gz_ros2_control icon indicating copy to clipboard operation
gz_ros2_control copied to clipboard

Loading parameters for multiple ign_ros2_control plugins

Open roni-kreinin opened this issue 2 years ago • 8 comments

I'm trying to run two different robots simultaneously in Fortress (ROS2 Humble) using ign_ros2_control. Each robot is namespaced and launches its own instance of the ign_ros2_control plugin, and both a Diff Drive controller and Joint State Broadcaster. Each robot has its own namespaced parameter file for the controllers. The nodes and topics are all being namespaced correctly, but the issue I am seeing is that when I spawn the second robot, the controller manager seems to be loading the parameter file of the first robot.

Each robot defines the plugin like so:

<gazebo>
  <plugin filename="libign_ros2_control-system.so" name="ign_ros2_control::IgnitionROS2ControlPlugin">
    <parameters>/path/to/robot/param.yaml</parameters>
    <ros>
            <remapping>~/odom:=platform/odom</remapping>
            <remapping>~/cmd_vel_unstamped:=platform/cmd_vel_unstamped</remapping>
            <remapping>/tf:=tf</remapping>
            <remapping>/tf_static:=tf_static</remapping>
            <remapping>/diagnostics:=diagnostics</remapping>
            <remapping>joint_states:=platform/joint_states</remapping>
            <namespace>robot_namespace</namespace>
    </ros>
  </plugin>
</gazebo>

The parameter file path and namespace is unique to each robot.

If I add the parameters of both robots to the parameter file of the first, then everything loads and runs well. Similarly, if I use the /** wildcard for the namespace in the parameter file, then both robots will load the first robots parameters.

Is there a workaround to this issue?

roni-kreinin avatar Jun 05 '23 22:06 roni-kreinin

This is exactly what I have noticed. Same ROS and gazebo version. Please fix it.

lklimkiewicz7 avatar Jun 27 '23 14:06 lklimkiewicz7

Have you found a workaround @roni-kreinin ?

lklimkiewicz7 avatar Jun 27 '23 14:06 lklimkiewicz7

@lklimkiewicz7 Either have all parameters in the file passed to the first robot, or us a wildcard if all robots use the same parameters.

roni-kreinin avatar Jun 27 '23 15:06 roni-kreinin

I have the same issue. Launch the script with gazebo sim and spawn two different robots. Each of the robot has its own controller manager with the corresponding namespace. I can see both controller managers get started. However, the second controller managers does not get its configurations from the file.

After the investigation of the code, I assume the problem is here https://github.com/ros-controls/gz_ros2_control/blob/889837d682c6cad9c6c481b1eb119dacb1aaa9a6/ign_ros2_control/src/ign_ros2_control_plugin.cpp#L326

Since one single gz plugin manages all controller manager, the rcl Context will be initialized once and with the arguments, that contain the parameter file from the first controller manager. Therefore, the solution would be to reinitialize Context or to update the parameter before the controller manager could be created.

Could it be fixed, since the workaround does not scale-up?

annaborn avatar Nov 30 '23 12:11 annaborn

I'm still facing this issue as mentionned by @roni-kreinin . Is there any progress on this ?

Mechaick avatar Jan 19 '24 13:01 Mechaick