ROS Controllers for Manipulator
There are two ROS controllers commonly used to control manipulators:
effort_controllers/JointPositionController
This is commonly used to control individual joints of a manipulator. The configuration YAML file of the controller, let’s call it my_controller.yaml, looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
MYROBOT: # Publish all joint states ----------------------------------- joint_state_controller: type: joint_state_controller/JointStateController publish_rate: 50 # Position Controllers --------------------------------------- joint1_position_controller: type: effort_controllers/JointPositionController joint: joint1 pid: {p: 100.0, i: 0.01, d: 10.0} joint2_position_controller: type: effort_controllers/JointPositionController joint: joint2 pid: {p: 100.0, i: 0.01, d: 10.0} |
A launch file to launch the controller looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<launch> <!-- Load joint controller configurations from YAML file to parameter server --> <rosparam file="$(find MY_PACKAGE)/config/my_controller.yaml" command="load"/> <!-- load the controllers --> <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" ns="/rrbot" args="joint_state_controller joint1_position_controller joint2_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="/MYROBOT/joint_states" /> </node> </launch> |
To command a joint position from the terminal, the following CLI commands are used:
1 2 |
rostopic pub -1 /MYROBOT/joint1_position_controller/command std_msgs/Float64 "data: 1.5" rostopic pub -1 /MYROBOT/joint2_position_controller/command std_msgs/Float64 "data: 1.0" |
position_controllers/JointTrajectoryController
When multiple joints of a manipulator is to be controlled simultaneously to follow a trajectory (waypoints), ROS joint trajectory controller can be conveniently used. When the joint trajectory controller uses position controller, the configuration YAML file looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 |
MYROBOT: # Publish all joint states ----------------------------------- joint_state_controller: type: joint_state_controller/JointStateController publish_rate: 50 # Trajectory Controller --------------------------------------- arm_joint_trajectory_controller: type: position_controllers/JointTrajectoryController joints: - joint1 - joint2 |
The joint trajectory controller actually can be either position controller, velocity controller, or effort controller. How to the configuration YAML file of the controller looks like depends on the controller type used (either position controller, velocity controller, or effort controller). This can be seen here: http://wiki.ros.org/joint_trajectory_controller
The launch file to launch the joint trajectory above looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<launch> <!-- Load joint controller configurations from YAML file to parameter server --> <rosparam file="$(find MY_PACKAGE)/config/my_controller.yaml" command="load"/> <!-- load the controllers --> <node name="trajectory_controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" ns="/MY_ROBOT" args="arm_joint_trajectory_controller"/> <node name="joint_state_controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" ns="/MY_ROBOT" args="joint_state_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="/MY_ROBOT/joint_states" /> </node> </launch> |
The trajectory waypoints of the joints, defined as control_msgs::FollowJointTrajectoryGoal, are defined in a node such as the following:
- https://gitioc.upc.edu/rostutorials/actions_tutorial/-/blob/master/src/pantilt_follow_traj.cpp
- https://github.com/pal-robotics/tiago_tutorials/blob/kinetic-devel/tiago_trajectory_controller/src/run_traj_control.cpp
Furthermore, since this uses action, the following nodes are needed:
- action server node
- action client node
The following is an example for a pan-tilt manipulator: https://gitioc.upc.edu/rostutorials/actions_tutorial/-/tree/master/src
The joint trajectory controller can also be commanded by using topic namely “/my_controller/command”.