2. Control the arm, gripper and base of a robot - HoangGiang93/mujoco_sim GitHub Wiki
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.
- Create a
.yamlfile in theconfigfolder 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 }
- Create a
launchfile, add the parameter and the nodecontroller_manageras follows, note thatmy_robot_controlshould 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
launchfile, include themujoco_sim.launchfile 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.launchfile
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.
- rqt_robot_steering provides a GUI plugin for steering a robot using Twist messages.
- rqt_joint_trajectory_controller is the graphical frontend for interacting with joint_trajectory_controller instances.
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
