Subject:
|
Following Robot
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Sun, 11 Feb 2007 14:17:53 GMT
|
Viewed:
|
3620 times
|
| |
| |
Hello. I am trying to program a simple Jentoo-based robot (
http://www.legoedwest.com/page.php?19 ) to follow moving objects. However this
is turning out to be much harder than expected.
Here it what I want to do:
1) The robot monitors the ultrasonic sensor every second, checks if there are
any objects in the range of the US and compares the speed at which they are
approaching with the robot's travel speed.
2) If the speeds are considerably different, the robot is approaching a moving
object.
3)If the object disappears, the robot assumes that it has moved away, stops, and
spins round, 45° at a time, looking for the moving object.
4) Once it has found it the robot moves towards it
Point 3 and 4 are then repeated throughout the program.
Unfortunately my knowledge of NXC is close to non existant, and doing this in
NXT-G would end up in a mess of connectors...
This is what I have written:
#include "NXCDefs.h"
int x;
int z;
int d;
int i;
int y;
int v;
task main()
{
SetSensorLowspeed(IN_4);
OnRevSync (OUT_AB, 100, 0);
}
task monitor_speed()
{
Follows(main);
while(true)
{
y = MotorTachoCount (OUT_A);
Wait(1000);
x = MotorTachoCount (OUT_A)-y; // angle in degrees
v = -100*x/2045; // velocity in cm/s
NumOut (0, LCD_LINE3, false, v);
}
}
task monitor_distance()
{
Follows(main);
while (true)
{
z = SensorUS (IN_4);
Wait(1000);
d = SensorUS (IN_4)-d;
d = abs (d); // difference in distance in cm(?)
NumOut (0, LCD_LINE5, false, z);
}
}
task monitor_wall()
{
Follows(main);
}
I have no idea on how to proceed from here... And I'm not even sure that what
I've written does what it's supposed to do.
Any Ideas
Thanks in Advance
Luca Bortolotti (A useless NXC programmer)
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|