Rayrai Example: Spherical Joint Friction

Overview
Coulomb friction of spherical joints (Joint Damping and Friction). Three spherical pendulums (
| Bob | <dynamics friction> | Friction cone | What happens |
|---|---|---|---|
| blue | none | – | swings on |
| orange | spirals down slowly and stops | ||
| red | spirals down quickly and stops |
The friction torque is the same in every direction and opposes the bob's rotation, so the swing loses energy at every turn instead of stopping one direction first. A bob can stop wherever gravity's torque,
Run
./build-examples/examples/rayrai_spherical_joint_frictionCMake target: rayrai_spherical_joint_friction. Source: examples/src/rayrai/dynamics/rayrai_spherical_joint_friction.cpp. On Windows, run rayrai_spherical_joint_friction.exe instead.
API pattern
The friction is the standard URDF attribute of the spherical joint:
<joint name="ball" type="spherical">
<parent link="socket"/>
<child link="bob"/>
<dynamics friction="0.6"/>
</joint>The joint's generalized velocity is the bob's angular velocity in its own frame. A joint held by friction keeps only round-off of it:
auto* pendulum = world->addArticulatedSystem(urdf);
pendulum->setState(gc, gv); // gc: quaternion w, x, y, z; gv: angular velocity
world->integrate();
const bool atRest = pendulum->getGeneralizedVelocity().e().norm() < 1e-9;