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_arm.urdf.xacro, into testing the robot base.
Now that we have the complete model of our robot arm, let's get it into action and see how our arm moves. Follow the steps:
- Create a launch file that would spawn the robot arm and its controllers. Now, go into the launch folder and create the following launch file:
$ cd ~/chapter3_ws/src/robot_description/launch
$ gedit arm_gazebo_control_xacro.launch
Now, copy the following code into it:
<?xml version="1.0"?>
<launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find robot_description)/urdf/robot_arm.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_arm" />
<rosparam command="load" file="$(find robot_description)/config/arm_control.yaml" />
<node name="arm_controller_spawner" pkg="controller_manager" type="controller_manager" args="spawn arm_controller" respawn="false" output="screen"/>
<rosparam command="load" file="$(find robot_description)/config/joint_state_controller.yaml" />
<node name="joint_state_controller_spawner" pkg="controller_manager" type="controller_manager" args="spawn joint_state_controller" respawn="false" output="screen"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen"/>
</launch>
- Now, you could visualize your robot by running the following command:
$ initros1
$ roslaunch robot_description arm_gazebo_control_xacro.launch
You could see the necessary ROS topics by opening another Terminal and running rostopic list:
$ initros1
$ rostopic list
- Try to move the arm using the following command:
$ rostopic pub /arm_controller/command trajectory_msgs/JointTrajectory '{joint_names: ["arm_base_joint", "shoulder_joint", "bottom_wrist_joint", "elbow_joint", "top_wrist_joint"], points: [{positions: [-0.1, 0.210116830848170721, 0.022747275919015486, 0.0024182584123728645, 0.00012406874824844039], time_from_start: [1.0,0.0]}]}'
You will learn how to move the arm without using publishing values in the upcoming chapters. We'll learn how to set up the mobile manipulator in the next section.