-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_4_2_2.cpp
More file actions
36 lines (27 loc) · 769 Bytes
/
Copy pathex_4_2_2.cpp
File metadata and controls
36 lines (27 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <ros/ros.h>
#include <unistd.h>
#include "texas_robotics_academy/texbot_wrapper.h"
int main(int argc, char **argv) {
ros::init(argc, argv, "robot");
TexBot bot;
double leftObstacleSensor(),rightObstacleSensor();
while(ros::ok()) {
if (bot.leftObstacleSensor()<5) {bot.lcd1("left sensor active");
bot.ledLeft(true);
}
else if (bot.rightObstacleSensor()<5) {bot.lcd1("right sensor active");
bot.ledRight(true);
}
else if (bot.rightObstacleSensor()<5 && bot.leftObstacleSensor()<5) {bot.lcd1("both sensors active");
bot.ledRight(true);
bot.ledLeft(true);
}
else {bot.lcd1 (" ");
bot.ledLeft(false);
bot.ledRight(false);
}
ros::spinOnce();
usleep(1000000);
}
return 0;
}