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 uint16_t light_signals[6];
00066 bool light_bumpers[6];
00067 bool contact_bumpers[2];
00068
00069 while (!robot->isCleanButtonPressed()) {
00070
00071 if (model == create::RobotModel::CREATE_2) {
00072
00073 light_signals[0] = robot->getLightSignalLeft();
00074 light_signals[1] = robot->getLightSignalFrontLeft();
00075 light_signals[2] = robot->getLightSignalCenterLeft();
00076 light_signals[3] = robot->getLightSignalCenterRight();
00077 light_signals[4] = robot->getLightSignalFrontRight();
00078 light_signals[5] = robot->getLightSignalRight();
00079
00080
00081 light_bumpers[0] = robot->isLightBumperLeft();
00082 light_bumpers[1] = robot->isLightBumperFrontLeft();
00083 light_bumpers[2] = robot->isLightBumperCenterLeft();
00084 light_bumpers[3] = robot->isLightBumperCenterRight();
00085 light_bumpers[4] = robot->isLightBumperFrontRight();
00086 light_bumpers[5] = robot->isLightBumperRight();
00087 }
00088
00089
00090 contact_bumpers[0] = robot->isLeftBumper();
00091 contact_bumpers[1] = robot->isRightBumper();
00092
00093
00094 std::cout << "[ " << light_signals[0] << " , "
00095 << light_signals[1] << " , "
00096 << light_signals[2] << " , "
00097 << light_signals[3] << " , "
00098 << light_signals[4] << " , "
00099 << light_signals[5]
00100 << " ]" << std::endl;
00101 std::cout << "[ " << light_bumpers[0] << " , "
00102 << light_bumpers[1] << " , "
00103 << light_bumpers[2] << " , "
00104 << light_bumpers[3] << " , "
00105 << light_bumpers[4] << " , "
00106 << light_bumpers[5]
00107 << " ]" << std::endl;
00108 std::cout << "[ " << contact_bumpers[0] << " , "
00109 << contact_bumpers[1]
00110 << " ]" << std::endl;
00111 std::cout << std::endl;
00112
00113 usleep(100000);
00114 }
00115
00116 std::cout << std::endl;
00117
00118
00119 robot->disconnect();
00120
00121
00122 delete robot;
00123
00124 std::cout << "Bye!" << std::endl;
00125 return 0;
00126 }