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

hardware_interface - read/write are called before on_activate has finished #1891

Open
firesurfer opened this issue Nov 28, 2024 · 1 comment
Labels

Comments

@firesurfer
Copy link
Contributor

firesurfer commented Nov 28, 2024

Describe the bug

During our migration from Iron to Jazzy I ran into the issue of having random segfaults during startup in one of our hardware interfaces.

The cause of the issue seems to be that the read/write methods are called before the on_activate method has finished (It is actually random what is executed first). The segfault in our case was a pointer being accessed in the the read method that is initialized in the on_activate method

To Reproduce

Write a hardware interface, and simply check if read/write or on_activate is called first.

Expected behavior

on_activate should be called and should have finished before the read/write methods of a hardware interface are called.

Environment (please complete the following information):

  • OS: Ubuntu 24.04 - ROS2 installation in container
  • Version: Jazzy binary install, hardware_interface: 4.20.0

Preliminary solution

I added a std::atomic_bool active_ flag to my hardware interface which I set after on_activate has finished.

In the read/write methods I then check it and return early if nessary

    if (!active_)
        return hardware_interface::return_type::OK;
@christophfroehlich
Copy link
Contributor

I think it's not a bug, it's a feature.

AFAIK, the idea was that joint values are sent only in activated mode but all non-joint interfaces are read/written from configured on. But I think this distinction is not implemented yet and always sent.

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

No branches or pull requests

2 participants