Now that we have the complete model for our robot base, let's put it into action and see how our base moves. Follow these steps:
- Let's create a launch file that will spawn the robot and its controllers. Now, go into the launch folder and create the following launch file:
$ cd ~/chapter3_ws/src/robot_description/launch
$ gedit base_gazebo_control_xacro.launch
- Now, copy the following code into it and save the file:
<?xml version="1.0"?>
<launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find robot_description)/urdf/robot_base.urdf.xacro" />
<include file="$(find gazebo_ros)/launch/empty_world.launch"/>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model robot_base" />
<rosparam command="load" file="$(find robot_description)/config/control.yaml" />
<node name="base_controller_spawner" pkg="controller_manager" type="spawner" args="robot_base_joint_publisher robot_base_velocity_controller"/>
</launch>
- Now, you can visualize your robot by running the following command:
$ cd ~/chapter3_ws
$ source devel/setup.bash
$ roslaunch robot_description base_gazebo_control_xacro.launch
Once the Gazebo environment launches, you should see something like the following without any error prompt:
Successful Gazebo launch
- You can view the necessary ROS topics by opening another Terminal and running rostopic list:
$ initros1
$ rostopic list
The following screenshot shows the list of ROS topics:
List of ROS topics
The Gazebo view of the robot should be as follows:
Robot base in Gazebo
- Try using the rqt_robot_steering node and move the robot, as follows:
$ rosrun rqt_robot_steering rqt_robot_steering
In the window, mention our topic, /robot_base_controller/cmd_vel. Now, move the sliders slowly and see how the robot base moves around.
Have a look at the robot URDF file in this book's GitHub repository: https://github.com/PacktPublishing/ROS-Robotics-Projects-SecondEdition/blob/master/chapter_3_ws/src/robot_description/urdf/robot_base.urdf.xacro before testing the robot base.
We have completed our robot base. Now, let's learn how to build the robot arm.