gerkey / ros1_external_use

64 stars 12 forks source link

Automatic Launching of roscore #12

Closed liangfok closed 8 years ago

liangfok commented 8 years ago

What is the best practice for a C++ process to start a roscore if one does not exist? For example, if I run ros1_external_use/ros1_comms/listener.cpp without first launching a roscore, I'd like for it to go ahead and start a roscore rather than get stuck printing the following message:

[ERROR] [1460603956.331714509]: [registerPublisher] Failed to contact master at [localhost:11311].  Retrying...

Thanks!

jspricke commented 8 years ago

Best practice is actually to use roslaunch, as it would start the core automatically, if it doesn't find on. I don't think there is an easy way to do that in a listener.

liangfok commented 8 years ago

Thanks for the advice. I will test roslaunch. I hope I can run and control it from within a Google Test context!

gerkey commented 8 years ago

For testing, you should consider running rostest (http://wiki.ros.org/rostest). It's basically just an extension of roslaunch that will:

You might have to play a little with directing and collecting the test results that are produced by rostest and feeding them into your own reporting scheme, but it should be doable.