micro-ROS / micro-ROS-Agent

ROS 2 package using Micro XRCE-DDS Agent.
Apache License 2.0
101 stars 58 forks source link

Guarnatee sucessful communication from main device running the agent #121

Closed Johannap1 closed 2 years ago

Johannap1 commented 2 years ago

Hello,

I am currently working on implementing micro-ros on an ESP32dev board and ROS2 foxy running on my laptop. For now, I am starting the agent from a separate terminal and then subscribing to the published topics on a node implemnted with rospy. Currently, I am checking a connection of the agent only visually by the output in the terminal. However, ideally I would like to know if the agent was successfully setup from my rospy node and make sure that it discovered the MCU, to guarantee that the communication is running from the main device and not only on the MCU side (for that I was looking at the reconnection example). This would be similar to a handshake functionality at startup in a serial communication setting. It should furthermore open the possibility to detect from my rospy node if connection to the device was lost during runtime. I also thought that in the end it should be possible to just check that messages are coming in or implementing a service upon startup, but that would already require a successful communication setup and no possibility to automatically reconnect from the main device side if the communication is not working for some reason. Could you please help me out and tell me if I am simply missing something here or if this functionality is not available yet. Also, if this has not been implemented yet I would appreciate some hints where to look at to solve this issue.

Thanks

pablogs9 commented 2 years ago

Hello @Johannap1,

In the micro-ROS client-side you can implement application logic for checking if the agent is available using the ping functionality. You have the example code in the reconnection example.

On your ROS 2 application side, the only way to check if micro-ROS node is correctly enabled is by checking the ROS 2 graph, for example, using get_node_names() in order to check if your micro-ROS node is alive.

Johannap1 commented 2 years ago

Hello @pablogs9,

thank you for your quick answer. Indeed my question concerns more the ROS 2 application side. I tried your suggestion using the get_node_names(). This should work to check whether the agent is running on startup to see whether the node is there, but what I discovered is that when connection is lost to the microcontroller (either unplugging it or killing the agent), the node remains for up to half a minute before it cannot be detected by ROS anymore. So this would not be a solution to detecting if connection is lost. Do you see the same behavior with your system?

pablogs9 commented 2 years ago

Hello @Johannap1,

On the ROS 2 side you have two situations:

If you want to check the liveliness of your MCU system, my recommendation would be to send a topic in a certain rate and check this rate at the ROS 2 side. For this deadline QoS can be handy, check this

pablogs9 commented 2 years ago

Any update on this?

pablogs9 commented 2 years ago

Some comments here: https://discourse.ros.org/t/our-conclusions-on-trying-to-implement-micro-ros-in-our-robot/24690/2?u=pablogs

pablogs9 commented 2 years ago

Closing due to inactivity