#include <QApplication>
#include <QInputDialog>
+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";
Roomba roomba;
RoombaUart roomba_uart(os);
ControlledMotion ctrl_motion;
+char * roomba_id;
+char * ground_type;
/**
* Sensor data we need, filled in callback
input_distance = getInt(0, "Input distance", chargeText(roomba)
+ "Input new distance in mm:", input_distance,
numeric_limits<int>::min(), numeric_limits<int>::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<int>::min(), numeric_limits<int>::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<int>::min(), numeric_limits<int>::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<int>::min(), numeric_limits<int>::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;
}
}
// 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<int>::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="
// new orientation
cur_angle = (cur_angle + measured_angle) % 360;
-
}
}
*/
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);
}
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) {