55 printf(
"Caught signal %d, stopping program!\n", signum);
64 cout <<
"\nRequests a data stream from the specified rc_visard IP " 65 "\nand simply prints received data to std out." 67 << arg <<
" -v <rcVisardIP> -s <stream> [-i <networkInterface>][-n <numMessages>]" << endl;
70 int main(
int argc,
char* argv[])
74 WSAStartup(MAKEWORD(2, 2), &wsaData);
84 string visardIP, networkIface =
"", streamName =
"";
85 unsigned int maxNumMsgs = 50, cntMsgs = 0;
86 bool userSetIp =
false;
87 bool userSetStreamType =
false;
92 std::string p = argv[i++];
94 if (p ==
"-s" && i < argc)
96 streamName = string(argv[i++]);
97 userSetStreamType =
true;
99 else if (p ==
"-i" && i < argc)
101 networkIface = string(argv[i++]);
103 else if (p ==
"-v" && i < argc)
105 visardIP = string(argv[i++]);
108 else if (p ==
"-n" && i < argc)
110 maxNumMsgs = (
unsigned int)std::max(0, atoi(argv[i++]));
125 cerr <<
"Please specify rc_visard IP." << endl;
129 if (!userSetStreamType)
131 cerr <<
"Please specify stream type." << endl;
139 cout <<
"connecting rc_visard " << visardIP <<
"..." << endl;
145 cout <<
"starting rc_dynamics module on rc_visard..." << endl;
146 rcvisardDynamics->start();
150 cout <<
"ERROR! Could not start rc_dynamics module on rc_visard: " << e.what() << endl;
157 cout <<
"creating receiver and waiting for first messages to arrive..." << endl;
158 auto receiver = rcvisardDynamics->createReceiverForStream(streamName, networkIface);
159 receiver->setTimeout(250);
164 auto msg = receiver->receive(rcvisardDynamics->getPbMsgTypeOfStream(streamName));
167 cout <<
"received msg " << endl << msg->DebugString() << endl;
173 cout <<
"ERROR during streaming: " << e.what() << endl;
181 cout <<
"stopping rc_dynamics module on rc_visard..." << endl;
182 rcvisardDynamics->stop();
186 cout <<
"ERROR! Could not start rc_dynamics module on rc_visard: " << e.what() << endl;
189 cout <<
"Received " << cntMsgs <<
" " << streamName <<
" messages." << endl;
static Ptr create(const std::string &rc_visard_ip, unsigned int requests_timeout=5000)
Creates a local instance of rc_visard's remote pose interface.
void signal_callback_handler(int signum)
static bool caught_signal
catching signals for proper program escape
void printUsage(char *arg)
Print usage of example including command line args.
int main(int argc, char *argv[])