int main (int argc, char *argv[]) { MonoAssembly *assembly = NULL; const char *aname = NULL; const char *outfile = NULL; const char *rootfile = NULL; int i; gboolean all_meta = FALSE; mono_init (argv [0]); type_table = g_hash_table_new (NULL, NULL); method_table = g_hash_table_new (NULL, NULL); field_table = g_hash_table_new (NULL, NULL); image_table = g_hash_table_new (NULL, NULL); for (i = 1; i < argc; ++i) { all_meta = FALSE; aname = argv [i]; if (strcmp (aname, "-v") == 0) { verbose++; continue; } else if (strcmp (aname, "-e") == 0) { force_enums = 1; continue; } else if (strcmp (aname, "-h") == 0) { usage (0); } else if (strcmp (aname, "-o") == 0) { i++; if (i >= argc) usage (1); outfile = argv [i]; continue; } else if (strcmp (aname, "-F") == 0) { i++; if (i >= argc) usage (1); all_meta = TRUE; aname = argv [i]; } else if (strcmp (aname, "-a") == 0) { i++; if (i >= argc) usage (1); rootfile = argv [i]; continue; } assembly = mono_assembly_open (aname, NULL); if (!assembly) { g_print ("cannot open assembly %s\n", aname); exit (1); } process_assembly (assembly, all_meta); } if (!assembly) usage (1); if (rootfile) load_roots (rootfile); process_images (); dump_images (outfile); return 0; }
void ManualOperation::work() { #ifndef DEBUG_FRAME_BY_FRAME // Turn off display by default if (image_input->can_display()) { mvWindow::setShowImage(show_raw_images); } #else // Show first image process_image(); #endif display_start_message(); // Take keyboard commands bool loop = true; while (loop) { char c = CharacterStreamSingleton::get_instance().wait_key(WAIT_KEY_IN_MS); // Print yaw and depth unless delayed by another message if (c == '\0') { if (count < 0) { count++; } else if (mode != VISION) { static int attitude_counter = 0; attitude_counter++; if (attitude_counter == 1000 / WAIT_KEY_IN_MS / REFRESH_RATE_IN_HZ) { attitude_counter = 0; char buf[128]; sprintf(buf, "Yaw: %+04d degrees, Depth: %+04d cm, Target Yaw: %+04d degrees, Target Depth: %+04d", attitude_input->yaw(), attitude_input->depth(), attitude_input->target_yaw(), attitude_input->target_depth()); message(buf); } } } switch(c) { case 'q': loop = false; break; case 'z': dump_images(); break; case 'y': if (image_input->can_display()) { show_raw_images = !show_raw_images; mvWindow::setShowImage(show_raw_images); } else { message_hold("Image stream should already be displayed"); } break; case 'u': use_fwd_img = !use_fwd_img; break; case 'i': actuator_output->special_cmd(SIM_MOVE_FWD); break; case 'k': actuator_output->special_cmd(SIM_MOVE_REV); break; case 'j': actuator_output->special_cmd(SIM_MOVE_LEFT); break; case 'l': actuator_output->special_cmd(SIM_MOVE_RIGHT); break; case 'p': actuator_output->special_cmd(SIM_MOVE_RISE); break; case ';': actuator_output->special_cmd(SIM_MOVE_SINK); break; case 'e': actuator_output->stop(); break; case 'w': actuator_output->set_attitude_change(FORWARD, SPEED_CHG); break; case 's': actuator_output->set_attitude_change(REVERSE, SPEED_CHG); break; case 'a': actuator_output->set_attitude_change(LEFT, YAW_CHG_IN_DEG); break; case 'd': actuator_output->set_attitude_change(RIGHT, YAW_CHG_IN_DEG); break; case 'r': actuator_output->set_attitude_change(RISE, DEPTH_CHG_IN_CM); break; case 'f': actuator_output->set_attitude_change(SINK, DEPTH_CHG_IN_CM); break; case ' ': actuator_output->special_cmd(SIM_ACCEL_ZERO); #ifdef DEBUG_FRAME_BY_FRAME process_image(); #endif break; case '^': actuator_output->special_cmd(SUB_POWER_ON); break; case '%': actuator_output->stop(); actuator_output->special_cmd(SUB_STARTUP_SEQUENCE); break; case '$': actuator_output->special_cmd(SUB_POWER_OFF); break; case '#': long_input(); break; case 'm': endwin(); // Scope mission so that it is destructed before display_start_message { Mission m(attitude_input, image_input, actuator_output); m.work_internal(true); } display_start_message(); message_hold("Mission complete!"); break; case 'M': // same as mission, but force turn off show_image endwin(); // Scope mission so that it is destructed before display_start_message { Mission m(attitude_input, image_input, actuator_output); m.work(); } display_start_message(); message_hold("Mission complete!"); break; case '0': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_TEST test_task(attitude_input, image_input, actuator_output); ret_code = test_task.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Test task completed successfully"); break; case TASK_QUIT: message_hold("Test task quit by user"); break; default: message_hold("Test task errored out"); break; } break; } delete vision_module; message_hold("Selected test vision module\n"); vision_module = new MDA_VISION_MODULE_TEST(); use_fwd_img = true; break; case '1': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_GATE gate_task(attitude_input, image_input, actuator_output); ret_code = gate_task.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Gate task completed successfully"); break; case TASK_QUIT: message_hold("Gate task quit by user"); break; default: message_hold("Gate task errored out"); break; } break; } delete vision_module; message_hold("Selected gate vision module\n"); vision_module = new MDA_VISION_MODULE_GATE(); use_fwd_img = true; break; case '2': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_PATH path_task(attitude_input, image_input, actuator_output); ret_code = path_task.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Path task completed successfully"); break; case TASK_QUIT: message_hold("Path task quit by user"); break; default: message_hold("Path task errored out"); break; } break; } delete vision_module; message_hold("Selected path vision module\n"); vision_module = new MDA_VISION_MODULE_PATH(); use_fwd_img = false; break; case '3': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_BUOY buoy_task(attitude_input, image_input, actuator_output); ret_code = buoy_task.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Buoy task completed successfully"); break; case TASK_QUIT: message_hold("Buoy task quit by user"); break; default: message_hold("Buoy task errored out"); break; } break; } delete vision_module; message_hold("Selected buoy vision module\n"); vision_module = new MDA_VISION_MODULE_BUOY(); use_fwd_img = true; break; case '4': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_FRAME frame_task(attitude_input, image_input, actuator_output); ret_code = frame_task.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Frame task completed successfully"); break; case TASK_QUIT: message_hold("Frame task quit by user"); break; default: message_hold("Frame task errored out"); break; } break; } delete vision_module; message_hold("Selected frame vision module\n"); vision_module = new MDA_VISION_MODULE_FRAME(); use_fwd_img = true; break; case '5': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_MARKER marker_task(attitude_input, image_input, actuator_output); ret_code = marker_task.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Marker task completed successfully"); break; case TASK_QUIT: message_hold("Marker task quit by user"); break; default: message_hold("Marker task errored out"); break; } break; } delete vision_module; message_hold("Selected marker dropper vision module\n"); vision_module = new MDA_VISION_MODULE_MARKER(); use_fwd_img = false; break; case '8': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_PATH_SKIP path_skip(attitude_input, image_input, actuator_output); ret_code = path_skip.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Path skip task completed successfully"); break; case TASK_QUIT: message_hold("Path skip task quit by user"); break; default: message_hold("Path skip task errored out"); break; } } break; case '9': if (mode != VISION) { endwin(); MDA_TASK_RETURN_CODE ret_code; // Scope task so that it is destructed before display_start_message { MDA_TASK_SURFACE surface_task(attitude_input, image_input, actuator_output); ret_code = surface_task.run_task(); } display_start_message(); switch(ret_code) { case TASK_DONE: message_hold("Surface task completed successfully"); break; case TASK_QUIT: message_hold("Surface task quit by user"); break; default: message_hold("Surface task errored out"); break; } } break; case 'x': if (mode == NORMAL) { break; } delete vision_module; vision_module = NULL; mode = NORMAL; display_start_message(); break; case 'v': if (mode == VISION) { delete vision_module; vision_module = NULL; } endwin(); mode = VISION; message( "Entering Vision Mode:\n" " 0 - test vision\n" " 1 - gate vision\n" " 2 - path vision\n" " 3 - buoy vision\n" " 4 - frame vision\n" " 5 - marker dropper vision\n" "\n" " v - cancel current vision selection\n" " x - exit vision mode\n" " q - exit simulator\n" ); break; case '\0': // timeout #ifndef DEBUG_FRAME_BY_FRAME process_image(); #else char ch = cvWaitKey(3); if (ch != -1) { CharacterStreamSingleton::get_instance().write_char(ch); } #endif break; } } // close ncurses endwin(); // Surface MDA_TASK_SURFACE surface(attitude_input, image_input, actuator_output); surface.run_task(); actuator_output->special_cmd(SUB_POWER_OFF); }