---
url: /dyad/stable/stdlib/MultibodyComponents/components/ControlMixer.md
description: >-
  Dyad ControlMixer docs.  Static thrust mixer: maps three control channels into
  four thruster commands using fixed gain vectors. The 3-vector input u_in is
  interprete...
---

# `ControlMixer` {#ControlMixer}

Static thrust mixer: maps three control channels into four thruster commands using fixed gain vectors. The 3-vector input `u_in` is interpreted as `[u_alt, u_roll, u_pitch]`; each thruster command is `Galt[i]*u_in[1] + Groll[i]*u_in[2] + Gpitch[i]*u_in[3]`.

## Usage {#Usage}

`MultibodyComponents.ControlMixer(Galt=[1, 1, 1, 1], Groll=[1, 0, -1, 0], Gpitch=[0, -1, 0, 1])`

## Parameters: {#Parameters:}

|     Name |                             Description | Units | Default value |
| --------:| ---------------------------------------:| -----:| -------------:|
|   `Galt` | Altitude-channel gain for each thruster |     – |  \[1, 1, 1, 1] |
|  `Groll` |     Roll-channel gain for each thruster |     – | \[1, 0, -1, 0] |
| `Gpitch` |    Pitch-channel gain for each thruster |     – | \[0, -1, 0, 1] |

## Connectors {#Connectors}

* `u_in` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `u_out` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{u_out}\_{1}\left( t \right) &= \mathtt{Galt}*{1} ~ \mathtt{u_in}\_{1}\left( t \right) + \mathtt{Gpitch}*{1} ~ \mathtt{u_in}\_{3}\left( t \right) + \mathtt{Groll}*{1} ~ \mathtt{u_in}\_{2}\left( t \right) \\
\mathtt{u_out}\_{2}\left( t \right) &= \mathtt{Galt}*{2} ~ \mathtt{u_in}\_{1}\left( t \right) + \mathtt{Gpitch}*{2} ~ \mathtt{u_in}\_{3}\left( t \right) + \mathtt{Groll}*{2} ~ \mathtt{u_in}\_{2}\left( t \right) \\
\mathtt{u_out}\_{3}\left( t \right) &= \mathtt{Galt}*{3} ~ \mathtt{u_in}\_{1}\left( t \right) + \mathtt{Gpitch}*{3} ~ \mathtt{u_in}\_{3}\left( t \right) + \mathtt{Groll}*{3} ~ \mathtt{u_in}\_{2}\left( t \right) \\
\mathtt{u_out}\_{4}\left( t \right) &= \mathtt{Galt}*{4} ~ \mathtt{u_in}\_{1}\left( t \right) + \mathtt{Gpitch}*{4} ~ \mathtt{u_in}\_{3}\left( t \right) + \mathtt{Groll}*{4} ~ \mathtt{u_in}\_{2}\left( t \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Static thrust mixer: maps three control channels into four thruster commands
using fixed gain vectors. The 3-vector input `u_in` is interpreted as
`[u_alt, u_roll, u_pitch]`; each thruster command is
`Galt[i]*u_in[1] + Groll[i]*u_in[2] + Gpitch[i]*u_in[3]`.
"""
component ControlMixer
  "Control commands as a 3-vector: [altitude, roll, pitch]. Bundle three scalar PID outputs with a `Mux3` before connecting here."
  u_in = [RealInput() for i in 1:3] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Thrust commands for the four thrusters (in the order expected by RotorCraft.u)"
  u_out = [RealOutput() for i in 1:4] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Altitude-channel gain for each thruster"
  parameter Galt::Real[4] = [1, 1, 1, 1]
  "Roll-channel gain for each thruster"
  parameter Groll::Real[4] = [1, 0, -1, 0]
  "Pitch-channel gain for each thruster"
  parameter Gpitch::Real[4] = [0, -1, 0, 1]
relations
  for i in 1:4
    u_out[i] = Galt[i] * u_in[1] + Groll[i] * u_in[2] + Gpitch[i] * u_in[3]
  end
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/ControlMixer.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

```dyad
"""
Static thrust mixer: maps three control channels into four thruster commands
using fixed gain vectors. The 3-vector input `u_in` is interpreted as
`[u_alt, u_roll, u_pitch]`; each thruster command is
`Galt[i]*u_in[1] + Groll[i]*u_in[2] + Gpitch[i]*u_in[3]`.
"""
component ControlMixer
  "Control commands as a 3-vector: [altitude, roll, pitch]. Bundle three scalar PID outputs with a `Mux3` before connecting here."
  u_in = [RealInput() for i in 1:3] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 450, "x2": 100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Thrust commands for the four thrusters (in the order expected by RotorCraft.u)"
  u_out = [RealOutput() for i in 1:4] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 450, "x2": 1000, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Altitude-channel gain for each thruster"
  parameter Galt::Real[4] = [1, 1, 1, 1]
  "Roll-channel gain for each thruster"
  parameter Groll::Real[4] = [1, 0, -1, 0]
  "Pitch-channel gain for each thruster"
  parameter Gpitch::Real[4] = [0, -1, 0, 1]
relations
  for i in 1:4
    u_out[i] = Galt[i] * u_in[1] + Groll[i] * u_in[2] + Gpitch[i] * u_in[3]
  end
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/ControlMixer.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "160"}
      }
    ]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
