|
In lugnet.robotics.rcx.legos, Elizabeth Mabrey wrote:
> >
> > start Loop
> > if-left light sensor=dark (less than threshold) -> reverse
> > left motor
> > else -> forward left motor
> > end if block
> >
> > if-right light sensor=dark -> reverse right motor
> > else -> forward right motor
> > end if block
> > end loop (jump to start)
>
>
> That's pretty much what I did initially, except I used to put in "wait" time
> and stops. By simply removing all the "stop"s and reduce the wait time, it
> works quite well on a simple line tracking test.
Your approach is pretty common. As it turns out, you can (should) remove the
wait time, also. Many people think they need to tell the robot how long to
turn, or how long to go forward.
It's like driving down the road in a car. You don't look at which direction you
want to go, close your eyes, drive for a bit, stop and start the loop again.
You want your robot to look at the road as much as possible.
There is no reason to have any waits in this program, because they could
actually cause the problem you're describing here:
>
> I multitask the light sensor readings because there may be times like the
> following:
>
> - right light sensor<= threshold ->
> | < making slight right turn >|
> (during this movement)
> | < some slipping condition happens! >|
> | < left light sensor across the the black line >|
> | < but did not get to read it yet >|
> - now both front legs(sensors) of the bot go over to the white area...
> - picture this: [] = the black line; b = back legs; f=front legs; L=
> light sensors
>
> []
> [] f L
> b [] L f
> b []
> - it keeps walking straight forward instead of making a left turn back on
> track.
> - in other words, I am trying to program it for more fault tolerant.
Fault tolerant is good. But, in this case I doubt it's required. I suspect the
robot doesn't move very fast. It may take at least a second for the light
sensor to cross the line, and in that time, the program should be able to read
the sensor several times (assuming there are no "waits" in the code)
But the above problem comes from this style of line following. With the two
sensors trying to stay "off" the line, the robot assumes (ass-u-me) the line is
between the sensors, but it really doesn't know.
Another option is to try and keep the sensors ON the line. If your program uses
the forward/reverse described above (not forward/stop) then you can test your
robot using this method, without reprogramming it, but just moving a couple
wires, and remounting the light sensors.
First, put the light sensors so they're touching each other. For the test, it's
not critical that they are in the middle of the robot.
Next, take the motor wires and swap them (move motor A to motor C, and C to A)
AND reverse the direction of the motors by rotating the wires 180 degrees.
Now, try it.
When the sensors are on dark, the robot should go forward. If one sensor goes
off the line (sees white), the motor on the other side will reverse, causing the
robot to turn back towards the line.
If BOTH sensors go off the line, the robot will actually back up until it finds
the line, again.
Steve
|
|
Message is in Reply To:
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|