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

fix multiple system unconfigured rise cleanup #1171

Closed
anscipione opened this issue Nov 20, 2023 · 1 comment · Fixed by #1279
Closed

fix multiple system unconfigured rise cleanup #1171

anscipione opened this issue Nov 20, 2023 · 1 comment · Fixed by #1279

Comments

@anscipione
Copy link
Contributor

Background

while developing a hobby robot, I created hardware that interfaces with a vesc. to be able to control 4 motors each separately via a serial connection I created an urdf that instantiates 4 of them with different parameters.

I realized that during startup I always encountered the warning message

  RCUTILS_LOG_WARN_NAMED(
           "resource_manager",
           "(hardware '%s'): '%s' command interface not in available list. "
           "This should not happen (hint: multiple cleanup calls).",
           hardware_name.c_str(), interface.c_str());

of the remove_all_hardware_interfaces_from_available_list method

analyzing the problem I found that the cause is due to the fact that when the first component is initialized but not the others, the following ResourceManager code occurs

  // TODO(destogl): discuss what should be default return value, e.g., "NOT_EXECUTED"
   return_type result = return_type::ERROR;
   if (
     impl_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE ||
     impl_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
   {
     result = impl_->read(time, period);
     if (result == return_type::ERROR)
     {
       error();
     }
   }

   return result;

where all components except one return return_type::ERROR because are not yet configured.

This trigger all interfaces to be removed , living the hardware in indeterminate state.

correcting in

// TODO(destogl): discuss what should be default return value, e.g., "NOT_EXECUTED"
   return_type result = return_type::ERROR;
   if (
     impl_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE ||
     impl_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
   {
     result = impl_->write(time, period);
     if (result == return_type::ERROR)
     {
       error();
     }
   } else if (
     impl_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED
   )
   {
     return return_type::OK;
   }
   return result;

suppress the removal of the interfaces until components are CONFIGURED.

if my analysis is correct I would have a pr with the reported correction.

On my hardware it seems to have resolved the instability.

@bmagyar
Copy link
Member

bmagyar commented Nov 21, 2023

Would you mind putting this on a pull request?

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