Spawning multiple copys of an urdf model at Gazebo and Rviz
I spawn 9 copies of a urdf model in a gazebo simulation and its working fine. I cant figure out how i can spawn the robots in Rviz, all of them or just one at a time .I can spawn the urdf model however it doesnt correspond to any of the robots in the simulation. Below are the rvis launch file and the spawn.launch. Every robot has its own cmdvel and odom topics. Also when i choose a Fixed frame at rviz i have as an option the linkchassis which is the the fixed frame from the urdf and the robot1/linkchassis robot2/linkchassis etc. When i choose these it just shows me the position of that robot with a line. I think i have to remap something but i dont know what. Thank you in advance.
rviz.launch:
<?xml version="1.0"?>
<launch>
<param name="robot_description" command="cat '$(find swarm)/urdf/robot.urdf.xacro'"/>
<!-- send fake joint values -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
</node>
<!-- Combine joint values -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>
<!-- Show in Rviz -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find swarm)/" />
</launch>
spawn.launch:
<?xml version="1.0"?>
<launch>
<arg name="initial_pose_x" default="0.0"/>
<arg name="initial_pose_y" default="0.0"/>
<arg name="initial_pose_a" default="1.0"/>
<arg name="robot_name" default="robot_1"/>
<!-- ******************** Robot Model ******************** -->
<group ns="$(arg robot_name)"> <!-- namespace for spawning multiple models -->
<!-- loads the robot_description and starts robot_state_publisher node -->
<param name="robot_description" command="$(find xacro)/xacro '$(find swarm)/urdf/robot.urdf.xacro' robot_name:=$(arg robot_name) " />
<param name="tf_prefix" type="string" value="-file $(find swarm)/urdf/robot.urdf.xacro"/>
<node pkg="swarm" name="get_position" type="get_position.py" output="screen" args="$(arg robot_name) ">
</node>
</group>
<!-- Spawn a robot into Gazebo -->
<node name="$(arg robot_name)_spawn" pkg="gazebo_ros" type="spawn_model" args="-file $(find swarm)/urdf/robot.urdf.xacro -x $(arg initial_pose_x) -y $(arg initial_pose_y) -z $(arg initial_pose_a) -unpause -urdf -model $(arg robot_name)"/>
</launch>
Asked by Nick_JR on 2020-08-05 16:31:51 UTC
Comments