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

(How) can a rospy node be reinitialized after ctrl+c?

asked 2014-05-28 07:11:16 -0500

updated 2014-05-28 07:12:12 -0500

TL:DR Is there a correct way to use rospy in the interactive shell? Seems stuck in shutdown after ctrl+c

Since interacting with ros from python is much more powerful than interacting via the command line interface, I've been attempting to use the interactive python shell to do many of the things I might otherwise do at the command line, like echoing and filtering messages.

The problem is that once I hit ctrl+c to SIGINT rospy.spin(), from then on out rospy.spin() is useless as it is in shutdown state. I've tried re-calling rospy.init_node again, but that fails to solve the problem.

So, is there a correct way to use rospy in the interactive shell?

Is there a way to kick rospy out of the shutdown state?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2014-05-28 07:49:07 -0500

In an interactive shell, there's no need for rospy.spin(). Unlike in C++ where it deals with processing the event queue, rospy.spin()'s only purpose is to keep your program from exiting.

edit flag offensive delete link more

Comments

That was the insight I needed. Thanks!

Asomerville gravatar image Asomerville  ( 2014-05-28 08:24:34 -0500 )edit
2

answered 2014-05-28 07:51:08 -0500

tfoote gravatar image

rospy is not designed to be used in an interactive shell. It is possible to restart a rospy process but it's not part of the public documented API.

Ken developed rosh as a prototype of an python based interactive environment for interacting with ROS. Dan seems to be maintaining a fork but it's not actively developed anymore.

edit flag offensive delete link more

Comments

1

rosh is great for interactive testing/prototyping - it deals with some of the paradigms ROS relies on that don't work well in an interactive context (like callbacks). The fork I maintain has been released into hydro, though I haven't had much time for new features.

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2014-05-28 09:00:48 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-28 07:11:16 -0500

Seen: 330 times

Last updated: May 28 '14