gazebo_ros2_control icon indicating copy to clipboard operation
gazebo_ros2_control copied to clipboard

Fix namespacing for multiple instances of gazebo_ros2_control plugin

Open bobbleballs opened this issue 2 years ago • 17 comments

Fixes the issue described in #127 It appears that when adding __ns tags to ros args on nodes that have already been namespaced, something odd happens. I'm not too sure what happens on the rclcpp node side of things but removing the additional namespace tags on the args seems to fix the issue for me at least. I'm running Humble on 22.04 so I've only tested against the humble branch. I also removed the additional RCL_ROS_ARGS_FLAG in the arguments because I don't think it was doing anything. Cheers Ben

bobbleballs avatar Feb 24 '23 13:02 bobbleballs

Hi @bobbleballs, usually PRs are opened targeting master and are afterwards backported to older branches

tonynajjar avatar Feb 24 '23 13:02 tonynajjar

Hi @tonynajjar sorry, I had some issues with rebasing. I think I've sorted it now!

bobbleballs avatar Feb 24 '23 13:02 bobbleballs

Hi @ahcorde, I haven't changed any of the ways that you would use Namespaces before with this plugin, but now it works with multiple instances of the same plugin/robot description. I've added to the README.md here Thanks!

bobbleballs avatar Feb 24 '23 17:02 bobbleballs

Hi there, I think this patch needs to be merged. If you look at the bottom of this thread , there is an example with multiple robots whose controllers had problems with the namespace.

mauriz avatar May 22 '23 22:05 mauriz

@ahcorde Could you please take another look at this? I was stuck on this issue for multiple days until i stumbled upon the previously mentioned thread. The patch in this MR fixed my problem with multi robot simulations in gazebo. It would be nice if this patch can be incorporated into the upcoming releases.

splatter96 avatar Nov 21 '23 13:11 splatter96

Hi All! Has the mentioned fork already been merged into the master branch? I'm having issue as well on creating multiple instances of the same robot in gazebo simulation. Thanks.

DoppiaEffe94 avatar Mar 04 '24 16:03 DoppiaEffe94

@mauriz @splatter96 @DoppiaEffe94 can you please add your review to this PR (In the "Files changed" tab in the upper right corner: "Review Changes"? Compile the plugin from source, and test it with different setups.

christophfroehlich avatar Mar 05 '24 08:03 christophfroehlich

Sorry that is a quick review, just minor comments. See if that is reasonable

Thanks for proof-reading. There is a little button in the code comment UI to include the code inside your comment, where you can propose your changes. This is then a one-click action to apply your changes for us, could you please change your comments above? Have you actually tested the new version, does it fix the mentioned problem?

christophfroehlich avatar Mar 06 '24 09:03 christophfroehlich

Ok sorry I am new to this review system. I will do that as well as code checking asap, no earlier than a couple of days though.. sorry

mauriz avatar Mar 06 '24 10:03 mauriz

Hi @christophfroehlich !

I had the time to test the compilation and running of this PR.

Somehow the provided fork from does not compile in my ROS2 Humble version. For sake of precision, I just forked the package from the "humble" branch and removed the mentioned lines, without touching the README.md for now.

With the above steps, now the package compiles without any issue and the namespacing problem seems to be solved, as you can see below:

Example for husky robot with namespace "husky_1": gazebo_ros2_control_husky_1

and "husky_2": gazebo_ros2_control_husky_2

You can see here my fork.

Do you want me to open a new PR for the merge request?

Thank you

DoppiaEffe94 avatar Mar 07 '24 22:03 DoppiaEffe94

Hi @christophfroehlich !

I had the time to test the compilation and running of this PR.

Somehow the provided fork from does not compile in my ROS2 Humble version. For sake of precision, I just forked the package from the "humble" branch and removed the mentioned lines, without touching the README.md for now.

Hi @DoppiaEffe94, Could you give details on why this branch doesn't compile? It's currently merging against master so that could be why. This will be fixed when we backport.

Unfortunately I've now moved on from the position that I was at that was allowing me to test this regularly. But it was working when I left! I don't currently have a ROS install or the time to check things.

If possible we should test against master or rolling, but I understand that can be difficult. Hopefully we can get this merged soon as it's a blocker for quite a few workflows!

bobbleballs avatar Mar 07 '24 22:03 bobbleballs

Do you want me to open a new PR for the merge request?

No you don't have to make a PR for humble. If it is merged to rolling we'll backport it to humble.

Ideally, someone can provide an example for gazebo_ros2_control_demos with two namespaced robots, where everyone can test this.

christophfroehlich avatar Mar 07 '24 22:03 christophfroehlich

Hi there @christophfroehlich. I am using Humble and Gazebo 11 and I am trying to get a gazebo_ros2_control example running using the Plankton-uuv_simulator repo found here. I can run all of the examples in the repo, but none of them use ROS2 control. Here is a snippet of my URDF

 <xacro:zray_base
      namespace="$(arg namespace)"
      inertial_reference_frame="$(arg inertial_reference_frame)">
      <gazebo>
        <plugin name="$(arg namespace)_uuv_plugin" filename="libuuv_underwater_object_ros_plugin.so">
          <fluid_density>1028.0</fluid_density>
          <namespace>namespace</namespace>
          <flow_velocity_topic>hydrodynamics/current_velocity</flow_velocity_topic>
          <debug>0</debug>
          <xacro:zray_hydro_model namespace="$(arg namespace)"/>
        </plugin>  
        <plugin name="gazebo_ros2_control" filename="libgazebo_ros2_control.so">
          <parameters>$(find zray_description)/config/controller_configuration.yaml</parameters>
            <robot_param>$(arg namespace)/robot_description</robot_param>
            <robot_param_node>$(arg namespace)/robot_state_publisher</robot_param_node>   
          <ros>
            <namespace>$(arg namespace)</namespace>
            <remapping>/tf:=tf</remapping>
            <remapping>/tf_static:=tf_static</remapping>
          </ros>             
        </plugin>
     </gazebo>
  </xacro:zray_base> 

After launching, if I check the node list I see /zray/robot_state_publisher, but I am getting the error

[gzserver-2] [ERROR] [1710189413.862622929] [zray.gazebo_ros2_control]: zray/robot_state_publisher service not available

Additionally, checking ros2 service list I see

/zray/robot_state_publisher/describe_parameters /zray/robot_state_publisher/get_parameter_types /zray/robot_state_publisher/get_parameters /zray/robot_state_publisher/list_parameters /zray/robot_state_publisher/set_parameters /zray/robot_state_publisher/set_parameters_atomically

machineIntelligence avatar Mar 11 '24 20:03 machineIntelligence

@machineIntelligence you haven't written if you have compiled the code from this PR or speaking of the released version? From your gzserver output, it seems that there is a leading / missing: zray/robot_state_publisher instead of /zray/robot_state_publisher.

christophfroehlich avatar Mar 12 '24 06:03 christophfroehlich

@DoppiaEffe94 how far did you get with it? could you provide a demo for gazebo_ros2_control_demos including two robot descriptions already provided with this package?

christophfroehlich avatar Jul 18 '24 06:07 christophfroehlich

Hello @christophfroehlich.

Sorry for the delay, I was really busy and with a lot of projects going on.

I will set a demo in the next days and get back to you.

DoppiaEffe94 avatar Jul 24 '24 07:07 DoppiaEffe94