-
Notifications
You must be signed in to change notification settings - Fork 37
Jaco example in Gazebo
Here is how to get started using the Jaco arm with Gazebo.
The package jaco_on_table provides an example set-up with the Kinova Jaco arm on a table which you may use for testing all the packages.
The following instructions just cover the basics in form of a tutorial. Please refer to the jaco_arm wiki page which references documentation to all packages involved.
You can bring up the robot without joint controllers first. This just spawns the robot into Gazebo, and the arm should collapse as it is not controlled:
roslaunch jaco_on_table jaco_on_table_gazebo.launch
Please also refer to the general wiki for jaco_arm for more options to launch gazebo and the arm without joint controllers, which can be useful for test purposes.
There are currently two options to control the joints of the example Kinova Jaco arm:
- Using the gazebo_joint_control controllers (see also package jaco_gazebo for more details).
- Using gazebo_ros_control hardware interfaces.
There are some limitations for using ros_control (option 2) at the moment, therefore this wiki page will focus on option 1. If you would like to learn more about the limited support of ros_control and would like to try it out, please refer to the wiki page about Jaco and ros_control.
You can use the following launch file to bring up the example jaco on a table (using option 1):
roslaunch jaco_on_table jaco_on_table_gazebo_controlled.launch
This will load up the jaco robot on the table in its home position. It should maintain the home position and not collapse.
The following is going to describe how to use different methods to control the joints. Please refer to the jaco_gazebo wiki page for details on how to adjust the control parameters (e.g. PID values) for all control methods described in the following.
Using joint_state_publisher
You can load up a joint_state_publisher GUI which you can use to control the individual joints if you specify the additional argument load_joint_state_publisher:
roslaunch jaco_on_table jaco_on_table_gazebo_controlled.launch load_joint_state_publisher:=true
Note that on melodic and higher this will require the joint_state_publisher_gui
installed, sudo apt install ros-<distro>-joint-state-publisher-gui
.
The robot will move from the "home" position into 0 angles position, because that is the default in joint_state_publisher. You can now use the GUI to change the angles.
Control with joint velocity
If you would like to control the jaco arm with joint velocity commands instead, you cannot use joint_state_publisher, because it sends sensor_msgs/JointState messages with positions, not velocities.
To control the arm with velocity commands (note: load_joint_state_publisher argument defaults to false):
roslaunch jaco_on_table jaco_on_table_gazebo_controlled.launch
The arm will load up in "home" position and should maintain it. The maintenance of the current pose is achieved by a mix of position and velocity controllers. See also the discussion here.
You can now send a sensor_msgs/JointState message to the topic /jaco/joint_control in which you specify the velocities of the joints. There is a simple example ROS node which does that for you:
rosrun jaco_gazebo test_set_joint_state_publisher_vel <joint-number> <velocity>
This will send a sensor_msgs/JointState message to set the velocity of joint-number i, i=[0..8], and hold this velocity for 5 seconds. Joint numbers for the Jaco arm are [0..5] for the arm joints and [6..8] for the finger joints.
For example, run
rosrun jaco_gazebo test_set_joint_state_publisher_vel 0 1
to make the arm rotate around its first joint a 1 rad/s.
Notes
-
With velocity controllers, it is important to specify a target position in the sensor_msgs/JointState message for all joints which are set to zero velocity, or for which no velocity value is specified at all. You can find an explanation for this on this wiki page. The example test program test_set_joint_state_publisher_vel used above does this for you.
-
A gazebo model plugin needs to be loaded which takes care of the joint control. Gazebo "model plugins" have to be loaded from within the URDF. This tutorial uses gzplugin_joint_control.urdf.xacro which is loaded by jaco_on_table_gazebo_controlled.launch.
Executing a joint trajectory
The package jaco_gazebo offers a ROS action server which provides joint trajectory execution of a control_msgs/FollowJointTrajectoryAction. It uses the implementation in packages gazebo_joint_control.
Lauch the robot as before:
roslaunch jaco_on_table jaco_on_table_gazebo_controlled.launch
You can now reach the action server on the topic /jaco/joint_trajectory_action/. You may either send your own JointTrajectory, or use RViz to generate one, as described in the jaco MoveIt! tutorial.
For more details about the trajectory execution, please also refer to the wiki page for jaco_gazebo.
You can test the grasping ability in a hand-crafted grasp scenario. Try the difference with and without the gazebo grasp plugin.
A cube is spawned at a fixed predefined position. Then, the arm moves to a pre-defined state to grasp the cube. There is no motion planner, so there will be no smooth trajectory execution, and it will only work for the exact cube pose used in this tutorial. This is only intended as a demonstration and test.
roslaunch jaco_on_table jaco_on_table_gazebo_controlled.launch load_grasp_fix:=true
(or set load_grasp_fix:=false
to not use the grasp plugin)
The arm will move to the pre-defined state in two steps: First, it will move in pre-grasp state, then it will move to to the grasp state, but without doing the grasp yet. The two steps are required because there is no real motion planning, and not using the pre-grasp state would make it sweep the cube off the table.
roslaunch jaco_on_table spawn_and_reach_cube.launch
Or do the spawning and moving separately:
rosrun gazebo_test_tools cube_spawner cube1 0.2 0 0.76 robot_base
rosrun jaco_on_table set_arm_to_cube
Now, you can grasp the cube. If you are using the Gazebo grasp plugin, a message that the cube has been attached should be printed in the terminal where you launched Gazebo.
rosrun jaco_on_table grasp_cube
Move the arm back to the home pose. It will lift the cube (at least when the grasp plugin is used):
rosrun jaco_on_table set_arm_to_cube --home --no-fingers
The last argument is required so the arm moves into the "Home" position but leaves the finger joints as they are now (to keep hold of the cube).
Now, you may release the cube again and observe how it falls down.
rosrun jaco_on_table grasp_cube --ungrasp
If you are using the Gazebo grasp plugin, a notice should be printed that the object was detached.
Learn how to execute a joint trajectory using MoveIt! with the RViz plugin in this tutorial.
There are also a more advanced grasping tutorial in grasp-execution-pkgs.
- Using ros_control with Jaco
- The jaco_arm wiki page for more details.