How to simulate multi-robots transportation in gazebo?
Hi all,
I can use px4-sitl to spawn a drone and control it in gazebo by sending command to specific rostopics.
https://dev.px4.io/en/simulation/multi-vehicle-simulation.html
Now,I want to simulate a group of quadcopters to transport a payload cooperatively.
I think I have to spawn the payload and drones in a xacro file and define joints between them.Is it correct?
If it's not, how do I modify the XACRO file?
Can someone give me an alternative method?
Thanks!!
Asked by pinxian on 2019-01-14 12:57:24 UTC
Answers
You can spawn multiple robot instances in gazebo by launching the xacro in different namespaces (and hopefully starting positions so they don't explode) as long as you don't hardcode any topics in the global namespace in your software. This would make it so a command to one would be sent to all. If you use a local namespace for all this should just work out of the box, although slow
Asked by stevemacenski on 2019-01-14 13:50:39 UTC
Comments
Hi , Thank you for your reply. I have tried to give each of robots namespace.For example /robot1 /robot2 .... However,I found that I cant define the joint and link after spawing robots. So I have to predefine the robots and their relationship in xacro file and then spawn the model. Is it right?
Asked by pinxian on 2019-01-14 21:40:39 UTC
I think my problem is very similar to this https://answers.ros.org/question/202683/multiple-robots-and-ros_control/ . Have you ever solved this kind of problem?
Asked by pinxian on 2019-01-14 21:50:19 UTC
Here is the code that worked for me, and as steve said on the comment above, you have to pay attention for hardcoded topics. For namespace:
<arg name="model" default="$(find your_package)/urdf/robot.urdf.xacro"/>
<!-- Launch gazebo -->
<include file="$(find your_package)/launch/gazebo.launch">
<arg name="model" value="$(arg model)"/>
</include>
<group ns="robot1">
<param name="tf_prefix" value="robot1_tf" />
<include file="$(find your_package)/launch/robot.launch" >
<arg name="init_pose" value="-x 0 -y 1 -z 0" />
<arg name="robot_name" value="robot1" />
</include>
<include file="$(find ira_laser_tools)/launch/laserscan_multi_merger.launch">
<arg name="robot_name" value="robot1"/>
</include>
</group>
then for robot.launch:
<launch>
<arg name="robot_name" default="your_default_value"/>
<arg name="init_pose" default="your_default_value"/>
<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model"
args="$(arg init_pose) -urdf -param /robot_description -model $(arg robot_name)"
respawn="false" output="screen" />
<node pkg="robot_state_publisher" type="robot_state_publisher"
name="robot_state_publisher" output="screen"/>
</launch>
Asked by Youssef_Lah on 2021-06-15 14:35:44 UTC
Comments
I'm facing the same issue, could you solve this problem?
Asked by Alireza_msb on 2021-06-15 11:32:17 UTC
@Alireza_msb this question is over 2 years old, you should create a new question and reference this one instead of commenting here. This will give your problem more visibility
Asked by jayess on 2021-06-15 14:38:05 UTC
@jayess Thanks, I made a new question here as you mentioned: https://answers.ros.org/question/380399/simulating-multi-robot-cooperative-transportation/
Asked by Alireza_msb on 2021-06-15 23:53:26 UTC