I am trying to have a wall follow robot but there are errors on the names not being declared in my s
Posted
by Sam
on Stack Overflow
See other posts from Stack Overflow
or by Sam
Published on 2010-03-30T14:49:31Z
Indexed on
2010/03/30
14:53 UTC
Read the original article
Hit count: 323
#include <iostream>
#include <libplayerc++/playerc++.h>
using namespace std;
int main(int argc, char *argv[])
{
using namespace PlayerCc;
PlayerClient robot("localhost");
BumperProxy bp(&robot,0);
Position2dProxy pp(&robot,0);
pp.SetMotorEnable(true);
for(;;)
double turnrate, speed;
double error;
bool wall;
motor_a_speed(0);
motor_c_speed(0);
while(1) {
front_bumper = SENSOR_2;
left_bumper = SENSOR_3;
if (front_bumper > 2) {
if (left_bumper < 3) {
motor_a_speed(5);
motor_c_speed(drive_speed);
motor_a_dir(fwd);
motor_c_dir(fwd);
}
else {
motor_a_speed(drive_speed);
motor_c_speed(5);
motor_a_dir(rev);
motor_c_dir(rev);
}
}
else {
motor_a_speed(drive_speed);
motor_c_speed(drive_speed);
motor_a_dir(brake);
motor_c_dir(brake);
mrest(100);
cputs("bump");
motor_a_dir(fwd);
motor_c_dir(rev);
msleep(450);
cputs("right");
motor_a_speed(10);
motor_a_dir(fwd);
motor_c_dir(fwd);
mrest(1300);
}
pp.SetSpeed(speed, turnrate);
}
}
© Stack Overflow or respective owner