---
url: /dyad/stable/stdlib/MultibodyComponents/components/GearConstraint.md
description: >-
  Dyad GearConstraint docs.  Ideal massless gear constraint between two
  arbitrary 3D shaft axes.
---

# `GearConstraint` {#GearConstraint}

Ideal massless gear constraint between two arbitrary 3D shaft axes.

Provides a kinematic gear ratio coupling between rotations about `frame_a` axis `n_a` and `frame_b` axis `n_b`. The two shafts share a common `bearing` frame; the joint axes are offset from `bearing` by `r_a` and `r_b` respectively.

* `ratio`: gear speed ratio (phi_a = ratio \* phi_b)

* `n_a`: axis of rotation of shaft a (same coordinates in frame_a, frame_b, bearing)

* `n_b`: axis of rotation of shaft b (same coordinates in frame_a, frame_b, bearing)

* `r_a`: vector from bearing to frame_a, resolved in bearing

* `r_b`: vector from bearing to frame_b, resolved in bearing

* `checkTotalPower`: when true, exposes `total_power` (~0 for an ideal gear; for testing only)

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

## Usage {#Usage}

`MultibodyComponents.GearConstraint(ratio, n_a=[1, 0, 0], n_b=[1, 0, 0], r_a=[0, 0, 0], r_b=[0, 0, 0])`

## Parameters: {#Parameters:}

|              Name |                                                                 Description | Units | Default value |
| -----------------:| ---------------------------------------------------------------------------:| -----:| -------------:|
| `checkTotalPower` |                                                                             |     – |         false |
|   `statePriority` |                                                                             |     – |             1 |
|           `ratio` |                                                            Gear speed ratio |     – |               |
|             `n_a` | Axis of rotation of shaft a (same coordinates in frame_a, frame_b, bearing) |     – |     \[1, 0, 0] |
|             `n_b` | Axis of rotation of shaft b (same coordinates in frame_a, frame_b, bearing) |     – |     \[1, 0, 0] |
|             `r_a` |                         Vector from bearing to frame_a, resolved in bearing |     m |     \[0, 0, 0] |
|             `r_b` |                         Vector from bearing to frame_b, resolved in bearing |     m |     \[0, 0, 0] |

## 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))

* `bearing` - 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 |
| -------------:| ------------------------------------------------------------:| ------:|
|       `phi_b` |         Relative rotation angle of revolute joint at frame_b |    rad |
|         `w_b` |       Relative angular velocity of revolute joint at frame_b |  rad/s |
|         `a_b` |   Relative angular acceleration of revolute joint at frame_b | rad/s2 |
| `total_power` | Total power flowing into this element (~0 for an ideal gear) |      – |

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
Ideal massless gear constraint between two arbitrary 3D shaft axes.

Provides a kinematic gear ratio coupling between rotations about `frame_a` axis
`n_a` and `frame_b` axis `n_b`. The two shafts share a common `bearing` frame;
the joint axes are offset from `bearing` by `r_a` and `r_b` respectively.

- `ratio`: gear speed ratio (phi_a = ratio * phi_b)
- `n_a`: axis of rotation of shaft a (same coordinates in frame_a, frame_b, bearing)
- `n_b`: axis of rotation of shaft b (same coordinates in frame_a, frame_b, bearing)
- `r_a`: vector from bearing to frame_a, resolved in bearing
- `r_b`: vector from bearing to frame_b, resolved in bearing
- `checkTotalPower`: when true, exposes `total_power` (~0 for an ideal gear; for testing only)
"""
component GearConstraint
  extends PartialTwoFrames()
  bearing = Frame3D() {}
  actuated_revolute_a = Revolute(final n = n_a, render = false)
  actuated_revolute_b = Revolute(final n = n_b, render = false)
  ideal_gear = RotationalComponents.Components.IdealGear(final ratio = ratio)
  gear_support = RotationalComponents.Components.Fixed()
  translation_a = FixedTranslation(final r = r_a, render = false)
  translation_b = FixedTranslation(final r = r_b, render = false)
  structural parameter checkTotalPower::Boolean = false
  structural parameter statePriority::Integer = 1
  "Gear speed ratio"
  parameter ratio::Real
  "Axis of rotation of shaft a (same coordinates in frame_a, frame_b, bearing)"
  parameter n_a::Real[3] = [1, 0, 0]
  "Axis of rotation of shaft b (same coordinates in frame_a, frame_b, bearing)"
  parameter n_b::Real[3] = [1, 0, 0]
  "Vector from bearing to frame_a, resolved in bearing"
  parameter r_a::Length[3] = [0, 0, 0]
  "Vector from bearing to frame_b, resolved in bearing"
  parameter r_b::Length[3] = [0, 0, 0]
  "Relative rotation angle of revolute joint at frame_b"
  variable phi_b::Angle(statePriority = statePriority)
  "Relative angular velocity of revolute joint at frame_b"
  variable w_b::AngularVelocity(statePriority = statePriority)
  "Relative angular acceleration of revolute joint at frame_b"
  variable a_b::AngularAcceleration
  "Total power flowing into this element (~0 for an ideal gear)"
  variable total_power::Real if checkTotalPower
relations
  phi_b = actuated_revolute_b.phi
  w_b = der(phi_b)
  a_b = der(w_b)
  connect(actuated_revolute_a.axis, ideal_gear.spline_a)
  connect(ideal_gear.spline_b, actuated_revolute_b.axis)
  connect(ideal_gear.support, gear_support.spline)
  connect(actuated_revolute_a.frame_a, translation_a.frame_b)
  connect(translation_a.frame_a, bearing)
  connect(translation_b.frame_a, bearing)
  connect(translation_b.frame_b, actuated_revolute_b.frame_a)
  connect(frame_a, actuated_revolute_a.frame_b)
  connect(actuated_revolute_b.frame_b, frame_b)
  if checkTotalPower
    total_power = dot(frame_a.f, resolve2(frame_a.R, der(frame_a.r_0))) + dot(frame_b.f, resolve2(frame_b.R, der(frame_b.r_0))) + dot(bearing.f, resolve2(bearing.R, der(bearing.r_0))) + dot(frame_a.tau, angular_velocity2(frame_a.R)) + dot(frame_b.tau, angular_velocity2(frame_b.R)) + dot(bearing.tau, angular_velocity2(bearing.R))
  end
end
```

```dyad
"""
Ideal massless gear constraint between two arbitrary 3D shaft axes.

Provides a kinematic gear ratio coupling between rotations about `frame_a` axis
`n_a` and `frame_b` axis `n_b`. The two shafts share a common `bearing` frame;
the joint axes are offset from `bearing` by `r_a` and `r_b` respectively.

- `ratio`: gear speed ratio (phi_a = ratio * phi_b)
- `n_a`: axis of rotation of shaft a (same coordinates in frame_a, frame_b, bearing)
- `n_b`: axis of rotation of shaft b (same coordinates in frame_a, frame_b, bearing)
- `r_a`: vector from bearing to frame_a, resolved in bearing
- `r_b`: vector from bearing to frame_b, resolved in bearing
- `checkTotalPower`: when true, exposes `total_power` (~0 for an ideal gear; for testing only)
"""
component GearConstraint
  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": []
    }
  }
  bearing = Frame3D() {}
  actuated_revolute_a = Revolute(final n = n_a, render = false)
  actuated_revolute_b = Revolute(final n = n_b, render = false)
  ideal_gear = RotationalComponents.Components.IdealGear(final ratio = ratio)
  gear_support = RotationalComponents.Components.Fixed()
  translation_a = FixedTranslation(final r = r_a, render = false)
  translation_b = FixedTranslation(final r = r_b, render = false)
  structural parameter checkTotalPower::Boolean = false
  structural parameter statePriority::Integer = 1
  "Gear speed ratio"
  parameter ratio::Real
  "Axis of rotation of shaft a (same coordinates in frame_a, frame_b, bearing)"
  parameter n_a::Real[3] = [1, 0, 0]
  "Axis of rotation of shaft b (same coordinates in frame_a, frame_b, bearing)"
  parameter n_b::Real[3] = [1, 0, 0]
  "Vector from bearing to frame_a, resolved in bearing"
  parameter r_a::Length[3] = [0, 0, 0]
  "Vector from bearing to frame_b, resolved in bearing"
  parameter r_b::Length[3] = [0, 0, 0]
  "Relative rotation angle of revolute joint at frame_b"
  variable phi_b::Angle(statePriority = statePriority)
  "Relative angular velocity of revolute joint at frame_b"
  variable w_b::AngularVelocity(statePriority = statePriority)
  "Relative angular acceleration of revolute joint at frame_b"
  variable a_b::AngularAcceleration
  "Total power flowing into this element (~0 for an ideal gear)"
  variable total_power::Real if checkTotalPower
relations
  phi_b = actuated_revolute_b.phi
  w_b = der(phi_b)
  a_b = der(w_b)
  connect(actuated_revolute_a.axis, ideal_gear.spline_a)
  connect(ideal_gear.spline_b, actuated_revolute_b.axis)
  connect(ideal_gear.support, gear_support.spline)
  connect(actuated_revolute_a.frame_a, translation_a.frame_b)
  connect(translation_a.frame_a, bearing)
  connect(translation_b.frame_a, bearing)
  connect(translation_b.frame_b, actuated_revolute_b.frame_a)
  connect(frame_a, actuated_revolute_a.frame_b)
  connect(actuated_revolute_b.frame_b, frame_b)
  if checkTotalPower
    total_power = dot(frame_a.f, resolve2(frame_a.R, der(frame_a.r_0))) + dot(frame_b.f, resolve2(frame_b.R, der(frame_b.r_0))) + dot(bearing.f, resolve2(bearing.R, der(bearing.r_0))) + dot(frame_a.tau, angular_velocity2(frame_a.R)) + dot(frame_b.tau, angular_velocity2(frame_b.R)) + dot(bearing.tau, angular_velocity2(bearing.R))
  end
metadata {}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
