上QQ阅读APP看书,第一时间看更新
Viewing the seven DOF arm in RViz
After talking about the robot model, we can view the designed xacro file in RViz and control each joint using the joint state publisher node and publish the robot state using Robot State Publisher.
The preceding task can be performed using a launch file called view_arm.launch, which is inside the launch folder of this package:
<launch> <arg name="model" /> <!-- Parsing xacro and loading robot_description parameter --> <param name="robot_description" command="$(find xacro)/xacro --inorder $(find mastering_ros_robot_description_pkg)/urdf/ seven_dof_arm.xacro " /> <!-- Setting gui parameter to true for display joint slider, for getting joint control --> <param name="use_gui" value="true"/> <!-- Starting Joint state publisher node which will publish the joint values --> <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" /> <!-- Starting robot state publish which will publish current robot joint states using tf --> <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" /> <!-- Launch visualization in rviz --> <node name="rviz" pkg="rviz" type="rviz" args="-d $(find mastering_ros_robot_description_pkg)/urdf.rviz" required="true" /> </launch>
Create the following launch file inside the launch folder, and build the package using the catkin_make command. Launch the urdf using the following command:
$ roslaunch mastering_ros_robot_description_pkg view_arm.launch
The robot will be displayed on RViz, with the joint state publisher GUI:
Figure 10: Seven DOF arm in RViz with joint_state_publisher
We can interact with the joint slider and move the joints of the robot. Next, we will talk about what joint state publisher can do.