- Mastering ROS for Robotics Programming(Second Edition)
- Lentin Joseph Jonathan Cacace
- 140字
- 2025-02-17 19:11:05
Launching the ROS controllers with Gazebo
If the controller configuration is ready, we can build a launch file that starts all the controllers along with the Gazebo simulation. Navigate to the seven_dof_arm_gazebo/launch directory and open the seven_dof_arm_gazebo_control.launch file:
<launch> <!-- Launch Gazebo --> <include file="$(find seven_dof_arm_gazebo)/launch/seven_dof_arm_world.launch" /> <!-- Load joint controller configurations from YAML file to parameter server --> <rosparam file="$(find seven_dof_arm_gazebo)/config/seven_dof_arm_gazebo_control.yaml" command="load"/> <!-- load the controllers --> <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" ns="/seven_dof_arm" args="joint_state_controller joint1_position_controller joint2_position_controller joint3_position_controller joint4_position_controller joint5_position_controller joint6_position_controller joint7_position_controller"/> <!-- convert joint states to TF transforms for rviz, etc --> <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen"> <remap from="/joint_states" to="/seven_dof_arm/joint_states" /> </node> </launch>
The launch files start the Gazebo simulation of the arm, load the controller configuration, load the joint state controller and joint position controllers, and, finally, run the robot state publisher, which publishes the joint states and TF.
Let's check the controller topics generated after running this launch file:
$ roslaunch seven_dof_arm_gazebo seven_dof_arm_gazebo_control.launch
If the command is successful, we can see these messages in the Terminal:

Figure 8: Terminal messages while loading the ROS controllers of seven-DOF arm
Here are the topics generated from the controllers when we run this launch file:

Figure 9: Position controller command topics generated by the ROS-controllers