micro-ROS / micro_ros_espidf_component

micro-ROS ESP32 IDF component and sample code
Apache License 2.0
229 stars 53 forks source link

Adding a timeout parameter to rclc_support_init() #221

Closed flabrosse closed 5 months ago

flabrosse commented 6 months ago

To avoid waiting for a fixed amount of time at the start of my code on the ESP32, waiting for the micro-ros agent to start on my Raspberry Pi, I use rclc_support_init() and rclc_support_fini() in a loop until the connection is established. At the same time I flash an LED to indicate we are trying to connect. However, rclc_support_init() takes a long time to timeout if the agent is not available, producing a very slow flashing LED.

Is it possible to set a timeout for rclc_support_init()?

pablogs9 commented 5 months ago

There is a recommended way of achieving your goals, is using ping functionality, please check rmw_uros_ping_agent at: https://docs.vulcanexus.org/en/latest/rst/tutorials/micro/handle_reconnections/handle_reconnections.html#state-machine-approach

flabrosse commented 5 months ago

I seem to remember this only works for the UDP transport (I think I read this in an issue here). But maybe this has changed. I'll have a look.

flabrosse commented 5 months ago

Just to confirm and close this issue. The pinging as linked above works even using the serial transport, and is a neat solution. Thank you!