ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Any way to re rospy.init_node

asked 2016-12-13 14:53:12 -0500

robogrow gravatar image

updated 2016-12-14 13:03:37 -0500

gvdhoorn gravatar image

I am trying to write an optimizer that launches many simulation ie. roslaunch.start()/shutdown()

If I init one node to subsrcibea and publish topics, after I shutdown the roslaunch sim, I signal_shutdown() the node. The next attempt to init that node doesn't work but issues no error. I do get a ROSInterruptexception when trying the call a publisher/subsriber (these are unregistered at the end of each sim run).

So I try to run roscore first and only issue one rospy.init_node before the roslaunch startup()/shutdown() loop. This seems to sort of work. But I get a terminal full of TF_OLD_DATA errors and after a few runs the code crashes. I found answer suggesting running reset_time message but no such topic exists in indigo. It appears that while the im clock is reset with a new roslaunch, the tf buffer or some other sim time artifact still has the sim time from the previous run.

I can't be the only person running multiple sim runs. Please advise


Edit: I am trying to run simulations in sequence. Which I can do with import roslaunch module.

But rospy.init_doesn't like to be called a second time.

I have it working by running roscore first and then only one rospy.init_node and declaring subscribers and publishers then unregistering them each roslaunch. However, this generates many "TF_OLD_DATA" warnings ten times a second on the screen. Makes it hard to debug code.

sorr about duplicate new to ROS

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-12-13 23:27:48 -0500

ahendrix gravatar image

The short answer is that rospy and roscpp are not designed to initialize multiple times.

When I've wanted to do things like this, I usually run a separate ROS core for each simulation run, and the program that runs the simulation is generally not a ROS node. If you need to collect data from each run you could write it to a bag file or a custom data file and read that from your runner.

edit flag offensive delete link more

Comments

Question Tools

1 follower

Stats

Asked: 2016-12-13 14:53:12 -0500

Seen: 1,157 times

Last updated: Dec 14 '16