odom_example.cpp
Go to the documentation of this file.
00001 #include "create/create.h"
00002 
00003 create::Create* robot;
00004 
00005 int main(int argc, char** argv) {
00006   std::string port = "/dev/ttyUSB0";
00007   int baud = 115200;
00008   create::RobotModel model = create::RobotModel::CREATE_2;
00009 
00010   if (argc > 1 && std::string(argv[1]) == "create1") {
00011     model = create::RobotModel::CREATE_1;
00012     baud = 57600;
00013     std::cout << "1st generation Create selected" << std::endl;
00014   }
00015 
00016   robot = new create::Create(model);
00017 
00018   // Attempt to connect to Create
00019   if (robot->connect(port, baud))
00020     std::cout << "Successfully connected to Create" << std::endl;
00021   else {
00022     std::cout << "Failed to connect to Create on port " << port.c_str() << std::endl;
00023     return 1;
00024   }
00025 
00026   robot->setMode(create::MODE_FULL);
00027 
00028   usleep(1000000);
00029 
00030   // Drive in a circle
00031   robot->drive(0.1, 0.5);
00032 
00033   // Quit when center "Clean" button pressed
00034   while (!robot->isCleanButtonPressed()) {
00035     create::Pose pose = robot->getPose();
00036     create::Vel vel = robot->getVel();
00037 
00038     // Print pose
00039     std::cout << "x: " << pose.x
00040               << "\ty: " << pose.y
00041               << "\tyaw: " << pose.yaw * 180.0/create::util::PI << std::endl << std::endl;
00042   
00043     // Print velocity
00044     std::cout << "vx: " << vel.x
00045               << "\tvy: " << vel.y
00046               << "\tvyaw: " << vel.yaw * 180.0/create::util::PI << std::endl << std::endl;
00047 
00048     // Print covariances
00049     std::cout << "[ " << pose.covariance[0] << ", " << pose.covariance[1] << ", " << pose.covariance[2] << std::endl
00050               << "  " << pose.covariance[3] << ", " << pose.covariance[4] << ", " << pose.covariance[5] << std::endl
00051               << "  " << pose.covariance[6] << ", " << pose.covariance[7] << ", " << pose.covariance[8] << " ]" << std::endl << std::endl;;
00052     std::cout << "[ " << vel.covariance[0] << ", " << vel.covariance[1] << ", " << vel.covariance[2] << std::endl
00053               << "  " << vel.covariance[3] << ", " << vel.covariance[4] << ", " << vel.covariance[5] << std::endl
00054               << "  " << vel.covariance[6] << ", " << vel.covariance[7] << ", " << vel.covariance[8] << " ]" << std::endl << std::endl;;
00055     usleep(1000 * 100); //10hz
00056   }
00057 
00058   std::cout << "Stopping Create." << std::endl;
00059 
00060   robot->disconnect();
00061   delete robot;
00062 
00063   return 0;
00064 }


libcreate
Author(s): Jacob Perron
autogenerated on Sat Nov 26 2016 03:41:46