Visualize turtlebots in RViz

I have a world in Gazebo where I spawn three turtlebots, but I don't know how to visualize all of them in RViz using the same fixed frame. The codes I have for the .launch files are the following:

main.launch:

<launch>
    <param name="/use_sim_time" value="true" />
    
        <!-- start world -->
        <node name="gazebo" pkg="gazebo_ros" type="gazebo" args="$(find practica3)/worlds/world/world.world" respawn="false" output="screen" />

        <!-- include our robots -->
        <include file="$(find practica3)/launch/3robots_sim.launch"/>

        <!-- Launch del RViz -->
        <!--<node name="rviz" pkg="rviz" type="rviz"/>-->
</launch>

3robots_sim.launch:

<launch>
    <param name="robot_description" command="$(find xacro)/xacro.py $(find turtlebot_description)/robots/kobuki_hexagons_asus_xtion_pro.urdf.xacro" />
        
        <!-- BEGIN ROBOT 1  -->
        <group ns="robot1">
            <param name="tf_prefix" value="robot1_tf" />
            <include file="$(find practica3)/launch/one_robot.launch" >
                <arg name="init_pose" value="-x -1 -y -3 -z 0 -R 0 -P 0 -Y 1" />
                <arg name="robot_name" value="robot1" />
            </include>
        </group>


        <!-- BEGIN ROBOT 2 -->
        <group ns="robot2">
            <param name="tf_prefix" value="robot2_tf" />
            <include file="$(find practica3)/launch/one_robot.launch" >
                <arg name="init_pose" value="-x -3.5 -y -3 -z 0 -R 0 -P 0 -Y 1" />
                <arg name="robot_name" value="robot2" />
            </include>
        </group>


        <!-- BEGIN ROBOT 3 -->
        <group ns="robot3">
            <param name="tf_prefix" value="robot3_tf" />
            <include file="$(find practica3)/launch/one_robot.launch" >
                <arg name="init_pose" value="-x -4 -y 2 -z 0 -R 0 -P 0 -Y 1" />
                <arg name="robot_name" value="robot3" />
            </include>
        </group>

</launch>

one_robot.launch:

<launch>
    <arg name="robot_name"/>
    <arg name="init_pose"/>

    <node name="spawn_minibot_model" pkg="gazebo_ros" type="spawn_model"
    args="$(arg init_pose) -urdf -param /robot_description -model $(arg robot_name)"
    respawn="false" output="screen" />

    <node pkg="nodelet" type="nodelet" name="laserscan_nodelet_manager" args="manager"/>

    <node pkg="nodelet" type="nodelet" name="depthimage_to_laserscan"
    args="load depthimage_to_laserscan/DepthImageToLaserScanNodelet laserscan_nodelet_manager">
        <param name="scan_height" value="10"/>
        <param name="output_frame_id" value="/camera_depth_frame"/>
        <param name="range_min" value="0.45"/>
        <remap from="image" to="$(arg robot_name)/camera/depth/image_raw"/>
    </node>

    <remap from="scan" to="$(arg robot_name)/scan"/>

    <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen" >
        <param name="publish_frecuency" type="double" value="30.0"/>
        <param name="tf_prefix" type="string" value="$(arg robot_name)"/>
        <!--remap from="/joint_states" to="/$(arg robot_name)/joint_states" /-->
    </node>

</launch>

With visualizing their reference systems moving in RViz would be enough.

Upvotes: 0

Views: 58

Answers (0)

Related Questions