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 / 403
402  |  404
Subject: 
Re: Spybot studies: seek a world object
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Sun, 25 Sep 2005 19:17:29 GMT
Viewed: 
9928 times
  
In lugnet.robotics.spybotics, Brian B. Alano wrote:
/*
beacon.nqc

Uses World Relation Table to get a fix on and drive to another object.
The object can be a Spybot, PC, or Spybot Controller.

The program fixes on (i.e. drives to) the first object it finds. If that
object disappears from the "radar", it will fix on the next one. The
program exits when none are in range.

Functions illustrated:
ClearWorld()
FindWorld([WorldIndex], SPY_RANGE, REL_GT, RANGE_NOWHERE)
SetTargetID([WorldIndex])
Target(SPY_RANGE)
Target(SPY_DIRECTION)

Thoughts and discoveries.
1. The Spybot suffers from the same ills that most two-eared creatures do,
it can't tell whether an object is ahead left or behind right. This
leads it to go in the opposite direction that it should sometimes. There's a
word for this phenomenon, but I can't recall it.

2. I only registered LEFT_OF_CENTER and RIGHT_OF_CENTER when the
object was also in RANGE_HERE.

3. This program usually failed to fix acurately on a second target
after the initial target went to RANGE_NOWHERE.

4. There's probably a ROM routine that does the same thing as this
program, but it may not be useful from NQC.

Uses spy.nqh by John Hansen released 22 Oct 2003. See
http://news.lugnet.com/robotics/spybotics/?n=235

* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/

*/

#include "spy.nqh"

// Convenience macros for my particular 'bot.
#define FWD(x)     OnRev(x)
#define REV(x)     OnFwd(x)
#define OUT_LEFT   OUT_B
#define OUT_RIGHT  OUT_A

task main()
{
    int t = -1;     // our index into the World Relation Table
    int x;          // temp var
    int range;      // range to the current target
    int state = 0;  // used for displaying SHORT_ID and RANGE on LEDs
    ClearWorld();   // empty the World Relation Table
    // wait for pings to be recieved.
    // I think this wait could be smaller, but I don't know by how much.
    // Probably something like 2x the default ping interval is enough.
    Wait(100);
    // FindWorld sets t to the next valid index in the World Relation Table
    // or to -1 if there are no more entries.
    FindWorld(t, SPY_RANGE, REL_GT, RANGE_NOWHERE);
    while (t != -1)
    {
        // By using SetTargetID, we can use the Target() convenience methods
        // for accessing the properities of the device.
        SetTargetID(t);
        x = Target(SPY_SHORTID);
        // put ID of the current target in red LEDs
        state = x & 0x7;
SetLED(LED_MODE_ON, state);
        // Insure object is still in range before assuming other values are
good.
        range = Target(SPY_RANGE);
while (range != RANGE_NOWHERE) {
    x = Target(SPY_DIRECTION);
            // put direction on green LEDs
            state = (state & 0x7) | ((x & 0x7) << 3) ;
    SetLED(LED_MODE_ON, state);

            if (range == RANGE_HERE) { // we made it!
        Off(OUT_A+OUT_B);
    } else {
                // Turn and move toward the target
                switch (x) {
    case DIRECTION_LEFT:
        REV(OUT_LEFT);
                        FWD(OUT_RIGHT);
                break;
    case DIRECTION_LEFT_OF_CENTER:
        Float(OUT_LEFT);
                        FWD(OUT_RIGHT);
                break;
    case DIRECTION_CENTER:
        FWD(OUT_LEFT+OUT_RIGHT);
        break;
    case DIRECTION_RIGHT:
        REV(OUT_RIGHT);
                        FWD(OUT_LEFT);
        break;
    case DIRECTION_RIGHT_OF_CENTER:
        Float(OUT_RIGHT);
                        FWD(OUT_LEFT);
        break;
    default:
                        // should never get here
        PlaySound(SOUND_LOW_BEEP);
        }  // end switch
    } // end if range
            range = Target(SPY_RANGE);   // update the range to the target
        } // end while in range
        // If we're here, it means our current target moved to RANGE_NOWHERE
        // so we need to acquire a new target.
        FindWorld(t, SPY_RANGE, REL_GT, RANGE_NOWHERE);
    } // end while

}

Well We are trying to get Spybotics following an IR emitting Ball..  This ball
will be emitting the same data as the Controller does on blinking mode..

But somehow the program above (as said before) Will not work propperly and send
the spybot as well away as to the ball because it has some problem to determine
where the signal comes from..

Somehow Lego did manage that good.. Because if i take the default programm in
the Spybotic that can indicte and find the 'beacon' (controller) It can find it
perfectly without very much problems...

Maybe Lego is also using the IR sensor that is stcked in behind to determen if
it comes from the front or from the right...

Is somebody intrested to help us out to get a more stable program that will find
the beacon in 98% of the time???

Many thanks in advanced,
Daniel Wittenaar



Message has 1 Reply:
  Re: Spybot studies: seek a world object
 
(...) Nobody who can help us out on this one?? I'm looking for the NQC comando's that can control (readout) the sensor on the rear of the spybot.. This can be used as told above to determen if the beacon is in front of the spybot.. Or behind the (...) (19 years ago, 1-Oct-05, to lugnet.robotics.spybotics)

Message is in Reply To:
  Spybot studies: seek a world object
 
/* beacon.nqc Uses World Relation Table to get a fix on and drive to another object. The object can be a Spybot, PC, or Spybot Controller. The program fixes on (i.e. drives to) the first object it finds. If that object disappears from the "radar", (...) (21 years ago, 10-Nov-03, 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