To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 5935
5934  |  5936
Subject: 
Re: Locating your position with the help of fixed beacons (was Re: A RCX 'Beacon')
Newsgroups: 
lugnet.robotics
Date: 
Fri, 30 Jul 1999 22:20:19 GMT
Viewed: 
824 times
  
Someone asked me a question by email and I'm answering here, so as to benefit
others.

The question was, would the necessary algorithms fit in the RCX's memory and
leave enough room for anything else?

The necessary waveform analysis should be fairly simple. By my estimate there
are two or three loops to write, and each gets executed two or three times. I
think each would compile to about 100 bytecodes long. You would want to put the
loops in subroutines because each one gets used more than once.

The first loop has to watch the light level and note the min and max readings;
this is used to figure out when you're facing the beacon. There's another loop
around this loop, that turns the robot a little bit. The whole thing has to get
executed twice:

  bestdiff = 0;
  for(i=0; i<360; i++) {
    [turn motors on to turn clockwise slowly]
    [sleep for correct amount of time to rotate one degree]
    [turn motors off]
    min = 255; max = 0;
    for(i=0; i<100; i++) { /* make "100" bigger than beacon sweep time */
      [sleep for a tiny bit of time]
      ls = [light sensor reading]
      if (ls > max) max = ls;
      if (ls < min) min = ls;
    }
    diff = max - min;
    if (diff > bestdiff) {
      /* it's brighter */
      bestdiff = diff;
    } else if (diff < bestdiff-1) {
      /* it's dimmer */
      i = 361; /* exit loop and stop rotating! */
    }
  }
  [now repeat the whole thing, but turning counterclockwise]
  [finally, rotate 1 or two degrees clockwise again]

Then you have to sit still and watch the light level for sudden jumps and/or
drops. If the beacon is designed well, then you can get what you need in two
steps: first, measure the time between two consecutive drops to the min level,
second, measure the time between a drop to the min level and the following
jump.

You detect jumps and drops using a "time decay" function. The idea of "time
decay" is simple -- you have an "average" value and a "current" value, each
time you read a new "current" value, you add it into the average like this:

  average = ((average * 4) + current) / 5;

So the average changes a little each time and lags behind the current value.
Then it's easy to detect a jump because the current differs from the average by
a significant amount. I'll assume we're using NQC which has integers only, so
we'll multiply everything by 4 to keep the precision.

Here's the algorithm for step 1:

  /* "diff" still defined from above */
  average = [light reading] * 4; /* x 4 everywhere to avoid roundoff error */
  curtime = 0; /* this will be our "clock" */
  firstjump = 0;
  for(i=0; i<100; i++) {
    [sleep a tiny bit of time]
    curtime += 1;
    current = [light reading];
    average = (average + current) * 4 / 5;
    current = current * 4; /* so we can compare directly to average */
    jump = current - average;
    if (jump < 0) {
      /* it went down. How far? */
      jump = 0 - jump; /* make it positive */
      if (jump > diff) {
        /* this is enough to be noticable */
        firstjump = curtime;
      }
    }
    /* check if it's time to exit loop */
    if (curtime > firstjump + 5) {
      /* the first jump-down is well past, so let's move on... */
      i = 101; /* force loop exit */
    }
  }
  [then repeat the whole thing again to find "secondjump"]

Step 2 is similar, except the second time through the loop you're looking for a
jump "up". The useful data you end up with is the time difference
secondjump-firstjump, which tells you your heading from the beacon's point of
view, and the "diff" value which tells you how close to the beacon you are.

In lugnet.robotics, Robert Munafo writes:
The simplest way to do this is to build a device that emits a sweeping light
signal, similar to a lighthouse, and a blinking signal synchronized to the
sweep. Unlike a lighthouse, you want it to sweep back and forth (otherwise
there are problems with wires getting twisted).
[...]

- Robert Munafo



Message has 1 Reply:
  Soda-can challenge: beacons, tethers, etc. (was Re: Locating your position with the help of fixed be
 
Yet another comment about my "beacon" ideas. Yesterday I talked with someone who was involved in Joel Shafer's "soda can challenge" that was proposed in this message: (URL) learned that the primary reason people are trying to locate their *position* (...) (25 years ago, 2-Aug-99, to lugnet.robotics)

Message is in Reply To:
  Locating your position with the help of fixed beacons (was Re: A RCX 'Beacon')
 
(...) The simplest way to do this is to build a device that emits a sweeping light signal, similar to a lighthouse, and a blinking signal synchronized to the sweep. Unlike a lighthouse, you want it to sweep back and forth (otherwise there are (...) (25 years ago, 29-Jul-99, to lugnet.robotics)

15 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