To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.spyboticsOpen lugnet.robotics.spybotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Spybotics / 409
408  |  410
Subject: 
Re: Spybot studies: seek a world object
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Tue, 18 Oct 2005 10:05:51 GMT
Viewed: 
10395 times
  
John,

perhaps you can help me with the directional capabilities.  I have attached a
copy of my code below.

I am reading the direction to another spybot/beacon and putting it through a
simple least squares adjustment.  I find over short distance (HERE and maybe
THERE) I can get very good directions with as little as 5 consecutive sensor
readings.  But when I extend this beyond the there zone (about 1m/3ft) I find
the spybot always reports direction as CENTER.

Do you get different results?  I have 4 beacons and 5 spybots, and basically get
the same results each time.  The batteries I am using are NiMH and fully
charged.  The beacon light appears strong (if that is any indication of battery
strength).

I have wondered how much my floor type & room size affects the IR sensor.

Any tips you have on the IR sensor readings would be very much appreciated.

Cheers,

Allen

#pragma reserve 0 20

#define sum_x (@12)
#define sum_y (@13)
#define sum_x_2 (@14)
#define sum_xy (@15)
#define intercept (@16)
#define updated (@17)

task main()
{
  int spy_direction;
  int TARGET;
  sum_x = 0;
  sum_y = 0;
  sum_xy = 0;
  sum_x_2 = 0;

  start display;
  SetPingInterval(1);
  ClearCounter(0);
  spy_direction = 0;
  TARGET = -1;
  ClearWorld();
  Wait(500);

  FindWorld(TARGET, SPY_RANGE, REL_GT, RANGE_NOWHERE);
  while(TARGET < 0)
    FindWorld(TARGET, SPY_RANGE, REL_GT, RANGE_NOWHERE);
  SetTargetID(TARGET);

  while(true)
  {
     //PlaySound(SOUND_CLICK);
     spy_direction = Target(SPY_DIRECTION);
     if(spy_direction > -1 && spy_direction < 5)
     {
       IncCounter(0);
       sum_x_2 = sum_x_2 + Counter(0)*Counter(0);
       sum_x = sum_x + Counter(0);
       sum_xy = sum_xy + Counter(0) * spy_direction;
       sum_y = sum_y + spy_direction;
       least_square();
     }

     //Wait(50);

     if(sum_x_2 > 25000)
     {
      sum_x = 0;
      sum_y = 0;
      sum_xy = 0;
      sum_x_2 = 0;
      ClearCounter(0);
      //PlaySound(SOUND_DOUBLE_BEEP);
     }
  }
}

task display()
{
  int state;

  while(true)
  {

     // put direction on green LEDs & distance on red LEDs

     //state = (spy_distance & 0x7) | ((avg_dir & 0x7) << 3) ;
     until(updated);

     SetLED(LED_MODE_ON, intercept);
   }
}

void least_square()
{
  int ssx;
  int ssxy;
  int b1;

  updated = false;
  ssx = sum_x_2 - ((sum_x * sum_x)/Counter(0));
  ssxy = sum_xy - ((sum_x * sum_y)/Counter(0));
  b1 = ssxy / ssx;
  intercept = (sum_y / Counter(0)) - (b1 * (sum_x / Counter(0)));
  updated = true;
}




In lugnet.robotics.spybotics, John Hansen wrote:
In lugnet.robotics.spybotics, Daniel Wittenaar wrote:
In lugnet.robotics.spybotics, Daniel Wittenaar wrote:
In lugnet.robotics.spybotics, Brian B. Alano wrote:
/*
beacon.nqc  <<



There was a bug in the code generated by NQC for the find opcode prior to
version 3.1r2.  If you are using a version of NQC older than 3.1r2 then that
*might* explain why Brian's beacon.nqc program fails to work sometimes.


John Hansen



Message has 2 Replies:
  Re: Spybot studies: seek a world object
 
Sorry, I forgot to mention I am using nqc 3.1r4 Allen (...) (19 years ago, 18-Oct-05, to lugnet.robotics.spybotics)
  Re: Spybot studies: seek a world object
 
(...) I can't find it right now, but I thought I read somewhere that if the direction is "anywhere", it will not have a direction. I believe that's consistant with what you're seeing. Steve (19 years ago, 18-Oct-05, to lugnet.robotics.spybotics)

Message is in Reply To:
  Re: Spybot studies: seek a world object
 
(...) There was a bug in the code generated by NQC for the find opcode prior to version 3.1r2. If you are using a version of NQC older than 3.1r2 then that *might* explain why Brian's beacon.nqc program fails to work sometimes. I will try to find a (...) (19 years ago, 4-Oct-05, to lugnet.robotics.spybotics)

14 Messages in This Thread:





Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR