0
$\begingroup$

I'm trying to do a multi agent simulation using leo_rover which is open source. I'm comfortable with single system, but when I add a second robot using namespaces i get the second robot spawned in the gazebo exactly where i want, but the controllers for the two agents try to get published at the same node location. In the end neither of the controller spawns and I'm left with rovers without controllers.

This is the rover.launch file.

<launch>
   <arg name="init_pose"/>
   <arg name="robot_name"/>
   <param name="robot_description" command="$(find xacro)/xacro $(find leo_description)/urdf/new.urdf.xacro" />

   <!-- push robot_description to factory and spawn robot in gazebo -->
   <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model"
    args="$(arg init_pose) -unpause -urdf -model $(arg robot_name) -param /robot_description" respawn="false" output="screen"/>

  <node pkg="robot_state_publisher" type="robot_state_publisher"  name="robot_state_publisher" ns="leo">
      <param name="publish_frequency" type="double" value="30.0" />
  </node>

  <include file="$(find leo_control)/launch/control.launch">
   <!-- TODO: add possible arguments for depth camera, etc.-->
  </include>

</launch>

This is the control.launch used in the rover.launch

<launch>


  <arg name="use_tf_static" default="false"/>
  <arg name="model" default="$(find leo_description)/urdf/new.urdf.xacro"/>

  <!-- Load controller configuration />-->
  <rosparam command="load" file="$(find leo_control)/config/control.yaml" />

  <node name="controller_spawner" pkg="controller_manager" type="spawner"
    respawn="false" args="leo_velocity_controller leo_joint_publisher" output="screen" ns="leo"/>

</launch>

Below launch file tries to add 2rovers into the simulation using namespaces.

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

  <!-- BEGIN ROBOT 1-->
  <group ns="rover1">
    <param name="tf_prefix" value="rover1_tf" />
    <include file="$(find btp)/launch/rover.launch" >
      <arg name="init_pose" value="-x 0 -y 0 -z 0" />
      <arg name="robot_name"  value="Robot1" />
    </include>
  </group>

  <!-- BEGIN ROBOT 2-->
  <group ns="rover2">
    <param name="tf_prefix" value="rover2_tf" />
    <include file="$(find btp)/launch/rover.launch" >
      <arg name="init_pose" value="-x -2 -y 0 -z 0" />
      <arg name="robot_name"  value="Robot2" />
    </include>
  </group>
</launch>

Below multisim.launch file combines all these launches.

<launch>
   <arg name="world_name" default="worlds/empty.world"/>

   <include file="$(find gazebo_ros)/launch/empty_world.launch">
     <arg name="world_name" value="$(arg world_name)"/> <!-- world_name is wrt GAZEBO_RESOURCE_PATH environment variable -->
     <arg name="paused" value="false"/>
     <arg name="use_sim_time" value="true"/>
     <arg name="gui" value="true"/>
     <arg name="headless" value="false"/>
     <arg name="debug" value="true"/>
     <arg name="verbose" value="true"/>
   </include>
   <!-- start gui -->
   <!-- <node name="gazebo_gui" pkg="gazebo" type="gui" respawn="false" output="screen"/> -->

   <!-- include our robots -->
   <include file="$(find btp)/launch/multi_rover.launch"/>
</launch>

Now the error why I launch this multisim.launch file.

[ERROR] [1611075925.200755903, 0.394000000]: Tried to advertise a service that is already advertised in this node [/leo/controller_manager/list_controllers]
[ERROR] [1611075925.200778314, 0.394000000]: Tried to advertise a service that is already advertised in this node [/leo/controller_manager/list_controller_types]
[ERROR] [1611075925.200811448, 0.394000000]: Tried to advertise a service that is already advertised in this node [/leo/controller_manager/load_controller]
[ERROR] [1611075925.200824730, 0.394000000]: Tried to advertise a service that is already advertised in this node [/leo/controller_manager/unload_controller]
[ERROR] [1611075925.200841861, 0.394000000]: Tried to advertise a service that is already advertised in this node [/leo/controller_manager/switch_controller]
[ERROR] [1611075925.200859178, 0.394000000]: Tried to advertise a service that is already advertised in this node [/leo/controller_manager/reload_controller_libraries
$\endgroup$
2
  • $\begingroup$ do you have a specific question? ... you did not ask anything $\endgroup$ – jsotola Jan 20 at 4:45
  • $\begingroup$ Sorry about that, I have resolved it. The problem was of namespace conflicts for controller_manager. $\endgroup$ – Sankeerth Reddy Prodduturi Jan 20 at 14:51
0
$\begingroup$

I have resolved the problem. It was about conflicting namespaces for the controller manager. I have removed the control.launch file and included the stuff in the rover.launch itself. then i had to include namespaces everywhere.

<launch>
  <arg name="init_pose"/>
  <arg name="robot_name"/>
  <param name="robot_description" command="$(find xacro)/xacro $(find leo_description)/urdf/new.urdf.xacro" />

  <!-- push robot_description to factory and spawn robot in gazebo -->
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" ns="/$(arg robot_name)"
        args="$(arg init_pose) -unpause -urdf -model $(arg robot_name) -param /robot_description " respawn="false" output="screen"/>
  <node pkg="robot_state_publisher" type="robot_state_publisher"  name="robot_state_publisher" ns="leo">
    <param name="publish_frequency" type="double" value="30.0" />
  </node> 
  <arg name="model" default="$(find leo_description)/urdf/new.urdf.xacro"/>

  <!-- Load controller configuration />-->
  <rosparam command="load" file="$(find leo_control)/config/control.yaml" ns="/$(arg robot_name)" />
  <node name="controller_spawner_$(arg robot_name)" pkg="controller_manager" type="spawner" ns="/$(arg robot_name)"
    respawn="false" args=" leo/leo_velocity_controller leo/leo_joint_publisher --namespace=/$(arg robot_name)" output="screen"/>   
</launch>

and i had also removed the namespace from the urdf/xacro file at the bottom with the help of this answer's first part.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.