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

Check if a node exists using rosnode.rosnode_ping()

asked 2022-06-11 17:54:34 -0500

blackbird gravatar image

I just need to find a method to check if a node exists. I'm programming with python and using threading module to make the node run in another thread (otherwise the main thread would get blocked.). Then I just use rosnode.rosnode_ping("/my_node_name") to check if it is alive in the main thread. When running, rosnode.rosnode_ping() method seems to be in a dead loop, and I can't figure out the reason (have some problem understanding the rosnode source code).

FInally I used rosnode.get_node_names() to get the list of node name and check if the node is in it. THis method works. I just wonder what is the method rosnode.rosnode_ping() really for. In api document it seems to be a method to check connectivity. But is that not for checking if node is alive?

Api document as follow: link text

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-23 13:04:10 -0500

one gravatar image

updated 2023-01-23 13:47:56 -0500

Hey @blackbird Reading through the documentation link you provided, it seems rosnode.rosnode_ping can take max_count. So for example If you set max_count=5, the rosnode.rosnode_ping("/my_node_name", max_count=5) will exit after 5 pings and return True. If you don't mention any max_count, it will continue until stopped ctrl+c. You can also set verbose=True to see the ping time.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-06-11 17:54:34 -0500

Seen: 818 times

Last updated: Jan 23 '23