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