Cleanup examples
Signed-off-by: Jacob Perron <jacobmperron@gmail.com>
This commit is contained in:
parent
eaeea24a21
commit
dff0308b1b
8 changed files with 69 additions and 153 deletions
|
@ -47,10 +47,10 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
// Construct robot object
|
||||
create::Create* robot = new create::Create(model);
|
||||
create::Create robot(model);
|
||||
|
||||
// Connect to robot
|
||||
if (robot->connect(port, baud)) {
|
||||
if (robot.connect(port, baud)) {
|
||||
std::cout << "Connected to robot" << std::endl;
|
||||
}
|
||||
else {
|
||||
|
@ -59,16 +59,14 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
// Switch to Full mode
|
||||
robot->setMode(create::MODE_FULL);
|
||||
robot.setMode(create::MODE_FULL);
|
||||
|
||||
std::cout << std::endl << "Press center 'Clean' button to disconnect and end program" << std::endl;
|
||||
|
||||
while (!robot->isCleanButtonPressed()) {
|
||||
while (true) {
|
||||
// Get cliff status
|
||||
const bool cliff_left = robot->isCliffLeft();
|
||||
const bool cliff_front_left = robot->isCliffFrontLeft();
|
||||
const bool cliff_front_right = robot->isCliffFrontRight();
|
||||
const bool cliff_right = robot->isCliffRight();
|
||||
const bool cliff_left = robot.isCliffLeft();
|
||||
const bool cliff_front_left = robot.isCliffFrontLeft();
|
||||
const bool cliff_front_right = robot.isCliffFrontRight();
|
||||
const bool cliff_right = robot.isCliffRight();
|
||||
|
||||
// Print status
|
||||
std::cout << "\rCliffs (left to right): [ " <<
|
||||
|
@ -84,13 +82,5 @@ int main(int argc, char** argv) {
|
|||
usleep(10000); // 10 Hz
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
// Call disconnect to avoid leaving robot in Full mode
|
||||
robot->disconnect();
|
||||
|
||||
// Clean up
|
||||
delete robot;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue