---
url: /dyad/dev/stdlib/MultibodyComponents/components/RevoluteConstraint.md
description: >-
  Dyad RevoluteConstraint docs.  Revolute cut-joint that constrains frame_b to a
  single rotational degree of freedom about axis n relative to frame_a, without
  introducing st...
---

# `RevoluteConstraint` {#RevoluteConstraint}

Revolute cut-joint that constrains `frame_b` to a single rotational degree of freedom about axis `n` relative to `frame_a`, without introducing state variables for the relative motion.

Unlike the standard `Revolute` joint, this component does not define explicit state variables for the relative motion; instead it imposes kinematic constraints between `frame_a` and `frame_b` and evaluates the forces and torques required to satisfy them (an "implicit" joint). As a consequence, the relative kinematics between the two frames cannot be initialized.

It is intended for closed kinematic loops, where this formulation can simplify the resulting non-linear system of equations. In systems without closed loops the standard `Revolute` joint should be used instead.

The translational constraints may be released individually per axis (resolved in `frame_a`) with `x_locked`, `y_locked`, `z_locked`. With all three locked (default) the origins of the two frames coincide and only rotation about `n` remains free.

This component extends from [`PartialTwoFrames`](../types/PartialTwoFrames.md) This component extends from [`Renderable`](../types/Renderable.md)

## Usage {#Usage}

`MultibodyComponents.RevoluteConstraint(render=true, color=world_default_joint_color(), specular_coefficient=1.5, sphere_diameter=world_default_joint_length() / 3)`

## Parameters: {#Parameters:}

|                   Name |                                                                                                                     Description | Units |             Default value |
| ----------------------:| -------------------------------------------------------------------------------------------------------------------------------:| -----:| -------------------------:|
|             `x_locked` | If true, lock the relative translation along the frame_a x-direction (otherwise the constraint force in that direction is zero) |     – |                      true |
|             `y_locked` | If true, lock the relative translation along the frame_a y-direction (otherwise the constraint force in that direction is zero) |     – |                      true |
|             `z_locked` | If true, lock the relative translation along the frame_a z-direction (otherwise the constraint force in that direction is zero) |     – |                      true |
|                    `n` |                                                                     Axis of rotation resolved in frame_a (= same as in frame_b) |     – |                 \[0, 0, 1] |
|                    `e` |                                                                                                                                 |     – |              n / norm\_(n) |
|                `nnx_a` |                                                                                                                                 |     – | ifelse(abs(...\[1, 0, 0])) |
|                 `ey_a` |                                                                                                                                 |     – | cross(e, nn...(e, nnx_a)) |
|                 `ex_a` |                                                                                                                                 |     – |            cross(ey_a, e) |
|               `render` |                                                                                                                                 |     – |                      true |
|                `color` |                                                                                                                                 |     – | world_defau...int_color() |
| `specular_coefficient` |                                                                                                                                 |     – |                       1.5 |
|      `sphere_diameter` |                                                                                            Diameter of the sphere in animations |     – | world_defau...ength() / 3 |

## Connectors {#Connectors}

* `frame_a` - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several `Frame`

