A Chrono body can be constrained in its relative motion with respect to a different body or ground. This is achieved by using ChLink classes.
From the chrono::ChLink class various sets of links are derived. The most noticeable are those derived from:

  • chrono::ChLinkMate : more efficient, however they do not implement limits and only few of them can have an imposed motion;
  • chrono::ChLinkLock : more general, the relative motion can be limited within boundaries, forces and relative displacements can easily be retrieved; it is possible to specify a constraint over points that are moving respect to the body reference frame;
  • chrono::ChLinkMotor : ChLinkMate derived joints with included actuation.

Thus, some of the ChLinkMate and ChLinkLock derived classes may overlap. The latter being more flexible, the first more efficient. Because of this, the ChLinkMate version should be preferred, in general.

Some general information are fundamental to effectively use these classes:

  • links often refer to a pair chrono::ChMarker, but such markers can be automatically added to bodies during link initialization; see below;
  • each link has a reference/master frame; reaction forces and axis direction are computed with respect to this reference marker;
  • it's worth to set the initial position of the markers/bodies to a feasible position;
  • it's generally useful to set the solver parameters to finer values when constraints are present; see Solvers;

ChLink Quick Reference

ConDOF Task Description Class
6 Fix Fix position and rotation chrono::ChLinkMateFix
6|3 Bushing Linear compliance + optional spherical joint chrono::ChLinkBushing
5 Revolute Allows rotation along Z axis chrono::ChLinkLockRevolute
5 Prismatic Allows translation along Z axis chrono::ChLinkLockPrismatic
4 Universal Universal joint (along X and Y axes) chrono::ChLinkUniversal
4 Revolute+Prismatic Allow translation along X axis and rotation along Z axis chrono::ChLinkLockRevolutePrismatic
4 Oldham Oldham joint; does not fix axes position chrono::ChLinkLockOldham
4 Cylindrical Z axes are collinear chrono::ChLinkMateCoaxial
3 Spherical Fix translations chrono::ChLinkMateSpherical
3 Planar YZ planes are coplanar chrono::ChLinkLockPlanePlane
3 Aligned Fix rotations chrono::ChLinkLockAlign
2 Revolute+Spherical Fix distance to a X axis; free rotations chrono::ChLinkRevoluteSpherical
2 Revolute+Align Allow translation respect to a rotating frame chrono::ChLinkRevoluteTranslational
2 Point on a Plane Z translations are blocked chrono::ChLinkLockPointPlane
2 Point on a Line Point belongs to a given line; free to rotate chrono::ChLinkLockPointLine
2 Parallel X axes are parallel chrono::ChLinkMateParallel
2 Orthogonal X axes are orthogonal chrono::ChLinkMateOrthogonal
1 Distance Polar distance is fixed chrono::ChLinkDistance
1 Rack-Pinion Couple rotation of the pinion Z axis with rack X axis chrono::ChLinkRackpinion
1 Pulley Couple rotation over Z axes; pulley-specific features chrono::ChLinkPulley
1 Gear Couple rotation over Z axes; gear-specific features chrono::ChLinkGear
0 Free No constraints chrono::ChLinkLockFree

Additionally, if a body has to be fixed to the global frame and reaction forces are of no interest, it is possible to use the chrono::ChBody::SetBodyFixed() method; this will also eliminate the state from the system.


ConDOF MotDOF Task Description Class
0|3|5 1 Linear Actuator Applies linear force|speed|position between frames;
optionally adds none|prismatic|spherical joints to its ends
can be paired with 1D chrono::ChShaft
chrono::ChLinkMotorLinear and derived
0|3|5 1 Rotating Actuator Applies torque|speed|position between frames;
optionally adds none|revolute|cylindrical|Oldham joints to its ends
can be paired with 1D chrono::ChShaft
chrono::ChLinkMotorRotation and derived
0 1 Linear Spring+Damper Spring+Damper depending to frame distance; also with custom force chrono::ChLinkTSDA
0 1 Rotational Spring+Damper Spring+Damper depending to frame rotation along Z axis; also with custom force chrono::ChLinkRSDA

Also chrono::ChLinkLockLock can be used to impose a motion between bodies.


In many cases there is no need to explicitly create two markers. Use in the case the ChLink::Initialize() function, passing the two bodies and the position of the constraint. This function will automatically create the two markers and it will add them to the bodies.

Alternatively, one can create the two markers by explicitly, add them to the two bodies, and then call Initialize() by passing the two markers.

In general, the process involves the following steps:

  1. Create one of the links of the chrono::ChLink derived class (e.g. chrono::ChLinkLockSpherical)
    auto mylink = std::make_shared<ChLinkLockSpherical>();
  2. Use mylink->Initialize(…) to connect two bodies; different links may accept different arguments. Refer to the documentation of the specific link for further information.
    mylink->Initialize(pendulumBody, // the 1st body to connect
    floorBody, // the 2nd body to connect
    ChCoordsys<>(ChVector<>(1, 0, 0),
    Q_from_AngAxis(-CH_C_PI / 2, ChVector<>(1, 0, 0))
    ) // master reference
  3. Add the link to a ChSystem
  4. Optional: set link properties


See also:

ChQuaternion< double > Q_from_AngAxis(double angle, const ChVector< double > &axis)
Get the quaternion from an angle of rotation and an axis, defined in abs coords.
Definition: ChQuaternion.cpp:99