|
|
@ -18,13 +18,34 @@ int main(int argc, char* argv[])
|
|
|
|
|
|
|
|
|
|
|
|
set_sdk_mode(client, true);
|
|
|
|
set_sdk_mode(client, true);
|
|
|
|
poll_message(client, &msg);
|
|
|
|
poll_message(client, &msg);
|
|
|
|
if(msg.header.cmdid == SET_SDK_MODE_CMDID || msg.resp.sdkmode.retcode) {
|
|
|
|
if(msg.header.cmdid != SET_SDK_MODE_CMDID || msg.resp.sdkmode.retcode) {
|
|
|
|
fprintf(stderr, "Could not set SDK mode\n");
|
|
|
|
fprintf(stderr, "Could not set SDK mode\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subnode_reset(client);
|
|
|
|
|
|
|
|
poll_message(client, &msg);
|
|
|
|
|
|
|
|
if(msg.header.cmdid != SUBNODE_RESET_CMDID || msg.resp.subnodereset.retcode) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Could not reset subnode subscription\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subscribe_add_node(client);
|
|
|
|
|
|
|
|
poll_message(client, &msg);
|
|
|
|
|
|
|
|
if(msg.header.cmdid != SUBSCRIBE_ADD_NODE_CMDID || (msg.resp.subnodeadd.retcode && msg.resp.subnodeadd.retcode != 0x50)) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Could not subscribe node\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_robot_mode(client, MOVEMENTMODE_FREE);
|
|
|
|
|
|
|
|
poll_message(client, &msg);
|
|
|
|
|
|
|
|
if(msg.header.cmdid != SET_ROBOT_MODE_CMDID || msg.resp.mvmode.retcode) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Could not set move mode\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int c;
|
|
|
|
int c;
|
|
|
|
while((c = getopt(argc, argv, "hl:::w::::"))) {
|
|
|
|
while((c = getopt(argc, argv, "hl:::s:::")) != -1) {
|
|
|
|
switch(c) {
|
|
|
|
switch(c) {
|
|
|
|
case 'l':
|
|
|
|
case 'l':
|
|
|
|
set_system_led (
|
|
|
|
set_system_led (
|
|
|
@ -38,25 +59,29 @@ int main(int argc, char* argv[])
|
|
|
|
100,
|
|
|
|
100,
|
|
|
|
100 );
|
|
|
|
100 );
|
|
|
|
poll_message(client, &msg);
|
|
|
|
poll_message(client, &msg);
|
|
|
|
if(msg.header.cmdid == SET_SYSTEM_LED_CMDID || msg.resp.led.retcode) {
|
|
|
|
if(msg.header.cmdid != SET_SYSTEM_LED_CMDID || msg.resp.led.retcode) {
|
|
|
|
fprintf(stderr, "Could not set LED color\n");
|
|
|
|
fprintf(stderr, "Could not set LED color\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'w':
|
|
|
|
case 's':
|
|
|
|
set_wheel_speed (
|
|
|
|
chassis_speed_mode (
|
|
|
|
client,
|
|
|
|
client,
|
|
|
|
strtol(argv[optind + 0], NULL, 0),
|
|
|
|
atof(argv[optind + 0]),
|
|
|
|
strtol(argv[optind + 1], NULL, 0),
|
|
|
|
atof(argv[optind + 1]),
|
|
|
|
strtol(argv[optind + 2], NULL, 0),
|
|
|
|
atof(argv[optind + 2]) );
|
|
|
|
strtol(argv[optind + 3], NULL, 0) );
|
|
|
|
poll_message(client, &msg);
|
|
|
|
|
|
|
|
if(msg.header.cmdid != CHASSIS_SPEED_MODE_CMDID || msg.resp.chsspeed.retcode) {
|
|
|
|
|
|
|
|
fprintf(stderr, "Could not set speed\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "Unknown argument %c\n", optopt);
|
|
|
|
fprintf(stderr, "Unknown argument %c\n", optopt);
|
|
|
|
case 'h':
|
|
|
|
case 'h':
|
|
|
|
printf("Usage: [-h] [-l r g b] [-w w1 w2 w3 w4]");
|
|
|
|
printf("Usage: [-h] [-l r g b] [-w w1 w2 w3 w4]");
|
|
|
|
break;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|