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

multiple gazebo_ros2_control different namespaces #127

Closed
muttistefano opened this issue May 18, 2022 · 13 comments
Closed

multiple gazebo_ros2_control different namespaces #127

muttistefano opened this issue May 18, 2022 · 13 comments

Comments

@muttistefano
Copy link

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

@MXS13
Copy link

MXS13 commented Jun 10, 2022

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'].

@muttistefano
Copy link
Author

I tried but it didn't work either.

@bobbleballs
Copy link
Contributor

(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

@tonynajjar
Copy link
Contributor

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

bobbleballs pushed a commit to bobbleballs/gazebo_ros2_control that referenced this issue Feb 24, 2023
…ce issue described in ros-controls#127

Also remove superfluous ROS_ARGS_FLAG
@bobbleballs
Copy link
Contributor

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

bobbleballs pushed a commit to bobbleballs/gazebo_ros2_control that referenced this issue Feb 24, 2023
…ce issue described in ros-controls#127

Also remove superfluous ROS_ARGS_FLAG
@muttistefano
Copy link
Author

Thanks @bobbleballs .
I guess i close the issue.

@bobbleballs
Copy link
Contributor

Hi @nattasit63
Check out this PR. It has the fix.
#181

bobbleballs pushed a commit to bobbleballs/gazebo_ros2_control that referenced this issue Apr 5, 2023
…ce issue described in ros-controls#127

Also remove superfluous ROS_ARGS_FLAG
@mauriz
Copy link

mauriz commented May 22, 2023

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

@bobbleballs
Copy link
Contributor

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

@mauriz
Copy link

mauriz commented May 22, 2023

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.

hshah12 added a commit to jlg-autonomy-team/gazebo_ros2_control that referenced this issue Feb 7, 2024
@richma11111111
Copy link

richma11111111 commented Jun 5, 2024

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

@christophfroehlich
Copy link
Contributor

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.

jasonke1025 added a commit to fitfabsw/gazebo_ros2_control that referenced this issue Jul 11, 2024
@gyuray-dev
Copy link

gyuray-dev commented Aug 6, 2024

For those who are waiting for PR#181 to be merged, I have changed my URDF (xacro) as follows and successfully spawned multiple controller managers in different namespaces using the gazebo_ros2_control plugin:

        <gazebo>
            <plugin name="${namespace}gazebo_ros2_control" filename="libgazebo_ros2_control.so">
                ...
                <robot_param_node>/${namespace}/robot_state_publisher</robot_param_node>
                <ros>
                    <namespace>${namespace}</namespace>
                </ros>
            </plugin>
        </gazebo>

Please note that this is just a workaround, and the second gazebo_ros2_control plugin is started in the same namespace as the first one, but each controller_manager has its correct namespace. But do not spawn multiple robot in gazebo simultaneously in this way because the plugins would be crash.

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

No branches or pull requests

8 participants