1
$\begingroup$

Rosanswers logo

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?


Originally posted by Asomerville on ROS Answers with karma: 2743 on 2014-05-28

Post score: 1

$\endgroup$

2 Answers 2

1
$\begingroup$

Rosanswers logo

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.


Originally posted by Dan Lazewatsky with karma: 9115 on 2014-05-28

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by Asomerville on 2014-05-28:
That was the insight I needed. Thanks!

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by tfoote with karma: 58457 on 2014-05-28

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Dan Lazewatsky on 2014-05-28:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.