August 19, 2007, 3:45 am
RXC1.0 Mindstorms, LEJOS
HELLO! I cant seem to find a LEJOS forum anywhere, so if there is one
could someone pelase link me.. otherwise.
I am having trouble using a timer. In my program the robot is ment to
follow a wall and when it loses the wall it spins around in circles in
a loop trying to find the wall again. However , sometimes it does not
find the wall again and will keep spinning around indefinetely! So
what I want do is put a timer on this loop which will break out of the
loop after 5 seconds. So what I have done is this.
class Robot implements TimerListener
{
private static boolean breakOut = true;
private static Sensor lightSensor3 = Sensor.S3;
public void timedOut()
{
breakOut = false;
Sound.beep();
}
public static void goLeftWithSensor()
{
Timer timer = new Timer(5000, new Robot());
timer.start();
moveForward(9);
while (lightSensor3.readValue() < 33 && breakOut)
{
stop();
setSpeed(5);
go_left();
}
timer.stop();
}
}
This class is called in the sensor listner every time the value is
below 33 and then this class will keep the robot in the while loop
untill the sensor value is greater then 33. So this class will be
called a lot. However, I only want to do this for 5 seconds. This
works correctly, but say if it breaks out of the while loop before
the timer is up, it will still activate the timedOut() method.
So my question is, how to make it so the timedOut method is ONLY
accessed when the timer reaches 5 seconds, not before even if the loop
is broken out of and the program keeps going.
Also, is it possible to detect if a wheel is jammed and not moving? so
I can make it revearse.
Thanks in advance!
HELLO! I cant seem to find a LEJOS forum anywhere, so if there is one
could someone pelase link me.. otherwise.
I am having trouble using a timer. In my program the robot is ment to
follow a wall and when it loses the wall it spins around in circles in
a loop trying to find the wall again. However , sometimes it does not
find the wall again and will keep spinning around indefinetely! So
what I want do is put a timer on this loop which will break out of the
loop after 5 seconds. So what I have done is this.
class Robot implements TimerListener
{
private static boolean breakOut = true;
private static Sensor lightSensor3 = Sensor.S3;
public void timedOut()
{
breakOut = false;
Sound.beep();
}
public static void goLeftWithSensor()
{
Timer timer = new Timer(5000, new Robot());
timer.start();
moveForward(9);
while (lightSensor3.readValue() < 33 && breakOut)
{
stop();
setSpeed(5);
go_left();
}
timer.stop();
}
}
This class is called in the sensor listner every time the value is
below 33 and then this class will keep the robot in the while loop
untill the sensor value is greater then 33. So this class will be
called a lot. However, I only want to do this for 5 seconds. This
works correctly, but say if it breaks out of the while loop before
the timer is up, it will still activate the timedOut() method.
So my question is, how to make it so the timedOut method is ONLY
accessed when the timer reaches 5 seconds, not before even if the loop
is broken out of and the program keeps going.
Also, is it possible to detect if a wheel is jammed and not moving? so
I can make it revearse.
Thanks in advance!
Re: Mindstorm questions
There is a huge LEGO forum, with lots of activity; it's at
<http://news.lugnet.com> . If you ask in the Robotics subforum, I'm sure
you can find someone who can help with LEJOS.
Good luck,
- Joe
--
"Polywell" fusion -- an approach to nuclear fusion that might actually work.
Learn more and discuss via: <http://www.strout.net/info/science/polywell/>
Site Timeline
- » Mars Exploration Rover Update - August 20, 2007
- — Next thread in » General Robotics Forum
-

- » C-R-M: Suggested posting format
- — Previous thread in » General Robotics Forum
-

- » evoMUSART 2013: First CFP (with correct dates)
- — Newest thread in » General Robotics Forum
-

- » Bending 1/8 inch thick 7075-T6 aluminum
- — The site's Newest Thread. Posted in » General Metalworking
-

- » Rysunek techniczny-pytania
- — The site's Last Updated Thread. Posted in » Engineering Science (Polish)
-


Subject


