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

Question about timeout parameter of rmw_uros_ping_agent function #1551

Closed
ChoiYouJung opened this issue Oct 13, 2023 · 4 comments
Closed

Question about timeout parameter of rmw_uros_ping_agent function #1551

ChoiYouJung opened this issue Oct 13, 2023 · 4 comments

Comments

@ChoiYouJung
Copy link

Issue template

  • Hardware description: Teensy4.1 or i.MX-RT1060 MCU
  • RTOS: No
  • Installation type: Arduino IDE or MCUXpressoIDE
  • Version or commit hash: humble

Steps to reproduce the issue

(1) Code Behavior Description

Q1 : While testing the program, it seems that when using the rmw_uros_ping_agent function, a delay occurs as much as the number in the first parameter, the timeout parameter. Is my understanding correct?

Q2 : When timeout is set to 100 in the rmw_uros_ping_agent function, when ping with the agent is successful faster than 100msec, what is the delay of 100msec? Or is it possible to escape the function faster than that?

  switch (state) {
    case WAITING_AGENT:
      EXECUTE_EVERY_N_MS(500, state = (RMW_RET_OK == rmw_uros_ping_agent(100, 1)) ? AGENT_AVAILABLE : WAITING_AGENT;);
      break;
    case AGENT_AVAILABLE:
      state = (true == create_entities()) ? AGENT_CONNECTED : WAITING_AGENT;
      if (state == WAITING_AGENT) {
        destroy_entities();
      };
      break;
    case AGENT_CONNECTED:
      EXECUTE_EVERY_N_MS(200, state = (RMW_RET_OK == rmw_uros_ping_agent(100, 1)) ? AGENT_CONNECTED : AGENT_DISCONNECTED;);
      if (state == AGENT_CONNECTED) {
        rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100));
      }
      break;
    case AGENT_DISCONNECTED:
      destroy_entities();
      state = WAITING_AGENT;
      break;
    default:
      break;
  }

Additional question: If the function set in the second question is implemented so as not to escape quickly, is there a way to reduce the delay?

Expected behavior

  • To operate the micro-ros_reconnection_example example code.

  • To understand the rmw_uros_ping_agent function in the micro-ros_reconnection_example example code and operate it to minimize delay.

Actual behavior

  • Running the micro-ros_reconnection_example example code

Additional information

@pablogs9
Copy link
Member

Q1 : While testing the program, it seems that when using the rmw_uros_ping_agent function, a delay occurs as much as the number in the first parameter, the timeout parameter. Is my understanding correct?

The first parameter is the maximum time that the ping can take. So for example if there is no agent found, this call will take take this number of milliseconds.

Q2 : When timeout is set to 100 in the rmw_uros_ping_agent function, when ping with the agent is successful faster than 100msec, what is the delay of 100msec? Or is it possible to escape the function faster than that?

Yes, the function will return as fast as the agent responds to the ping. The 100 ms is the maximum amount of time allowed for the ping operation.

Additional question: If the function set in the second question is implemented so as not to escape quickly, is there a way to reduce the delay?

Just reduce the timeout in order to provide a smaller time window to perform the ping operation.

@ChoiYouJung
Copy link
Author

ChoiYouJung commented Oct 17, 2023

thank you. Thanks, it was helpful.
I have an additional question.

(reconnection example : https://github.com/micro-ROS/micro_ros_arduino/blob/humble/examples/micro-ros_reconnection_example/micro-ros_reconnection_example.ino)

In the reconnection example, if EXECUTE_EVERY_N_MS(200, state = (RMW_RET_OK == rmw_uros_ping_agent(100, 1)) ? AGENT_CONNECTED : AGENT_DISCONNECTED;); is set in the EXECUTE_EVERY_N_MS function,
Total maximum waiting time is 200msec, right? Or is 100msec correct?

@pablogs9
Copy link
Member

Every 200 ms it will try to ping the agent for a maximum time of 100 ms.

@ChoiYouJung
Copy link
Author

oh! I misunderstood.

Thanks for your help.

Close the issue.

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