10. Constraints
Constraints represent geometrical relationships between bodies. For example, a door hanging in its frame with hinges can be modeled in a simulation with one or several Constraints. A tire attached to a wheel hub is another example where a Constraint can be used.
The image below show two boxes constrained using a Hinge Constraint.
Try out the Constraints
level, included in the Tutorial Hallways Demo Project
10.1. Creating Constraints
Constraints can be created in the same way as Rigid Bodies and Shapes are created, by adding Components to Actors. Another way to create Constraints is through the Constraint creation wizard found in the AGX Dynamics Mode.
Select the type of Constraint to create, the bodies that should be constrained, and the way attachment frames should be computed. For the example, create a Hinge Constraint having a wheel as it’s first body and leave the second body blank. This will constrain the wheel to the world.
Orange circles are rendered to indicate the constrained bodies when an actor containing one or more Constraints is selected. When a Constraint component is selected in the Details panel then the full Constraint gizmo is rendered. The Constraint gizmo is a visualization of both the Constraint frame and the free degree(s) of freedom, if any. A Prismatic has one free translational axis, the z-axis, which can be seen in the image below.
10.2. Secondary Constraints
To enable motors, friction controllers and more, one can enable one or several of the Secondary Constraints of a Constraint Component. This is done from the AGX Secondary Constraint category of the Details panel when a Constraint Component is selected. A Secondary Constraint acts on one of the degrees of freedom that the main Constraint doesn’t constrain. For example, a Hinge Constraint doesn’t constraint one rotation degree of freedom so its Secondary Constraints acts on that rotational axis. Different constraint types have different Secondary Constraints available. Secondary Constraints are disabled by default.
A special case is the Distance Constraint. It uses the Lock Controller for its main functionality so disabling that will prevent the constraint from maintaining the target distance.
Below is an example where the Target Speed Controller is enabled and set to a speed of 100 degrees per second.
The following Secondary Constraints are available:
- Electric Motor Controller
Converts an input voltage to a force or torque.
- Friction Controller
Applies a friction force based on current load on the constraint and a friction coefficient.
- Lock Controller
Locks any motion along or around the degree of freedom.
- Range Controller
Stops motion from extending past some distance or angle from the constraint’s zero position.
- Target Speed Controller
Applies a force or torque on the Rigid Bodies to maintain the set relative velocity.
- Screw Controller
Enforces a relationship between rotation and translation. Any rotation will resulting in a corresponding translation, and vice versa.
Only available on Cylindrical Constraint, which has a free translational degree of freedom and a free rotational degree of freedom.
- Twist Range Controller
A Range Controller specifically around the Z axis.
Only available on Ball Constraint.
10.3. Hinge Constraint
A Hinge Constraint allows for rotations around the z axis. All other degrees of freedoms are locked. It has the following Secondary Constraints:
Electric Motor Controller
Friction Controller
Lock Controller
Range Controller
Target Speed Controller
10.4. Prismatic Constraint
A Prismatic Constraint allows for translations along the z axis. All other degrees of freedoms are locked. It has the following Secondary Constraints:
Electric Motor Controller
Friction Controller
Lock Controller
Range Controller
Target Speed Controller
10.5. Lock Constraint
For a Lock Constraint, all degrees of freedoms are locked. It has no Secondary Constraints.
10.6. Ball Constraint
A Ball Constraint allows for rotations around the x, y and z axis. All other degrees of freedoms are locked. It has the following Secondary Constraints:
Twist Range Controller
The Twist Range Controller enforces a limit on how far the two bodies can twist around the constraint’s Z axis. In the following image we see the Detail panel for a Twist Range controller that has been set up to allow a rotation of 40 degrees in either direction
10.7. Cylindrical Constraint
A Cylindrical Constraint allows for translations along and rotations around the z axis. All other degrees of freedoms are locked. It has the following Secondary Constraints:
Electric Motor Controller (one for rotation + one for translation)
Friction Controller (one for rotation + one for translation)
Lock Controller (one for rotation + one for translation)
Range Controller (one for rotation + one for translation)
Target Speed Controller (one for rotation + one for translation)
Screw Controller
10.8. Distance Constraint
A Distance Constraint ensures a constant distance is kept. The bodies may translate and rotate freely as long as the distance is constant. It uses the Lock Controller to maintain the target distance. If the Lock Controller is disabled then the Distance Constraint will be unable to maintain the target distance.
10.9. Graphical Representation Settings
All Constraints have graphical representations, i.e. are rendered to the screen when an actor containing one or several Constraints is selected.
These renderings are scaled in such a way that they keep a constant size as measured on the screen. This behavior is similar to the regular transformation gizmo.
To keep these renderings from cluttering the screen when moving far away from a selected Actor, a maximum distance within which this scaling is active, is available as a plugin setting.
To change this setting, select Edit > Project Settings... > Plugins > AGX Dynamics
and in the category Rendering
change the value of Constraint Visualization Scaling Distance Max
.