Loading the map using map_server

When you want to use the map built with your robot, it is necessary to load it with the map_server package. The following command will load the map:

    $ rosrun map_server map_server map.yaml
  

But to make it easy, create another .launch file in chapter5_tutorials/launch with the name gazebo_map_robot.launch, and put in the following code:

<?xml version="1.0"?> 
<launch> 
  <param name="/use_sim_time" value="true" /> 
  <!-- start up wg world --> 
  <include file="$(find 
gazebo_ros)/launch/willowgarage_world.launch"/> <arg name="model" /> <param name="robot_description" command="$(find xacro)/xacro.py
$(arg model)" /> <node name="joint_state_publisher" pkg="joint_state_publisher"
type="joint_state_publisher" ></node> <!-- start robot state publisher --> <node pkg="robot_state_publisher" type="robot_state_publisher"
name="robot_state_publisher" output="screen" > <param name="publish_frequency" type="double" value="50.0" /> </node> <node name="spawn_robot" pkg="gazebo_ros" type="spawn_model"
args="-urdf -param robot_description -z 0.1 -model robot_model"
respawn="false" output="screen" /> <node name="map_server" pkg="map_server" type="map_server"
args=" $(find chapter5_tutorials)/maps/map.yaml" /> <node name="rviz" pkg="rviz" type="rviz" args="-d $(find
chapter5_tutorials)/launch/mapping.rviz" /> </launch>

Now, launch the file using the following command and remember to put in the model of the robot that will be used:

    $ roslaunch chapter5_tutorials gazebo_map_robot.launch model:="'rospack find chapter5_tutorials'/urdf/robot1_base_04.xacro"
  

Then, you will see rviz with the robot and the map. The navigation stack, in order to know the localization of the robot, will use the map published by the map server and the laser readings. This will help it perform a scan matching algorithm that helps in estimating the robot's location using a particle filter implemented in the AMCL node.

We will see more about maps, as well as more useful tools, in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.239.140