Ask Your Question
1

Tried to advertise a service that is already advertised in this node [/leo/controller_manager/list_controllers]

asked 2021-01-19 11:17:11 -0600

Sankeerth gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-20 08:49:56 -0600

Sankeerth gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2021-01-19 11:17:11 -0600

Seen: 328 times

Last updated: Jan 20