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 / 22676
22675  |  22677
Subject: 
Re: Competitive MINDSTORMS: try again...
Newsgroups: 
lugnet.robotics
Date: 
Fri, 20 Aug 2004 16:09:37 GMT
Viewed: 
1213 times
  
In lugnet.robotics, Steve Hassenplug wrote:
In lugnet.robotics, David Perdue wrote:

given this piece of code:
----
So let's look at this portion of code:

        /* if Input Port 1 is less than "thresh" or
         * equal to 100*/
          if(LBump<=thresh | LBump==100)
          {

<snip>
  // ...attack!
until(LBump==thresh+5); // until sumo-bot goes away

<snip>
}

void Calibrate2()
{
<snip>
    thresh=LBump;
<snip>
}

----

'thresh' will be reading the ambient light in the room. (from the calibrate2
function)

The 'search' routine will immediately go into attack mode (low gear) because
(LBump<=thresh) is true, because both LBump and thresh are both reading the
ambient light in the room.


At no point will the reading on LBump go above 'thresh', unless the light sensor
is pointing towards a white robot.  So, the loop:
until(LBump==thresh+5);
will never exit (unless you see a white robot, in which case you DON'T want it
to exit, but it will)

This is actually incorrect - I see where you're getting confused. You are
thinking that the Calibrate2() function is always running, and the
"thresh=LBump;" is always being updated, correct? You see, Calibrate2() is only
run just once, and never again in the entire program. It provides the program
with a reading of the light in the room once, but never again. After the very
beginning of the program, Calibrate2() is completely ignored, and the value of
the variable thresh is never again changed.

Therefore, in this line of code:

if(LBump<=thresh | LBump==100)

the first part says that if LBump is less than the value of thresh--whose value
was adjusted only once, and will not change again--then we know we have the
opponent in sight. Likewise, if LBump starts to read that it is equal to
thresh+5--a value which is taken once and will never change--it knows that it
has lost sight of the opponent.


Thanks,

David J. Perdue

www.davidjperdue.com

www.davidjperdue.com/competitivemindstorms



Message has 1 Reply:
  Re: Competitive MINDSTORMS: try again...
 
(...) No, that's not what I was thinking. I see Calibrate and Calibrate2 only run at the beginning of the program. (...) Actually, it says that if LBump is less than OR EQUAL TO the value of thresh... Which means if the light in the room NOW is the (...) (20 years ago, 20-Aug-04, to lugnet.robotics)

Message is in Reply To:
  Re: Competitive MINDSTORMS: try again...
 
In lugnet.robotics, David Perdue wrote: given this piece of code: ---- (...) <snip> (...) <snip> (...) void Calibrate2() { <snip> thresh=LBump; <snip> } ---- 'thresh' will be reading the ambient light in the room. (from the calibrate2 function) The (...) (20 years ago, 20-Aug-04, to lugnet.robotics)

29 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