gazebo_ros2_control: different namespace

asked 2023-05-22 08:37:26 -0500

maurizio gravatar image

Hi, I am running ros2 humble and I have detected some problems when spawning multiple entities of the same type. I have created a toy problem, to avoid ambiguities with duplication names. In particular I want to control two robots, each being just a revolute joint controlled in velocity. The robots are "pinocchio", associated to /r1/r1_controller (and yes, there is a double r1, just to make sure there is no ambiguity/problem with the namespace: I have patched the code so instead of having a hard-coded "controller_manager" I have the namespace + "controller_manager", but please neglect that it doesn't change the result) and "geppetto", associated to /r2/r2_controller. See the attached picture.C:\fakepath\markers.png. Notice that in order to have two different controller managers I had to apply what suggested in here (which to my understanding it is not yet merged ). So all in all, after launching the following launch script all the nodes are in place (robot state publisher, controller manager, and the entity - robot - to be controlled). At that point I manually trigger the controllers (one for each robot) instantiation:

ros2 control load_controller --set-state  -c "/r2/r2controller_manager" geppetto

[gzserver-1] [INFO] [1684332993.826170124] [r2.r2controller_manager]: Loading controller 'geppetto'
[gzserver-1] [ERROR] [1684332993.901249319] [r2.geppetto]: 'joints' parameter was empty
[gzserver-1] [INFO] [1684332993.845766414] [r2.r2controller_manager]: Setting use_sim_time=True for geppetto to match controller manager (see ros2_control#325 for details)
[gzserver-1] [INFO] [1684332993.901068783] [r2.r2controller_manager]: Configuring controller 'geppetto'
[gzserver-1] [ERROR] [1684332993.901249319] [r2.geppetto]: 'joints' parameter was empty
[gzserver-1] [WARN] [1684332993.901323149] []: Error occurred while doing error handling.
[gzserver-1] [ERROR] [1684332993.901347966] [r2.r2controller_manager]: After configuring, controller 'geppetto' is in state 'unconfigured' , expected inactive.

This is confirmed by dumpling the parameter for geppetto:

ros2 param dump /r2/geppetto
/r2/geppetto:
  ros__parameters:
    interface_name: velocity
    joints: []
    qos_overrides:
      /clock:
        subscription:
          depth: 1
          durability: volatile
          history: keep_last
          reliability: best_effort
    update_rate: 0
    use_sim_time: true

while instead for the other robot we have:

ros2 param dump /r1/pinocchio
/r1/pinocchio:
  ros__parameters:
    command_interfaces:
    - velocity
    interface_name: velocity
    joints:
    - r1rollingBar_to_Tablet
    qos_overrides:
      /clock:
        subscription:
          depth: 1
          durability: volatile
          history: keep_last
          reliability: best_effort
    state_interfaces:
    - position
    - velocity
    update_rate: 0
    use_sim_time: true

Notice that I can control only one (but not always the same, I guess the parameters of one somehow override the ones of the second, see below for details on why I use the term "override") robot(i.e. joint). At the same time if I spawn only a robot, removing either ga1 or ga2 from the following file, I can control either of them without any issue.

This is the launch file I use:

import os

from ament_index_python.packages import get_package_share_directory


from launch import LaunchDescription
from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler
from launch.event_handlers import OnProcessExit
from launch.launch_description_sources import PythonLaunchDescriptionSource

from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument, ExecuteProcess
from launch.substitutions import EnvironmentVariable, LaunchConfiguration, PathJoinSubstitution
import xacro
from launch.actions import GroupAction
from launch_ros.actions import PushRosNamespace



def generate_launch_description():


    gazebo = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']),
             )
    gzserver ...
(more)
edit retag flag offensive close merge delete