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

micro-ros agent only starts for the second time after uC manual reset

asked 2021-12-18 15:32:31 -0500

Jefecito gravatar image

Hello,

I am building a launcher for a Micro-ROS application running Zephyr RTOS on STM32. I stumbled upon a situation that happens when the agent is started by the second time after being interrupted by a ctrl+c or by a $ killall micro_ros_agent. It freezes in the logger setup line, just before the initialization of topics, publishers, subscribers, and services, like this:

$ ros2 run  micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0 
[1639862248.302385] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1639862248.302663] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4

It only resumes if the microcontroller reset button is pressed:

[1639862662.431163] info     | TermiosAgentLinux.cpp | fini                     | server stopped         | fd: 3
[1639862662.443154] info     | TermiosAgentLinux.cpp | init                     | Serial port not found. | device: /dev/ttyACM0, error 2, waiting for connection...
[1639862663.140021] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[1639862664.207718] info     | Root.cpp           | create_client            | create                 | client_key: 0x59B06063, session_id: 0x81
[1639862664.208181] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x59B06063, address: 0
[1639862664.254578] info     | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x59B06063, participant_id: 0x000(1)
[1639862664.257543] info     | ProxyClient.cpp    | create_replier           | replier created        | client_key: 0x59B06063, requester_id: 0x000(7), participant_id: 0x000(1)
[1639862664.260180] info     | ProxyClient.cpp    | create_replier           | replier created        | client_key: 0x59B06063, requester_id: 0x001(7), participant_id: 0x000(1)
[1639862664.262102] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x59B06063, topic_id: 0x000(2), participant_id: 0x000(1)
[1639862664.263761] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x59B06063, publisher_id: 0x000(3), participant_id: 0x000(1)
[1639862664.265743] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x59B06063, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[1639862664.271523] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x59B06063, topic_id: 0x001(2), participant_id: 0x000(1)
[1639862664.273199] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x59B06063, publisher_id: 0x001(3), participant_id: 0x000(1)
[1639862664.275206] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x59B06063, datawriter_id: 0x001(5), publisher_id: 0x001(3)
[1639862664.280842] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x59B06063, topic_id: 0x002(2), participant_id: 0x000(1)
[1639862664.286361] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x59B06063, publisher_id: 0x002(3), participant_id: 0x000(1)
[1639862664.288642] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x59B06063, datawriter_id: 0x002(5), publisher_id: 0x002(3)

The necessity of resetting the board every time I need to restart the agent is too inconvenient since the board is inside the robot. Is there a way to prevent it or a way to reset the microcontroller automatically after an agent interruption?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-12-20 00:52:14 -0500

Pablogs gravatar image

It depends on the app that you are coding on the micro-ROS side. Of course, if the micro-ROS client tries to connect to the agent and then (after some tries) it desists, the board needs to be reset in order to connect to the agent.

In any case, you can code your application to loop until an agent is found. Even you can ping the agent in order to check the availability and open and close the session accordingly.

Check the reconnection example here: https://github.com/micro-ROS/micro_ro...

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-12-18 15:32:31 -0500

Seen: 696 times

Last updated: Dec 20 '21