Creating a robot configuration

To launch the entire robot, we are going to create a launch file with all the necessary files to activate all the systems. Anyway, here you have a launch file for a real robot that you can use as a template. The following script is present in configuration_template.launch:

<launch> 
  <node pkg="sensor_node_pkg" type="sensor_node_type" 
name="sensor_node_name" output="screen"> <param name="sensor_param" value="param_value" /> </node> <node pkg="odom_node_pkg" type="odom_node_type" name="odom_node"
output="screen"> <param name="odom_param" value="param_value" /> </node> <node pkg="transform_configuration_pkg"
type="transform_configuration_type"
name="transform_configuration_name" output="screen"> <param name="transform_configuration_param"
value="param_value" /> </node> </launch>

This launch file will launch three nodes that will start up the robot.

The first one is the node responsible for activating the sensors, for example, the Laser Imaging, Detection, and Ranging (LIDAR) system. The sensor_param parameter can be used to configure the sensor's port, for example, if the sensor uses a USB connection. If your sensor needs more parameters, you need to duplicate the line and add the necessary parameters. Some robots have more than one sensor to help in the navigation. In this case, you can add more nodes or create a launch file for the sensors, and include it in this launch file. This could be a good option for easily managing all the nodes in the same file.

The second node is to start the odometry, the base control, and all the necessary files to move the base and calculate the robot's position. Remember that in Chapter 4, The Navigation Stack - Robot Setups, we looked at these nodes in some detail. As in the other section, you can use the parameters to configure something in the odometry, or replicate the line to add more nodes.

The third part is meant to launch the node responsible for publishing and calculating the geometry of the robot, and the transform between the arms, sensors, and so on.

The previous file is for your real robot, but for our example, the next launch file is all we need.

Create a new file in chapter6_tutorials/launch with the namechapter6_configuration_gazebo.launch, and add the following code:

<?xml version="1.0"?> 
<launch> 
  <param name="/use_sim_time" value="true" /> 
  <remap from="robot/laser/scan" to="/scan" /> 
  <!-- start up wg world --> 
  <include file="$(find 
gazebo_ros)/launch/willowgarage_world.launch"/> <arg name="model" default="$(find
robot1_description)/urdf/robot1_base_04.xacro"/> <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" /> <node name="spawn_robot" pkg="gazebo_ros" type="spawn_model"
args="-urdf -paramrobot_description -z 0.1 -model robot_model"
respawn="false" output="screen" /> <node name="rviz" pkg="rviz" type="rviz" args="-d $(find
chapter6_tutorials)/launch/navigation.rviz" /> </launch>

This launch file is the same that we used in the previous chapters, so it does not need any additional explanation.

Now to launch this file, use the following command:

    $ ros launch chapter6_tutorials chapter6_configuration_gazebo.launch
  

You will see the following window:

Notice that in the previous screenshot, there are some fields in red, blue, and yellow, without you having configured anything before. This is because in the launch file, a configuration file for the rviz layout is loaded along with rviz, and this file was configured in the previous chapter of this section.

In the upcoming sections, you will learn how to configure rviz to use it with the navigation stack and view all the topics.

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

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