Joint Damping and Friction
Every revolute, prismatic and spherical joint can have viscous damping and Coulomb friction. They model bearings, seals, gears and ball-and-socket joints. They are passive: they only remove energy, they are not part of the generalized force you set, and they act whether or not the joint is controlled.
Set them with the standard URDF <dynamics> attributes. Both default to zero:
<joint name="knee" type="revolute">
<parent link="thigh"/>
<child link="shank"/>
<axis xyz="0 1 0"/>
<dynamics damping="0.5" friction="2.0"/>
</joint>| Joint type | damping | friction |
|---|---|---|
| revolute | ||
| prismatic | ||
| spherical |
The MJCF loader reads the joint damping attribute but not frictionloss.
Both are measured at the joint, i.e., after any gear. If the joint is driven by an actuator, the actuator's output_damping and output_friction add to them (see Actuators).
Damping
Damping is the torque
For example, a free joint with inertia
and converges to the velocity
To read the current joint damping, call getJointDamping(). It returns a const raisim::VecDyn reference in generalized velocity order, with getDOF() entries. These are the values loaded from the model or last supplied to setJointDamping(); actuator output damping and PD gains are separate. Copy getJointDamping().e() into an Eigen::VectorXd to preserve a baseline before adding temporary damping, such as wheel braking.
To change the damping at runtime, call setJointDamping() with one coefficient per degree of freedom (getDOF() entries). The new values act from the next step. Leave the six entries of a floating base at zero: they are not joints, and their damping would not be integrated implicitly.
The URDF effort limit bounds only the commanded torque (PD plus feedforward). The damping torque is passive and is never clipped. Actuator torques (see Actuators) are not bounded by the effort limit either: they are limited by the operating regions of their motors and are added after the effort clamp.
Friction
Friction is Coulomb friction with stiction. It opposes the motion with the constant torque
Once the other torques exceed
RaiSim solves friction as a joint impulse bounded by
Spherical joints
A spherical joint takes the same <dynamics> attributes:
<joint name="shoulder" type="spherical">
<parent link="torso"/>
<child link="upper_arm"/>
<dynamics damping="0.2" friction="1.5"/>
</joint>The friction of a spherical joint (a ball-and-socket joint) acts on its three entries of the generalized velocity,
The friction torque is opposite to the joint's angular velocity at the end of the step, whatever the inertia of the bodies, so it removes as much energy as the bound allows. Some consequences:
- It is isotropic. A torque of
is held in every direction, and a torque of turns the joint in every direction. The friction does not depend on the joint frame. Three revolute joints in a row (a gimbal), each with friction , behave differently. They hold up to about a diagonal, and their components stop at different times, which turns the axis of a rotation as it slows down. - A spin slows down about a fixed axis. A body with isotropic inertia
spinning about any axis slows down along that axis at the constant rate and stops. - A swing stops off the vertical. A pendulum of mass
whose center of mass is a distance from the joint comes to rest wherever gravity's torque, at the tilt , is at most . The resting points form a cone around the vertical, as the figure shows. With only viscous damping, it would keep creeping toward the bottom. - A planar swing stays planar. A pendulum on a spherical joint whose mass is symmetric about its plane of swing, under loads in that plane, moves exactly like a revolute joint with the same friction about the plane's normal. (Without that symmetry, the body's own dynamics can turn it out of the plane, which a revolute joint would prevent.)

A spherical pendulum (
Like the friction of a revolute or prismatic joint, it is solved together with the contacts, the joint limits and the other joints' friction. A contact pushing a link therefore cannot slip a joint unless the total torque on the joint exceeds
Accuracy
The friction of each joint is exact for the motion of the other joints and the contacts. When several joints with friction are strongly coupled, e.g., a long chain of spherical joints that mostly stick, the joints settle together over the contact solver's iterations. With the default solver settings the friction torque never exceeds World::setContactSolverParam()), the friction converges to that tolerance.
Setting the friction
The joint's own friction is set in the model file; there is no C++ setter for it. The output_friction of an actuator can be changed at runtime by editing the definitions from getActuators() and passing them to setActuators().