Tutorials/drcsim/2.6/set joint damping


 * 1) DRC Tutorial: Changing Atlas and Sandia Hand Joint Viscous Damping Coefficients Over ROS Service #

This tutorial will explain how to change Atlas robot and Sandia hand joint viscous damping coefficients.

'''ROS services allowing users to change Atlas robot and Sandia hand model's joint damping coefficients are added in drcsim 2.6.x candidate and after. Available via nightly deb builds:'''

sudo apt-get remove --purge osrf-common* sudo apt-get update sudo apt-get install -y drcsim-nightly


 * 1) Background

In this tutorial, we'll demonstrate how to call ROS services in command-line using [rosservice](http://www.ros.org/wiki/rosservice).

You can use `rosservice list` to look for existing services:

$ rosservice list | grep damping /atlas/get_joint_damping /atlas/set_joint_damping /sandia_hands/get_joint_damping /sandia_hands/set_joint_damping

Each service is described in detail below:

* ROS service: `/atlas/get_joint_damping` * message type: [atlas_msgs/srv/GetJointDamping](https://bitbucket.org/osrf/drcsim/src/844cd73465a0eff9dd0c51aa8b9723d4ac9a7eab/ros/atlas_msgs/srv/GetJointDamping.srv?at=default) * ROS service: `/atlas/set_joint_damping` * message type: [atlas_msgs/srv/SetJointDamping](https://bitbucket.org/osrf/drcsim/src/844cd73465a0eff9dd0c51aa8b9723d4ac9a7eab/ros/atlas_msgs/srv/SetJointDamping.srv?at=default) * ROS service: `/atlas/get_joint_damping` * message type: [atlas_msgs/srv/GetJointDamping](https://bitbucket.org/osrf/drcsim/src/844cd73465a0eff9dd0c51aa8b9723d4ac9a7eab/ros/atlas_msgs/srv/GetJointDamping.srv?at=default) * ROS service: `/sandia_hands/set_joint_damping` * message type: [atlas_msgs/srv/SetJointDamping](https://bitbucket.org/osrf/drcsim/src/844cd73465a0eff9dd0c51aa8b9723d4ac9a7eab/ros/atlas_msgs/srv/SetJointDamping.srv?at=default)
 * To get Atlas robot model's current joint damping coefficients,
 * To set Atlas robot model's joint damping coefficients,
 * To get Sandia hand model's current joint damping coefficients,
 * To set Sandia hand model's joint damping coefficients,

To run this tutorial, you'll need at least 2 separate terminals. Don't forget to execute following setup commands in each new terminal you open.
 * 1) Running the Tutorial

$ . /usr/share/drcsim/setup.sh

Start simulation of Atlas robot with Sandia hands:

$ roslaunch atlas_utils atlas_sandia_hands.launch

You should see an Atlas robot standing in an empty world:



In a separate terminal, change the Sandia hands model joint damping coefficients by typing:

$ . /usr/share/drcsim/setup.sh $ rosservice call /sandia_hands/set_joint_damping "damping_coefficients: [30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 5.0, 30.0, 30.0]" success: True status_message: ''

Here, each element of the `damping_coefficients` array corresponds to a joint as listed in [SandiaHandPlugin.cc line 68 ~ 91](https://bitbucket.org/osrf/drcsim/src/844cd73465a0/ros/atlas_msgs/SandiaHandPlugin.cpp?at=default#cl-68). So for example, above `rosservice` call will set all joint damping values to `30 N*m*sec/rad` with the exception of `right_f3_j0`, with damping coefficient of `5.0 N*m*sec/rad`.

Similarly for the Atlas robot model:

$ . /usr/share/drcsim/setup.sh $ rosservice call /atlas/set_joint_damping "damping_coefficients: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.1]" success: True status_message: ''

Here, the array of `damping_coefficients` should have exactly 28 elements, with each element corresponds to one joint as listed in [atlas_msgs/AtlasState.msg](https://bitbucket.org/osrf/drcsim/src/844cd73465a0/ros/atlas_msgs/msg/AtlasState.msg?at=default#cl-14). In this example, all joint will have damping coefficient of `0.1 N*m*sec/rad`, with the exception of `r_arm_uwy` with damping coefficient of `0.2 N*m*sec/rad`.