remoteCtrl.cpp
00001
00002
00003
00004
00005
00006
00007 #include "robotServer.h"
00008 #include "mRunCtrl.h"
00009 #include "mURGCtrl.h"
00010 #include "joystickCtrl.h"
00011 #include "inputHandle.h"
00012 #include <stdlib.h>
00013
00014
00015 int main(int argc, char *argv[]) {
00016 try {
00017 char* host = NULL;
00018 for (int i = 1; i < argc; ++i) {
00019 if (!strncmp("--host=", argv[i], 7)) {
00020 host = &argv[i][7];
00021 }
00022 }
00023 if (!host) {
00024 printf("specify connection host: --host=<host name>\n");
00025 exit(1);
00026 }
00027
00028 mRunCtrl run;
00029 mURGCtrl urg;
00030 vmonitor::connect(argc, argv);
00031 if (run.connectSocket(host, RunVirtualPort) < 0) {
00032 printf("RunCtrl::connectSocket: %s\n", run.what());
00033 exit(1);
00034 }
00035 if (urg.connectSocket(host, URGVirtualPort, true) < 0) {
00036 printf("URGCtrl::connectSocket: %s\n", run.what());
00037 exit(1);
00038 }
00039
00040
00041 enum { TcpipTimeout = 5000 };
00042 run.set_sendRetryTimes(0);
00043 run.set_recvTimeout(TcpipTimeout);
00044 urg.set_recvTimeout(TcpipTimeout);
00045 run.set_watchDogTimer(TcpipTimeout + 1000);
00046
00047 urg.setOwnCrdToObject(&run);
00048 run.adjustSubTreeTicks(0);
00049
00050 vmonitor::show();
00051
00052
00053 JoystickCtrl js;
00054 if (js.size() > 0) {
00055 js.activate();
00056 }
00057
00058
00059 UserInput::userInput_t ui;
00060 int pre_times = -1;
00061 do {
00062 ui = UserInput::getInputed();
00063 robotInput_t ri = inputHandle(js, ui);
00064 drawJetMode(ri);
00065 robotCtrl(run, ri);
00066
00067
00068 int times = urg.capture();
00069 if (times != pre_times) {
00070 drawCaptures(urg, run);
00071 }
00072 VXV::Delay(1);
00073 } while (!ui.quit);
00074 } catch (std::exception& e) {
00075 printf("exception: %s\n", e.what());
00076 }
00077 return 0;
00078 }
00079