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

Passing data to multiple instances of HardwareInterface from control node #1486

Open
tenfoldpaper opened this issue Apr 18, 2024 · 8 comments

Comments

@tenfoldpaper
Copy link

Hi, I've been working on a mujoco integration of the Panda robot arm into ros2-control.
So far, I've had some success simulating multiple robots, but only by creating the simulation loop inside the HardwareInterface class itself. While I can control and do things with it, when it comes to combining multiple hardware interfaces together (e.g. the robot arm mounted on a mobile base with its own HardwareInterface class), this structure would require me to write a monolothic HardwareInterface class that combines both of these together.

I've taken a look at the linked mujoco integration repo, and it appears that they are also doing something similar.

From what I can tell, in ros-control, we had a more fine-grained control over how to initialize the Interface classes, as it had a constructor and we could initialize the HardwareInterface-equivalent with an argument to simulate multiple components all sharing the same data source.

Is this a feature that is also available in ros2-control? If so, how do you do this? Apologies in advance for asking something that may be basic, but I could not find any relevant code bases that address this issue.

@christophfroehlich
Copy link
Contributor

Do you need to share data at run-time, or only at loading/initialization of the different components?

@destogl
Copy link
Member

destogl commented May 8, 2024

@tenfoldpaper maybe implementation of gz_ros2_control is interesting in this regard for you? Can you check it?

@tenfoldpaper
Copy link
Author

Do you need to share data at run-time, or only at loading/initialization of the different components?

Sorry for the late reply!
I need to share data at run-time. Generally, this should be possible by passing a reference to the mjData* and mjModel* pointers that get instantiated when loading up the scene using Mujoco. So far I've managed that successfully with member variable classes.

Since data is only accessed in the controller's read and write loops (and read and written in those parts), there shouldn't be major issues, as from what I can tell, the respective HardwareInterfaces' read and write functions are executed serially.

There is a mujoco-ros-control repo for ROS1 I found before that did the whole manual initialization thing, which made this possible. So far, I haven't been able to find a solution to this yet.

@tenfoldpaper
Copy link
Author

@tenfoldpaper maybe implementation of gz_ros2_control is interesting in this regard for you? Can you check it?

I'll take a look at it in a couple days and update my comment on this, but thank you for the suggestion!

@tenfoldpaper
Copy link
Author

So I went through gz_ros2_control, and it appears that the way it is handling ros2-control is not really transferable to MuJoCo.
It seems to work based on Gazebo's Plugin interface, which seems to create instances of ros2-control objects inside the simulation directly.

Since MuJoCo needs to be initialized and executed directly in ros2-control in the main control node, and there is no easy way to create a similar plugin-like interface for it, unfortunately it does not solve the problem.

@christophfroehlich , do you know any way to implement what I asked in the opening post?

@christophfroehlich
Copy link
Contributor

No I don't know a way to pass data between different hardware components. But maybe I don't understand your problem correctly: You will have to use different hardware components anyways, one (set) for your robot, and another one (set) for your simulation. For example, two hardware components for your real hardware (arm + base), but a single monolithic one for mujoco?

@saikishor
Copy link
Member

@tenfoldpaper Maybe what you are looking for is a System HardwareComponents, where multiple actuators can coexist and share information.

@christophfroehlich
Copy link
Contributor

@tenfoldpaper Maybe what you are looking for is a System HardwareComponents, where multiple actuators can coexist and share information.

as far as I understood he wants to share data between components which are not known altogether at compile time, but loaded dynamically.

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

No branches or pull requests

4 participants