Robotics StackExchange | Archived questions

Controller and spawner not in the same namespace

Hi all,

I've been stuck with a simple problem that I am unable to solve. I want to simulate and controll several robots of the same type in my gazebo with ros kinetic. I can simulate one without problems, but when it is time to add the second, the namespaces are being a mess. I have a launch like that. I have followed this https://answers.ros.org/question/233413/controller-manager-problem-for-multiple-robots-in-simulation/ and also https://answers.ros.org/question/41433/multiple-robots-simulation-and-navigation/ but I am still unable to make it work. I am quite sure that is a namespace problem since my spawner does not find my controller. Unfortunately I have tried 100 different configurations and still does not work. If I do this:

multiple_robots.launch:

<launch>
<!-- No namespace here as we will share this description.
Access with slash at the beginning -->
<param name="robot_description"
command="$(find xacro)/xacro.py $(find robot_description)/urdf/pizza_robot.urdf.xacro" />

 <!-- BEGIN ROBOT 1-->
  <group ns="robot1">
     <param name="tf_prefix" value="robot1_tf" />
     <include file="$(find robot_description)/launch/one_robot.launch" >
     <arg name="init_pose" value="-x 1 -y 1 -z 0" />
     <arg name="robot_name"  value="robot1" />
     </include>
   </group>
   <rosparam command="load" file="$(find robot_description)/config/support.yaml"  ns="robot1_support_controller" />

   <node name="robot1_controller_spawner" pkg="controller_manager" type="spawner"
    args="robot1_joint_state_controller robot1_support_controller --shutdown-timeout 3"/>

 <!-- BEGIN ROBOT 2-->
 </launch>

Everything works and I have a controller called robot1supportcontroller in the /controllermanager namespace a node called /robot1controller_spawner, and services

/controller_manager/list_controller_types
/controller_manager/list_controllers
/controller_manager/load_controller
/controller_manager/reload_controller_libraries
/controller_manager/switch_controller
/controller_manager/unload_controller
/robot1_controller_spawner/get_loggers
/robot1_controller_spawner/set_logger_level

But then when I try to move this into the namespace I am unable to make it work multiple_robots.launch:

<launch>
  <!-- No namespace here as we will share this description. Access with slash at the beginning -->
  <param name="robot_description"
    command="$(find xacro)/xacro.py $(find robot_description)/urdf/pizza_robot.urdf.xacro" />

  <!-- BEGIN ROBOT 1-->
  <group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
    <include file="$(find robot_description)/launch/one_robot.launch" >
          <arg name="init_pose" value="-x 1 -y 1 -z 0" />
          <arg name="robot_name"  value="Robot1" />
    </include>
    <rosparam command="load" file="$(find robot_description)/config/support.yaml"  ns="robot1_support_controller" />
    <node name="robot1_controller_spawner" pkg="controller_manager" type="spawner"
          args="robot1_joint_state_controller --shutdown-timeout 3"/>
  </group>

  <!-- BEGIN ROBOT 2-->
</launch>

In this case I have a node called

/robot1/robot1_controller_spawner

Only the controller manager appears as a service

/controller_manager/list_controller_types
/controller_manager/list_controllers
/controller_manager/load_controller
/controller_manager/reload_controller_libraries
/controller_manager/switch_controller
/controller_manager/unload_controller

and I have no controller and the controller manager is only looking to the /controller_manager namespace

I have also tried to specify the namespace in the call

<node name="robot1_controller_spawner" pkg="controller_manager" type="spawner" ns="/robot1"
  args="robot1_joint_state_controller robot1_support_controller --shutdown-timeout 3"/>

resulting in no controller found and these services

/controller_manager/list_controller_types
/controller_manager/list_controllers
/controller_manager/load_controller
/controller_manager/reload_controller_libraries
/controller_manager/switch_controller
/controller_manager/unload_controller
/robot1/robot1_controller_spawner/get_loggers
/robot1/robot1_controller_spawner/set_logger_level

and also

<node name="robot1_controller_spawner" pkg="controller_manager" type="spawner" ns="/robot1"
  args="--namespace=/robot1 robot1_joint_state_controller --shutdown-timeout 3"/>

with the same result

my yaml is quite simple:

type: "joint_state_controller/JointStateController"
publish_rate: 50+

What am I doing wrong?

Asked by Bernat Gaston on 2020-09-18 08:54:28 UTC

Comments

@Mermy, Your robot_description cannot be share you should launch a robot_description in two different namespaces to be loaded properly.

Asked by Weasfas on 2020-09-19 06:19:25 UTC

Answers