Skip to content

2. Control the arm, gripper and base of a robot

Hoang Giang Nguyen edited this page May 11, 2023 · 9 revisions

1. Control the arm and gripper using ros_control

To control the arm and gripper of a robot, standard controllers from ros_control can be used. The following section will outline the steps involved in configuring controllers for the arm and gripper of a robot.

1) Configure the controllers

  • Create a .yaml file in the config folder to define the controllers (e.g. config/default_controllers.yaml)
  • Specify the controller parameters, for e.g.
# This controller publishes the joint states
joint_state_controller:
  type: joint_state_controller/JointStateController
  publish_rate: 60

# This controller controls the arm with effort
joint_trajectory_controller:
  type: effort_controllers/JointTrajectoryController
  joints:
    - joint1
    - joint2
  gains:
    joint1: { p: 2000, i: 100, d: 50 }
    joint2: { p: 2000, i: 100, d: 50 }

# This controller controls the gripper with effort, assuming finger_joint_right is mimic of finger_joint_left
gripper_controller:
  type: effort_controllers/GripperActionController
  joint: finger_joint_left
  gains:
    finger_joint_left: { p: 2000, i: 100, d: 50 }

2) Create a launch file to launch the controllers (e.g. my_robot_control.launch)

  • Create a launch file, add the parameter and the node controller_manager as follows, note that my_robot_control should be replaced with the corresponding package
<!-- Load controller manager -->
<rosparam command="load" file="$(find my_robot)/config/default_controllers.yaml" />
<node name="controller_manager" pkg="controller_manager" type="controller_manager" respawn="false" output="screen" args="spawn 
	joint_state_controller 
	joint_trajectory_controller
	gripper_controller" />

3) Create a launch file to include the controllers and specify the robot_description (e.g. my_robot_display.launch)

  • Create a launch file, include the mujoco_sim.launch file with the correct parameters from Section 1.2
<launch>

    <arg name="namespace" default="my_robot" />

    <group ns="$(arg namespace)">
        <include file="$(find mujoco_sim)/launch/mujoco_sim.launch">
            <arg name="config" value="$(find my_robot)/config/my_robot.yaml" />
            <arg name="robot" value="$(find my_robot)/model/my_robot.xml" />
            <arg name="world" value="$(find my_robot)/model/world.xml" />
        </include>

        <param name="robot_description" command="$(find xacro)/xacro '$(find my_robot)/urdf/my_robot.urdf'" />

        <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />

        <include file="$(find my_robot)/launch/my_robot_control.launch" />
    </group>

</launch>
  • Launch the my_robot_display.launch file

2. Control the base using cmd_vel

The base of a mobile robot can be controlled by adding virtual odom joints and setting their velocity directly. The parameter add_odom_joints from the config file must be set to true. The topic cmd_vel will appear with the robot name as prefix and can be used to command velocity directly.

3. Some useful debug tools

The following example shows the full demonstration of a controlled mobile robot Tiago. To try it run the following command after cloning the repo:

roslaunch tiago_mujoco tiago_display_with_kitchen.launch

Click to play the video tiago_controllers