connectors that can be connected together ([`Frame3D`](/stdlib/Dyad/connectors/Frame3D#Frame3D))

* `frame_b` - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several `Frame`

connectors that can be connected together ([`Frame3D`](/stdlib/Dyad/connectors/Frame3D#Frame3D))

## Variables {#Variables}

|      Name |                                                                                  Description | Units |
| ---------:| --------------------------------------------------------------------------------------------:| -----:|
|   `n_rel` | Rotation axis e of frame_a expressed in frame_b coordinates (relative rotation applied to e) |     – |
| `r_rel_a` |             Position vector from origin of frame_a to origin of frame_b, resolved in frame_a |     m |

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
Revolute cut-joint that constrains `frame_b` to a single rotational degree of
freedom about axis `n` relative to `frame_a`, without introducing state
variables for the relative motion.

Unlike the standard `Revolute` joint, this component does not define explicit
state variables for the relative motion; instead it imposes kinematic constraints
between `frame_a` and `frame_b` and evaluates the forces and torques required to
satisfy them (an "implicit" joint). As a consequence, the relative kinematics
between the two frames cannot be initialized.

It is intended for closed kinematic loops, where this formulation can simplify
the resulting non-linear system of equations. In systems without closed loops
the standard `Revolute` joint should be used instead.

The translational constraints may be released individually per axis (resolved in
`frame_a`) with `x_locked`, `y_locked`, `z_locked`. With all three locked
(default) the origins of the two frames coincide and only rotation about `n`
remains free.
"""
component RevoluteConstraint
  extends PartialTwoFrames()
  extends Renderable(color = world_default_joint_color())
  "If true, lock the relative translation along the frame_a x-direction (otherwise the constraint force in that direction is zero)"
  structural parameter x_locked::Boolean = true
  "If true, lock the relative translation along the frame_a y-direction (otherwise the constraint force in that direction is zero)"
  structural parameter y_locked::Boolean = true
  "If true, lock the relative translation along the frame_a z-direction (otherwise the constraint force in that direction is zero)"
  structural parameter z_locked::Boolean = true
  # Visualization shape (sphere representing the cut-joint)
  shape = SphereShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), length = sphere_diameter, width = sphere_diameter, height = sphere_diameter)
  "Axis of rotation resolved in frame_a (= same as in frame_b)"
  structural parameter n::Real[3] = [0, 0, 1]
  "Diameter of the sphere in animations"
  parameter sphere_diameter::Real = world_default_joint_length() / 3
  # The axis basis is structural so that the constraint equations see numeric
  # coefficients; with symbolic coefficients, tearing may solve a constraint for a
  # variable whose pivot (e.g. ey_a[3]) is identically zero at the actual axis value.
  final structural parameter e::Real[3] = n / norm_(n)
  final structural parameter nnx_a::Real[3] = ifelse(abs(e[1]) > 0.1, [0, 1, 0], ifelse(abs(e[2]) > 0.1, [0, 0, 1], [1, 0, 0]))
  final structural parameter ey_a::Real[3] = cross(e, nnx_a) / norm_(cross(e, nnx_a))
  final structural parameter ex_a::Real[3] = cross(ey_a, e)
  "Rotation axis e of frame_a expressed in frame_b coordinates (relative rotation applied to e)"
  variable n_rel::Real[3]
  "Position vector from origin of frame_a to origin of frame_b, resolved in frame_a"
  variable r_rel_a::Position[3]
relations
  r_rel_a = resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0)
  n_rel = resolve_relative(e, frame_a.R, frame_b.R)
  # Constraint equations concerning translations: lock the relative position
  # along each locked axis, otherwise the corresponding constraint force is zero
  if x_locked
    r_rel_a[1] = 0
  else
    frame_a.f[1] = 0
  end
  if y_locked
    r_rel_a[2] = 0
  else
    frame_a.f[2] = 0
  end
  if z_locked
    r_rel_a[3] = 0
  else
    frame_a.f[3] = 0
  end
  # Constraint equations concerning rotations: the relative rotation must keep
  # the rotation axis e invariant (no tilt about the two perpendicular axes)
  0 = dot(ex_a, n_rel)
  0 = dot(ey_a, n_rel)
  # No constraint torque about the rotation axis (free to rotate)
  dot(frame_a.tau, n) = 0
  # Force and torque balance between the two frames
  frame_a.f + resolve_relative(frame_b.f, frame_b.R, frame_a.R) = [0, 0, 0]
  frame_a.tau + resolve_relative(frame_b.tau, frame_b.R, frame_a.R) - cross(r_rel_a, frame_a.f) = [0, 0, 0]
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/RevoluteConstraint.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 200,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

```dyad
"""
Revolute cut-joint that constrains `frame_b` to a single rotational degree of
freedom about axis `n` relative to `frame_a`, without introducing state
variables for the relative motion.

Unlike the standard `Revolute` joint, this component does not define explicit
state variables for the relative motion; instead it imposes kinematic constraints
between `frame_a` and `frame_b` and evaluates the forces and torques required to
satisfy them (an "implicit" joint). As a consequence, the relative kinematics
between the two frames cannot be initialized.

It is intended for closed kinematic loops, where this formulation can simplify
the resulting non-linear system of equations. In systems without closed loops
the standard `Revolute` joint should be used instead.

The translational constraints may be released individually per axis (resolved in
`frame_a`) with `x_locked`, `y_locked`, `z_locked`. With all three locked
(default) the origins of the two frames coincide and only rotation about `n`
remains free.
"""
component RevoluteConstraint
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  parameter render::Boolean = true
  parameter color::Real[4] = [0.5, 0.5, 0.5, 1.0]
  parameter specular_coefficient::Real = 1.5
  "If true, lock the relative translation along the frame_a x-direction (otherwise the constraint force in that direction is zero)"
  structural parameter x_locked::Boolean = true
  "If true, lock the relative translation along the frame_a y-direction (otherwise the constraint force in that direction is zero)"
  structural parameter y_locked::Boolean = true
  "If true, lock the relative translation along the frame_a z-direction (otherwise the constraint force in that direction is zero)"
  structural parameter z_locked::Boolean = true
  # Visualization shape (sphere representing the cut-joint)
  shape = SphereShape(render = render, color = color, r = frame_a.r_0, R = transpose(frame_a.R), length = sphere_diameter, width = sphere_diameter, height = sphere_diameter)
  "Axis of rotation resolved in frame_a (= same as in frame_b)"
  structural parameter n::Real[3] = [0, 0, 1]
  "Diameter of the sphere in animations"
  parameter sphere_diameter::Real = world_default_joint_length() / 3
  # The axis basis is structural so that the constraint equations see numeric
  # coefficients; with symbolic coefficients, tearing may solve a constraint for a
  # variable whose pivot (e.g. ey_a[3]) is identically zero at the actual axis value.
  final structural parameter e::Real[3] = n / norm_(n)
  final structural parameter nnx_a::Real[3] = ifelse(abs(e[1]) > 0.1, [0, 1, 0], ifelse(abs(e[2]) > 0.1, [0, 0, 1], [1, 0, 0]))
  final structural parameter ey_a::Real[3] = cross(e, nnx_a) / norm_(cross(e, nnx_a))
  final structural parameter ex_a::Real[3] = cross(ey_a, e)
  "Rotation axis e of frame_a expressed in frame_b coordinates (relative rotation applied to e)"
  variable n_rel::Real[3]
  "Position vector from origin of frame_a to origin of frame_b, resolved in frame_a"
  variable r_rel_a::Position[3]
relations
  r_rel_a = resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0)
  n_rel = resolve_relative(e, frame_a.R, frame_b.R)
  # Constraint equations concerning translations: lock the relative position
  # along each locked axis, otherwise the corresponding constraint force is zero
  if x_locked
    r_rel_a[1] = 0
  else
    frame_a.f[1] = 0
  end
  if y_locked
    r_rel_a[2] = 0
  else
    frame_a.f[2] = 0
  end
  if z_locked
    r_rel_a[3] = 0
  else
    frame_a.f[3] = 0
  end
  # Constraint equations concerning rotations: the relative rotation must keep
  # the rotation axis e invariant (no tilt about the two perpendicular axes)
  0 = dot(ex_a, n_rel)
  0 = dot(ey_a, n_rel)
  # No constraint torque about the rotation axis (free to rotate)
  dot(frame_a.tau, n) = 0
  # Force and torque balance between the two frames
  frame_a.f + resolve_relative(frame_b.f, frame_b.R, frame_a.R) = [0, 0, 0]
  frame_a.tau + resolve_relative(frame_b.tau, frame_b.R, frame_a.R) - cross(r_rel_a, frame_a.f) = [0, 0, 0]
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/RevoluteConstraint.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 200,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
