micro-ROS / micro_ros_arduino

micro-ROS library for Arduino
Apache License 2.0
442 stars 114 forks source link

micro-ros agent initializes and creates nodes, topics only after unplugging and plugging back the USB everytime #1812

Closed srujan-xairo closed 2 months ago

srujan-xairo commented 2 months ago

Issue template

Actual behavior

when I run the command ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0

I get the below output

[1722173514.344108] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1722173514.345154] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4

and does nothing. After I unplug the USB and Plug it back I get the below output and all my nodes are active. Which is the expected behavior, but why do I need to unplug and plug the USB every time? How can I solve this?

[1722173654.738771] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1722173656.288891] info     | Root.cpp           | create_client            | create                 | client_key: 0x0DA77874, session_id: 0x81
[1722173656.289134] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x0DA77874, address: 0
[1722173656.328959] info     | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x0DA77874, participant_id: 0x000(1)
[1722173656.331903] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x0DA77874, topic_id: 0x000(2), participant_id: 0x000(1)
[1722173656.333897] info     | ProxyClient.cpp    | create_subscriber        | subscriber created     | client_key: 0x0DA77874, subscriber_id: 0x000(4), participant_id: 0x000(1)
[1722173656.336467] info     | ProxyClient.cpp    | create_datareader        | datareader created     | client_key: 0x0DA77874, datareader_id: 0x000(6), subscriber_id: 0x000(4)
[1722173656.339489] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x0DA77874, topic_id: 0x001(2), participant_id: 0x000(1)
[1722173656.341205] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x0DA77874, publisher_id: 0x000(3), participant_id: 0x000(1)
[1722173656.344010] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x0DA77874, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[1722173656.346707] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x0DA77874, topic_id: 0x002(2), participant_id: 0x000(1)
[1722173656.348612] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x0DA77874, publisher_id: 0x001(3), participant_id: 0x000(1)
[1722173656.351384] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x0DA77874, datawriter_id: 0x001(5), publisher_id: 0x001(3)
[1722173656.353954] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x0DA77874, topic_id: 0x003(2), participant_id: 0x000(1)
[1722173656.355947] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x0DA77874, publisher_id: 0x002(3), participant_id: 0x000(1)
[1722173656.358593] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x0DA77874, datawriter_id: 0x002(5), publisher_id: 0x002(3)
[1722173656.361138] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x0DA77874, topic_id: 0x004(2), participant_id: 0x000(1)
[1722173656.363170] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x0DA77874, publisher_id: 0x003(3), participant_id: 0x000(1)
[1722173656.365905] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x0DA77874, datawriter_id: 0x003(5), publisher_id: 0x003(3)
hippo5329 commented 2 months ago

You will need to add re-connection support.

https://github.com/micro-ROS/micro_ros_arduino/blob/jazzy/examples/micro-ros_reconnection_example/micro-ros_reconnection_example.ino

Use of Humble is not recommended for new designs. You should move to current LTS stable release Jazzy and Ubuntu 24.04.

hippo5329 commented 2 months ago

You may check my wiki. https://github.com/hippo5329/micro_ros_arduino_examples_platformio/wiki

hippo5329 commented 2 months ago

You should check if /dev/ttyACM0 exists. "ls /dev/ttyA*" .

The arduino examplea without re-connection will timeout and enter error_loop(), if it failed to connect the agent.

srujan-xairo commented 2 months ago

This solved my issue. Thanks.