forked from compAIR/libcreate
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
|
@ -48,10 +48,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 {
|
||||
std::cout << "Failed to connect to robot on port " << port.c_str() << std::endl;
|
||||
|
@ -59,19 +59,17 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
// Switch to Full mode
|
||||
robot->setMode(create::MODE_FULL);
|
||||
|
||||
std::cout << std::endl << "Press center 'Clean' button to disconnect and end program" << std::endl;
|
||||
robot.setMode(create::MODE_FULL);
|
||||
|
||||
// There's a delay between switching modes and when the robot will accept drive commands
|
||||
usleep(100000);
|
||||
|
||||
// Command robot to drive a radius of 0.15 metres at 0.2 m/s
|
||||
robot->driveRadius(0.2, 0.15);
|
||||
robot.driveRadius(0.2, 0.15);
|
||||
|
||||
while (!robot->isCleanButtonPressed()) {
|
||||
while (true) {
|
||||
// Get robot odometry and print
|
||||
const create::Pose pose = robot->getPose();
|
||||
const create::Pose pose = robot.getPose();
|
||||
|
||||
std::cout << std::fixed << std::setprecision(2) << "\rOdometry (x, y, yaw): ("
|
||||
<< pose.x << ", " << pose.y << ", " << pose.yaw << ") ";
|
||||
|
@ -79,15 +77,5 @@ int main(int argc, char** argv) {
|
|||
usleep(10000); // 10 Hz
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
// Call disconnect to avoid leaving robot in Full mode
|
||||
// Also, this consequently stops the robot from moving
|
||||
robot->disconnect();
|
||||
|
||||
// Clean up
|
||||
delete robot;
|
||||
|
||||
std::cout << "Bye!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue