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

microros reconect whitout a blocking delay FROM destroy_entities() #1396

Open
Publicano opened this issue May 26, 2023 · 0 comments
Open

microros reconect whitout a blocking delay FROM destroy_entities() #1396

Publicano opened this issue May 26, 2023 · 0 comments
Assignees

Comments

@Publicano
Copy link

Publicano commented May 26, 2023

Hardware en software

  • Teensy 4.1
  • v2.0.5-humble Microros in docker

Problem description

i am trying to create a connection between the teensy and the microros agent without adding a blocking delay in my code.
For this, I used the micro-ros_reconnection_example code. This one only has a delay due to the rmw_uros_ping_agent() function.

Expected behavior

i would expect the rmw_uros_ping_agent function to cause the set delay as explained here

rmw_ret_t rmw_uros_ping_agent(
    **const int timeout_ms**,
    const uint8_t attempts
)

Actual behavior

when the ping_agent function is called for the first time after startup in the WAITING_AGENT there is a blocking delay of about 3 sec. the second time it is the set delay.

Additional information

It is very similar to #506, only there the problem is solved and I am using the latest version of microros.

main piece of code from the example

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(10, 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;
  }
@Acuadros95 Acuadros95 self-assigned this May 29, 2023
@Publicano Publicano changed the title microros reconect whitout a blocking delay microros reconect whitout a blocking delay FROM destroy_entities() Apr 19, 2024
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