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

Making rosnode_cleanup() not wait for y/n from user

asked 2022-05-19 04:28:26 -0500

abhishek47 gravatar image

I arrived at rosnode_cleanup() after looking at #q9521 and #q285530.

I need to use rosnode.rosnode_cleanup() in my Python script, but it is blocking because it waits for yes/no confirmation from user. While I understand this was put there for good reasons, for my purposes I need to make it non-blocking.

Is there a way to achieve that?

Looking at the source code, probably not? Is there another way to get the equivalent functionality without re-implementing most of rosnode myself?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-05-20 03:53:46 -0500

gvdhoorn gravatar image

updated 2022-05-20 03:54:09 -0500

Technically, you could probably hack around this by injecting characters into stdin in some way.

But I would not recommend you do that.

The main thing is: rosnode_cleanup() implements a TUI (text-bsed user interface). It's not meant to be reused as a vanilla function in a library.

If you want to reuse the main functionality, you'd have to call cleanup_master_blacklist(..) with the required arguments directly.

Is there another way to get the equivalent functionality without re-implementing most of rosnode myself?

I'm not sure what you're asking here.

rosnode_cleanup() essentially does this:

pinged, unpinged = rosnode_ping_all()
if unpinged:
    master = rosgraph.Master(ID)
    cleanup_master_blacklist(master, unpinged)

the rest is all just handling user input + output.

edit flag offensive delete link more

Comments

Thanks for the answer.

Is there another way to get the equivalent functionality without re-implementing most of rosnode myself?

Yeah I realize now simply importing rosnode_ping_all() and cleanup_master_blacklist() should be all I need.

abhishek47 gravatar image abhishek47  ( 2022-05-21 10:08:08 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-05-19 04:28:26 -0500

Seen: 160 times

Last updated: May 20 '22