From: svnhieber Date: Thu, 2 Dec 2010 18:04:23 +0000 (+0000) Subject: log groud type, Roomba ID and type of move X-Git-Url: https://git.rohieb.name/bachelor-thesis/roomba_tests.git/commitdiff_plain/46028ef249b14aef45c0020fb1a379cb1128a1f9?hp=f6be7e61cd8ee3cfadf1d83c48a1b5b8d1628c0d log groud type, Roomba ID and type of move git-svn-id: https://svn.itm.uni-luebeck.de/wisebed/wiselib/trunk/pc_apps/roomba_tests@3675 f8795833-4959-0410-8ae9-8bcb0cfab428 --- diff --git a/main.cc b/main.cc index 2363146..5002d70 100644 --- a/main.cc +++ b/main.cc @@ -33,14 +33,14 @@ #include #include +using namespace std; + #if QT_VERSION < 0x040500 #define getInt QInputDialog::getInteger #else // QT_VERSION > 0x040500 #define getInt QInputDialog::getInt #endif // QT_VERSION -using namespace std; - // UART port on which we communicate with the Roomba char uart[] = "/dev/ttyUSB0"; @@ -58,6 +58,8 @@ OsModel::Timer::self_t timer; Roomba roomba; RoombaUart roomba_uart(os); ControlledMotion ctrl_motion; +char * roomba_id; +char * ground_type; /** * Sensor data we need, filled in callback @@ -110,44 +112,41 @@ void drive(Roomba& roomba, ControlledMotion& ctrl_motion) { input_distance = getInt(0, "Input distance", chargeText(roomba) + "Input new distance in mm:", input_distance, numeric_limits::min(), numeric_limits::max(), 1, &ok); - if(ok) { - // new turn velocity - velocity = getInt(0, "Input velocity", chargeText(roomba) - + "Input drive velocity in mm/sec:", velocity, -500, 500, 10, &ok); - if(ok) { - ctrl_motion.move_distance(input_distance, velocity); - roomba.wait_for_stop(); - } else { - break; - } - } else { + if(!ok) { break; } + // new velocity + velocity = getInt(0, "Input velocity", chargeText(roomba) + + "Input drive velocity in mm/sec:", velocity, -500, 500, 10, &ok); + if(!ok) { + break; + } + ctrl_motion.move_distance(input_distance, velocity); + roomba.wait_for_stop(); // measured deviation deviation_x = getInt(0, "Input x deviation", chargeText(roomba) + "Input travelled distance on x axis in mm:", deviation_x, numeric_limits::min(), numeric_limits::max(), 1, &ok); - if(ok) { - deviation_y = getInt(0, "Input y deviation", chargeText(roomba) - + "Input travelled distance on y axis in mm:", deviation_y, - numeric_limits::min(), numeric_limits::max(), 1, &ok); - if(ok) { - cout << "svn=" << SVNREVISION << " input_distance=" << input_distance - << " velocity=" << velocity << " internal_distance=" - << roomba.distance() << " deviation_x=" << deviation_x - << " deviation_y=" << deviation_y << " encoder_ticks_left=" - << sensor_data.left_encoder_counts << " encoder_ticks_right=" - << sensor_data.right_encoder_counts << " batt_charge=" - << sensor_data.charge << " batt_capacity=" << sensor_data.capacity - << " batt_voltage=" << sensor_data.voltage << " batt_current=" - << sensor_data.current << endl; - } else { - break; - } - } else { + if(!ok) { break; } + deviation_y = getInt(0, "Input y deviation", chargeText(roomba) + + "Input travelled distance on y axis in mm:", deviation_y, + numeric_limits::min(), numeric_limits::max(), 1, &ok); + if(!ok) { + break; + } + cout << "svn=" << SVNREVISION << " roomba_id=" << roomba_id + << " move=straight" << " ground_type=" << ground_type + << " input_distance=" << input_distance << " velocity=" << velocity + << " internal_distance=" << roomba.distance() << " deviation_x=" + << deviation_x << " deviation_y=" << deviation_y + << " encoder_ticks_left=" << sensor_data.left_encoder_counts + << " encoder_ticks_right=" << sensor_data.right_encoder_counts + << " batt_charge=" << sensor_data.charge << " batt_capacity=" + << sensor_data.capacity << " batt_voltage=" << sensor_data.voltage + << " batt_current=" << sensor_data.current << endl; } } @@ -188,14 +187,16 @@ void turn(Roomba& roomba, ControlledMotion& ctrl_motion) { // new current angle measured_angle = getInt(0, "Input measured angle", chargeText(roomba) + QString("Orientation should be %1 degree now.\n\n").arg((cur_angle - + turn_angle) % 360) + "Input measured angle in degree the Roomba has " + + turn_angle) % 360) + "Input measured angle in degree the Roomba has " "turned:", turn_angle, 0, numeric_limits::max(), 1, &ok); if(!ok) { break; } - cout << "turn_angle=" << turn_angle << " measured_angle=" << measured_angle - << " velocity=" << velocity << " internal_angle=" << roomba.angle() + cout << "svn=" << SVNREVISION << " roomba_id=" << roomba_id + << " move=straight" << " ground_type=" << ground_type << "turn_angle=" + << turn_angle << " measured_angle=" << measured_angle << " velocity=" + << velocity << " internal_angle=" << roomba.angle() << " encoder_ticks_left=" << sensor_data.left_encoder_counts << " encoder_ticks_right=" << sensor_data.right_encoder_counts << " batt_charge=" << sensor_data.charge << " batt_capacity=" @@ -204,7 +205,6 @@ void turn(Roomba& roomba, ControlledMotion& ctrl_motion) { // new orientation cur_angle = (cur_angle + measured_angle) % 360; - } } @@ -213,8 +213,9 @@ void turn(Roomba& roomba, ControlledMotion& ctrl_motion) { */ int main(int argc, char ** argv) { - if(argc < 2) { - cerr << "Usage: " << argv[0] << " --turn|-t|--drive|-d" << endl; + if(argc < 4) { + cerr << "Usage: " << argv[0] + << " --turn|-t|--drive|-d roomba-id ground-type" << endl; exit(-1); } @@ -241,6 +242,8 @@ int main(int argc, char ** argv) { roomba.notify_state_receivers(Roomba::DATA_AVAILABLE); // actual tests + roomba_id = argv[2]; + ground_type = argv[3]; if(strcmp(argv[1], "--turn") == 0 || strcmp(argv[1], "-t") == 0) { turn(roomba, ctrl_motion); } else if(strcmp(argv[1], "--drive") == 0 || strcmp(argv[1], "-d") == 0) {