Go to the documentation of this file.00001
00031 #include "create/create.h"
00032
00033 #include <iomanip>
00034 #include <iostream>
00035
00036 int main(int argc, char** argv) {
00037
00038 create::RobotModel model = create::RobotModel::CREATE_2;
00039 std::string port = "/dev/ttyUSB0";
00040 int baud = 115200;
00041 if (argc > 1 && std::string(argv[1]) == "create1") {
00042 model = create::RobotModel::CREATE_1;
00043 baud = 57600;
00044 std::cout << "Running driver for Create 1" << std::endl;
00045 }
00046 else {
00047 std::cout << "Running driver for Create 2" << std::endl;
00048 }
00049
00050
00051 create::Create* robot = new create::Create(model);
00052
00053
00054 if (robot->connect(port, baud))
00055 std::cout << "Connected to robot" << std::endl;
00056 else {
00057 std::cout << "Failed to connect to robot on port " << port.c_str() << std::endl;
00058 return 1;
00059 }
00060
00061
00062 robot->setMode(create::MODE_FULL);
00063
00064 std::cout << std::endl << "Press center 'Clean' button to disconnect and end program" << std::endl;
00065
00066
00067 usleep(100000);
00068
00069
00070 robot->driveRadius(0.2, 0.15);
00071
00072 while (!robot->isCleanButtonPressed()) {
00073
00074 const create::Pose pose = robot->getPose();
00075
00076 std::cout << std::fixed << std::setprecision(2) << "\rOdometry (x, y, yaw): ("
00077 << pose.x << ", " << pose.y << ", " << pose.yaw << ") ";
00078
00079 usleep(10000);
00080 }
00081
00082 std::cout << std::endl;
00083
00084
00085
00086 robot->disconnect();
00087
00088
00089 delete robot;
00090
00091 std::cout << "Bye!" << std::endl;
00092 return 0;
00093 }