Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rmw_uros_ping_agent always adds 100 ms delay #306

Closed
mvanlobensels opened this issue Mar 27, 2024 · 6 comments
Closed

rmw_uros_ping_agent always adds 100 ms delay #306

mvanlobensels opened this issue Mar 27, 2024 · 6 comments

Comments

@mvanlobensels
Copy link

mvanlobensels commented Mar 27, 2024

Describe the bug
The rmw_uros_ping_agent function adds 100 ms of delay to the function's timeout_ms input argument when the Micro-ROS Agent is not found or not connected.

For example, when measuring the time it takes to evaluate rmw_uros_ping_agent(10, 1), the result is 110 ms.
Similarly, rmw_uros_ping_agent(100, 1) takes 200 ms.
rmw_uros_ping_agent(10, 2) results in 210 ms.

To Reproduce
I am using the micro-ros_reconnection_example to reconnect to the Agent in the case that a connection is lost, or when my microcontroller boots before the PC which runs the Micro-ROS Agent boots.

switch(agent_state)
{
    case WAITING_AGENT:
        time_start = uxr_millis();        
        agent_state = (RMW_RET_OK == rmw_uros_ping_agent(10, 1)) ? AGENT_AVAILABLE : WAITING_AGENT;
        time_end = uxr_millis() - time_start;
        break;
    case AGENT_AVAILABLE:
        ...
}

Expected behaviour
I expect the delay to be equal to timeout_ms. We are controlling electric motors with the microcontroller, so adding a 100 ms delay to our system makes our robot uncontrollable.

System information:

  • Microcontroller: Renesas RA6M5
  • OS: Pop OS 22.04
  • ROS 2 Humble
@pablogs9
Copy link
Member

pablogs9 commented Apr 1, 2024

Sorry but as far as we do not support Pop OS 22.04 for Renesas RA6M5 I'm not sure about the behaviour of your system. Could you confirm that it behaves the same with a supported configuration?

@mvanlobensels
Copy link
Author

Pop OS is the practically the same as Ubuntu, with drivers pre-installed and customized GNOME features. I find it hard to believe that that could be the issue.
https://support.system76.com/articles/difference-between-pop-ubuntu/

So this additional 100 ms is not something that is implemented by design?

@pablogs9
Copy link
Member

pablogs9 commented Apr 4, 2024

I thought that Pop OS was some sort of RTOS running in the RA6M5, sorry for the confusion.

Which transport are you using to communicate the micro-ROS Client with the micro-ROS Agent?

@mvanlobensels
Copy link
Author

mvanlobensels commented Apr 9, 2024

I am using Serial USB to communicate between the Agent and the microcontroller based on this example.

@pablogs9
Copy link
Member

pablogs9 commented Apr 9, 2024

Could you check if changing the timeout here: https://github.com/micro-ROS/micro_ros_renesas2estudio_component/blob/a99ccd815ebe6de4b53b02189cedd36bb1847c7d/extra_sources/microros_transports/usb_transport.c#L136 solves the issue?

Not sure right now if you can set it to

return handle_usb(USB_WRITE, (uint8_t *) buf, len, 0);

but maybe something less than WRITE_TIMEOUT (that is 100 ms).

@mvanlobensels
Copy link
Author

Thank you. This was indeed the cause of the 100 ms delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants