ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

Simulation of multiple Husky robots

asked 2016-02-02 16:12:50 -0600

nbeyers gravatar image

Hello all,

I'm relatively new to ROS and I'm working on simulation of multiple Clearpath Huskies running some simple obstacle avoidance code that I've written. I've installed and used the husky_gazebo package to successfully simulate a single robot with my code, but I'm running into difficulties when I try to add more. The way I'm hoping to accomplish this is through the use of namespaces, but I'm afraid I don't understand them very well. Here is the launch file where I'm attempting to do this:

<launch>

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

  <arg name="laser_enabled" default="true"/>
  <arg name="ur5_enabled" default="false"/>
  <arg name="kinect_enabled" default="false"/>

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(arg world_name)"/> 
    <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="false"/>
  </include>

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find husky_gazebo)/urdf/description.gazebo.xacro'
    laser_enabled:=$(arg laser_enabled)
    ur5_enabled:=$(arg ur5_enabled)
    kinect_enabled:=$(arg kinect_enabled)
    " />

  <group ns="husky1">
    <param name="tf_prefix" value="husky1_tf" /> 
    <include file="$(find husky_gazebo)/launch/spawn_husky.launch">
      <arg name="laser_enabled" value="$(arg laser_enabled)"/>
      <arg name="ur5_enabled" value="$(arg ur5_enabled)"/>
      <arg name="kinect_enabled" value="$(arg kinect_enabled)"/>
      <arg name="x" value="1.0"/>
      <arg name="y" value="-1.0"/>
    </include>
  </group>

  <group ns="husky2">
    <param name="tf_prefix" value="husky2_tf" /> 
    <include file="$(find husky_gazebo)/launch/spawn_husky.launch">
      <arg name="laser_enabled" value="$(arg laser_enabled)"/>
      <arg name="ur5_enabled" value="$(arg ur5_enabled)"/>
      <arg name="kinect_enabled" value="$(arg kinect_enabled)"/>
      <arg name="x" value="-3.0"/>
      <arg name="y" value="-1.0"/>
    </include>
  </group>

</launch>

This calls another launch file to actually spawn the vehicle:

<launch>



     <arg name="laser_enabled" default="true"/>
      <arg name="ur5_enabled" default="false"/>
      <arg name="kinect_enabled" default="false"/>

        <!-- Robot pose -->

  <arg name="x" default="0"/>
  <arg name="y" default="0"/>
  <arg name="z" default="0"/>
  <arg name="roll" default="0"/>
  <arg name="pitch" default="0"/>
  <arg name="yaw" default="0"/>

  <param name="robot_description" command="$(find xacro)/xacro.py '$(find mtu_husky_gazebo)/urdf/mtu_description.gazebo.xacro'
    laser_enabled:=$(arg laser_enabled)
    ur5_enabled:=$(arg ur5_enabled)
    kinect_enabled:=$(arg kinect_enabled)
    " />

  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />

  <!-- Load Husky control information -->
  <include file="$(find mtu_husky_control)/launch/control.launch"/>

  <!-- Include ros_control configuration for ur5, only used in simulation -->
  <group if="$(arg ur5_enabled)">

    <!-- Load UR5 controllers -->
    <rosparam command="load" file="$(find mtu_husky_control)/config/control_ur5.yaml" />
    <node name="arm_controller_spawner" pkg="controller_manager" type="spawner" args="arm_controller --shutdown-timeout 3"/>

    <!-- Fake Calibration -->
    <node pkg="rostopic" type="rostopic" name="fake_joint_calibration" args="pub calibrated std_msgs/Bool true" />

    <!-- Stow the arm -->
    <node pkg="husky_control" type="stow_ur5" name="stow_ur5"/>

  </group>

  <group if="$(arg kinect_enabled)">

    <!-- Include poincloud_to_laserscan if simulated Kinect is attached -->
    <node pkg="pointcloud_to_laserscan" type="pointcloud_to_laserscan_node" name="pointcloud_to_laserscan" output="screen">

        <remap from="cloud_in" to="camera/depth/points"/>
        <remap from="scan" to="camera/scan"/>
        <rosparam>
            target_frame: base_link # Leave empty to output scan in the pointcloud frame
            tolerance: 1.0
            min_height: 0.05
            max_height: 1.0

            angle_min: -0.52 # -30.0*M_PI/180.0
            angle_max: 0.52 ...
(more)
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2016-02-02 21:44:22 -0600

Each controller is running in a single namespace (see here), so you will need to adjust that. You will also need to configure the namespace for the imu and for the gps.

You need to also modify the -model parameter in spawn_husky_model or both robots will get an error.

here's a screenshot of the two huskies moving independently after applying the modifications

edit flag offensive delete link more

Comments

1

Thank you! This is just what I was looking for! But is there an easy way to pass the namespace from the parent launch file to all the children. What I mean is how could I set <robotnamespace> in the xacro files based on the namespaces set in the husky_empty_world launch file?

nbeyers gravatar image nbeyers  ( 2016-02-03 16:32:43 -0600 )edit
1

Yeah, that's the tricky part. You can pass arguments to a xacro file and use the arg to set the robotNamespace tag. The problem is that you can't pass an arg from a xacro file to an <xacro:include as stated here.

Gary Servin gravatar image Gary Servin  ( 2016-02-05 14:03:26 -0600 )edit
1

What I did was create two different husky.gazebo.xacro files and hard-code the robotNamespace for each robot there. And on the description.gazebo.xacro included each of those files depending on a namespace arg like: <xacro:include filename="/home/gary/$(arg namespace).gazebo.xacro"/>

Gary Servin gravatar image Gary Servin  ( 2016-02-05 14:07:07 -0600 )edit
1

This is how I've set mine up as well, so I can confirm that it works! Thanks again! Although a can see it might be cumbersome when working with a large number of robots...

nbeyers gravatar image nbeyers  ( 2016-02-08 21:06:27 -0600 )edit
1

Another question, since you've helped so much this far: do you use rviz or the odometry topic with your simulations? I'm not seeing anything published to "/husky1/odometry/filtered" and errors in the RobotModel like "No transform from [base_footprint] to [husky1_tf/base_link]"

nbeyers gravatar image nbeyers  ( 2016-02-08 21:11:24 -0600 )edit
1

I've narrowed down the problem. Rviz needed me to set the TF Prefix for the robot model, so that part is solved. However, it seems that the "Odom" frame is not being published since I started using namespaces. Any idea why that might be the case?

nbeyers gravatar image nbeyers  ( 2016-02-09 17:18:18 -0600 )edit
1

I have explored the odom transform issue slightly further, discovering that the husky_velocity_controller (diff_drive_controller) is hard-coded to transform from "odom" to (a parameterizable) base link. After editing the controller source to parameterize odom as well, I still cannot transform.

proboscisjoe gravatar image proboscisjoe  ( 2016-02-20 00:04:54 -0600 )edit
1

I was able to get it partially working. The solution involved also setting the FrameID parameter in the xacro file as described here. I now have 2 full trees, each with odom but no tf between them

nbeyers gravatar image nbeyers  ( 2016-02-24 12:39:14 -0600 )edit
0

answered 2016-02-10 13:31:09 -0600

Devin gravatar image

I think I have the same problem. Thanks for your advice,Gary. I notice RobotNamespace I try to start two gazebo_ros_control: <gazebo> <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> <robotnamespace>husky1</robotnamespace> </plugin> </gazebo> <gazebo> <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"> <robotnamespace>husky2</robotnamespace> </plugin> </gazebo> but I find that only husky2 controller manager start when I use the rosservice list What should I do?

edit flag offensive delete link more

Comments

This is in the "description.gazebo.xacro" file, correct? As Gary said above, you need 2 versions of this code. Mine are renamed as "description1.gazebo.xacro" and "description2.gazebo.xacro". Each will have a different namespace. The spawn husky launch file will then call one depending on namespace.

nbeyers gravatar image nbeyers  ( 2016-02-10 15:39:35 -0600 )edit

I think I have done what Gary told us. But it doesn't work. I can only control one husky robot. Please have a look at my problem

Devin gravatar image Devin  ( 2016-02-10 16:17:53 -0600 )edit

Oh, I know what you mean. it works now. thank you.

Devin gravatar image Devin  ( 2016-02-10 16:42:05 -0600 )edit
-1

answered 2018-04-27 08:31:52 -0600

topkek gravatar image

why am i always getting this error??

included file [/home/user/catkin_ws/src/husky_simulator/husky_gazebo/launch/spawn_husky.launch] requires the 'namespace' arg to be set The traceback for the exception was written to the log file

edit flag offensive delete link more

Comments

1

Please don't post this as an answer, as it's not an answer. Open a new question for this.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-27 11:29:20 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2016-02-02 16:12:50 -0600

Seen: 2,727 times

Last updated: Apr 27 '18