gazebo_ros2_control icon indicating copy to clipboard operation
gazebo_ros2_control copied to clipboard

multiple gazebo_ros2_control different namespaces

Open muttistefano opened this issue 2 years ago • 2 comments

Hi everyone, i am using ROS2 galactic with the debian repository packages. I want to load multiple robots in multiple namespaces , each robot with its gazebo_ros2_control node. Currently I'm am running the robot_state_publisher and gazebo spawner for each roboti in this way , changing the namespace for each robot accordingly:

robot_state_publisher_node_2 = Node(
        package="robot_state_publisher",
        executable="robot_state_publisher",
        namespace="sweepee_1",
        output="log",
        parameters=[robot_description_2,frame_prefix_param_2],
    )

  spawn_sweepee_1 = Node(package='gazebo_ros', executable='spawn_entity.py',namespace="sweepee_1",
                          arguments=['-entity', 'sw1', "-topic", "robot_description",
                                     "-robot_namespace","sweepee_1",
                                     "-x"," 1"],
                          output='screen')

while the gazebo_ros2_control plugin is in the xacro this way:

    <gazebo reference="world">
    </gazebo>
    <gazebo>
      <plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
        <robot_param>robot_description</robot_param>
        <!-- <parameters>/home/kolmogorov/Documents/2ROS/lampo_ws_ros2/install/lampo_description/share/lampo_description/config/ur_controllers_1.yaml</parameters> -->
        <parameters>$(arg simulation_controllers)</parameters>
        <robot_param_node>robot_state_publisher</robot_param_node>
      </plugin>
    </gazebo>

When I run the code, it seems like the namespace is neglected, and everything is loaded under the namespace of the first loaded node, for instance, when i run it for 2 robots it gets:

/sweepee_1/front_laser_plugin
/sweepee_1/front_laser_plugin
/sweepee_1/gazebo_ros2_control
/sweepee_1/gazebo_ros2_control

Further plugin are also loaded under the wrong namespace. Am i doing something wrong? if someone points me a known problem i can actually collaborate. Thanks

muttistefano avatar May 18 '22 16:05 muttistefano

Have you tried to add additional tags for namespaces and remappings, like:

<gazebo>
   <plugin filename="libgazebo_ros2_control.so" name="gazebo_ros2_control">
     <ros>
       <namespace>/${name}</namespace>
       <remapping>/tf:=/${name}/tf</remapping>
     </ros>
     <parameters>$(find ${name})/config/${pcb_type}_controller.yaml</parameters>
   </plugin>
 </gazebo>

Atm I am also trying to spawn multiple entities (ROS Foxy) within Gazebo with ros2_control, gazebo_ros2_control plugin, etc.. To be fair, when I do, what I have suggested, the gazebo_ros2_control HW interfaces cannot be loaded:

[ros2_control_node-3] terminate called after throwing an instance of 'pluginlib::LibraryLoadException'
[ros2_control_node-3]   what():  According to the loaded plugin descriptions the class gazebo_ros2_control/GazeboSystem with base class type hardware_interface::SystemInterface does not exist. Declared types are  fake_components/GenericSystem test_hardware_components/TestSystemCommandModes test_hardware_components/TestTwoJointSystem test_system ur_robot_driver/URPositionHardwareInterface
[ERROR] [ros2_control_node-3]: process has died [pid 838663, exit code -6, cmd '/opt/ros/foxy/lib/controller_manager/ros2_control_node -namespace gbr007_0 --ros-args --params-file /tmp/launch_params_j6qt01dk --params-file /root/ros2_ws/install/modprof_models/share/modprof_models/config/gbr007_controller.yaml'].

MXS13 avatar Jun 10 '22 12:06 MXS13

I tried but it didn't work either.

muttistefano avatar Jun 21 '22 13:06 muttistefano

(Sorry used wrong account before) Hello! I've spent some time and figured this out. I'm sure others might have moved on to ignition but I'm set in my ways! The issue is related to attempting to set namespaces on nodes that are already set with namespaces. Lines 208 to 218 in gazebo_ros2_control_plugin.cpp appear to be the issue if you comment these out the namespacing and nodes work perfectly in multiple namespaces. I've tested this on my installation with Humble on 22.04 and it appears to fix the problem. Let me know if it works for you @muttistefano

Cheers, Ben

bobbleballs avatar Feb 24 '23 13:02 bobbleballs

Hi @bobbleballs, thanks for taking a look, you can consider opening a PR, then the maintainers can also take a look :)

tonynajjar avatar Feb 24 '23 13:02 tonynajjar

Thanks @tonynajjar I've set one up at #181 Cheers, Ben

bobbleballs avatar Feb 24 '23 13:02 bobbleballs

Thanks @bobbleballs . I guess i close the issue.

muttistefano avatar Feb 24 '23 21:02 muttistefano

Hi @nattasit63 Check out this PR. It has the fix. https://github.com/ros-controls/gazebo_ros2_control/pull/181

bobbleballs avatar Mar 17 '23 17:03 bobbleballs

Hi there, I think this patch is needed: I have created a toy problem here and I needed to apply that. If you take a look to that question, may be the example can be simplified, but what about adding something similar to the tests so we can permanently track namespace problems? If you think it is a good idea, please let me know. Thanks

mauriz avatar May 22 '23 13:05 mauriz

Hi @mauriz I'm a bit confused about what your problem is? What tests are you referring to?

bobbleballs avatar May 22 '23 13:05 bobbleballs

Hi, the first point is that to my understanding (also considering what I have cloned some days ago) this patch has not been merged yet, right? If not, it is needed as it fixes the namespace problem for the controller manager. The second point is whether this package should have among its functional tests one that handles multiple robots similar to the example I have linked: at the moment I did not manage to use the load_controller (but it works with the spawner) node for example and I can't figure out if it is my mistake or a bug into this package or it's dependencies.

mauriz avatar May 22 '23 19:05 mauriz

hello i meet same problem ,where i find ,cpp [Lines 208 to 218 in gazebo_ros2_control_plugin.cpp appear to be the issue] i will appreciate it if you can help me

richma11111111 avatar Jun 05 '24 10:06 richma11111111

hello i meet same problem ,where i find ,cpp [Lines 208 to 218 in gazebo_ros2_control_plugin.cpp appear to be the issue] i will appreciate it if you can help me

Sorry, I don't understand. This has nothing to do with the namespace question of this thread? Please open a new issue and describe your problem properly.

christophfroehlich avatar Jun 05 '24 11:06 christophfroehlich