Closed ncnynl closed 1 year ago
Hello, Galactic is not a supported version of micro-ROS, could you confirm that this is replicable in humble or iron?
Currently we do not have a humble environment for testing. Maybe we will also build a humble environment later.
Could you share the micro-ROS Agent log with the flag -v6
?
docker run -it --net=host -v /dev:/dev --privileged microros/micro-ros-agent:galactic serial --dev /dev/ailibot -v6
[1695030014.669471] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1695030014.669762] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6
Only these contents, when I disconnect and reconnect
My debug infomation show like :
[17:44:04:766] APP State is AGENT_CONNECTED Continue!␍␊
[17:44:04:780] APP State is AGENT_CONNECTED!␍␊
[17:44:04:782] APP State is AGENT_CONNECTED Continue!␍␊
[17:44:04:795] APP State is AGENT_CONNECTED!␍␊
[17:44:04:798] APP State is AGENT_CONNECTED Continue!␍␊
[17:44:04:811] APP State is AGENT_CONNECTED!␍␊
[17:44:04:815] APP State is AGENT_CONNECTED Continue!␍␊
[17:44:04:827] APP State is AGENT_CONNECTED!␍␊
[17:44:04:830] APP State is AGENT_CONNECTED Continue!␍␊
[17:44:04:843] APP State is AGENT_CONNECTED!␍␊
this is a normal information , if i disconnected , it will be :
[17:45:42:614] APP State is WAITING_AGENT!␍␊
[17:45:42:882] APP State is WAITING_AGENT!␍␊
[17:45:42:885] APP State is WAITING_AGENT!␍␊
[17:45:42:893] APP State is WAITING_AGENT!␍␊
[17:45:42:893] APP State is WAITING_AGENT!␍␊
[17:45:42:901] APP State is WAITING_AGENT!␍␊
[17:45:42:901] APP State is WAITING_AGENT!␍␊
[17:45:42:901] APP State is WAITING_AGENT!␍␊
[17:45:42:914] APP State is WAITING_AGENT!␍␊
[17:45:42:914] APP State is WAITING_AGENT!␍␊
[17:45:42:914] APP State is WAITING_AGENT!␍␊
[17:45:42:914] APP State is WAITING_AGENT!␍␊
Does it work if you use rclc_support_init
instead of rclc_support_init_with_options
?
Yes, reconnect is correct if I use rclc_support_init
https://github.com/micro-ROS/micro_ros_arduino/blob/iron/examples/micro-ros_reconnection_example/micro-ros_reconnection_example.ino The reference is this reconnection code
I would recommend using a newer version of micro-ROS in order to ensure that this is not a old resolved issue
Okay, I will set up a humble environment to test it.
@pablogs9 I tested the code with init_options on humble today and found that this problem still exists, but this one can reconnect one more time than the galactic version. I replugged the USB, then the micro-ros-agent connected, disconnected, reconnected, disconnected again, and then couldn't connect again. The feedback is the same as galactic's problem.
@pablogs9 On Galactic, there is no limit on reconnection without init_options . It is normal for me to disconnect and reconnect more than 5 or 6 times. Judging from the content printed by debug on the code, the code on the MCU is running normally, but the agent cannot obtain it normally. Unable to reconnect, all that appear are stuck in the connected state:
docker run -it --net=host -v /dev:/dev --privileged microros/micro-ros-agent:humble serial --dev /dev/ailibot -v6
[1695030014.669471] info | TermiosAgentLinux.cpp | init | running... | fd: 3
[1695030014.669762] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6
@pablogs9 Is there a more complete example of adding init_options? I'd like to see if I'm missing any steps or code snippets.
@pablogs9 I may have found the answer to the problem. Without the rcl_init_options_fini(&init_options); line of code, after adding this, the current behavior on humble is normal. Can successfully reconnect multiple times in a row
Are you setting RMW_UXRCE_ENTITY_CREATION_DESTROY_TIMEOUT
to 0 and UCLIENT_MAX_SESSION_CONNECTION_ATTEMPTS
to a low value as stated here:
I didn't set these two values. I don't know where I can set them :( After I added rcl_init_options_fini, it became normal. The galactic and humble codes are all normal.
So can we close as solved?
Issue template
Steps to reproduce the issue
this is good code , not init_option
this is bad code with init_options . it will cause can't reconnect again .
Expected behavior
When I disconnect the micro-ros-agent, it can automatically connect when I use the micro-ros-agent again.
Actual behavior
Good code can achieve reconnection, but bad code cannot reconnect. However, for the actual data output by dubug, the development board is connected to the agent, but cannot output data.