# PX4 X-Quadcopter Controller

> Documentation version: 3.0
> HTML: https://docs.flarelive.manifolddynamics.com/reference/actuators-and-controllers/multicopter-controller.html
> [Complete contents](https://docs.flarelive.manifolddynamics.com/contents.md) · [Agent index](https://docs.flarelive.manifolddynamics.com/llms.txt)

Flare Live **3.0** · **Scene Object** · API type `simexp.uav.multicopter_controller`.

A PX4-inspired X-quadcopter position/attitude/rate controller and mixer. Attach directly to a Joint-Body Pair whose frame is the measurement/control frame (+X forward, +Z up). Assign actual FL/FR/BL/BR motor references; object traversal order is not rotor assignment.

Input length is variable. First value selects mode: 0 = 12-value world position/velocity/acceleration/yaw/yaw-rate command; 1 = quaternion wxyz/yaw-rate/throttle (7 values); 2 = local angular rates/throttle (5); 3 = local torques/throttle (5). Negative mode disables motors. Angles/rates use rad and rad/s. NaN is allowed only for the fields documented by the runtime input description. See [P600](https://docs.flarelive.manifolddynamics.com/manual/tutorials/p600/index.md).

## Properties

Values below are defaults for new objects. See [common properties](https://docs.flarelive.manifolddynamics.com/reference/common/properties.md) for shared fields, case-sensitive API paths and conditional visibility.

### General

| API path | Constructor default / enum choices | Meaning / units | Editable in Simulation |
| --- | --- | --- | --- |
| `front_left_motor` | None | Scene object receiving the front-left throttle command. Choose a motor on that arm in the controller frame that accepts one normalized throttle input. | No |
| `front_right_motor` | None | Scene object receiving the front-right throttle command. Choose a motor on that arm in the controller frame that accepts one normalized throttle input. | No |
| `back_left_motor` | None | Scene object receiving the rear-left throttle command. Choose a motor on that arm in the controller frame that accepts one normalized throttle input. | No |
| `back_right_motor` | None | Scene object receiving the rear-right throttle command. Choose a motor on that arm in the controller frame that accepts one normalized throttle input. | No |

### Mixer

| API path | Constructor default / enum choices | Meaning / units | Editable in Simulation |
| --- | --- | --- | --- |
| `mixer.yaw_weight` | 1.0 | Dimensionless multiplier on the alternating yaw correction added to the four motor commands. Zero removes yaw authority from the mixer. | No |

### Rate Controller

| API path | Constructor default / enum choices | Meaning / units | Editable in Simulation |
| --- | --- | --- | --- |
| `rate_controller.control_frequency` | 250.0 | Target update rate of the body angular-rate loop, in Hz. The rate loop executes at most once per simulation step. | No |
| `rate_controller.k_gain.roll` | 0.15 | Scales the roll rate error and the measured rate change before all three rate PID terms. | No |
| `rate_controller.k_gain.pitch` | 0.15 | Scales the pitch rate error and the measured rate change before all three rate PID terms. | No |
| `rate_controller.k_gain.yaw` | 0.2 | Scales the yaw rate error and the measured rate change before all three rate PID terms. | No |
| `rate_controller.proportional_gain.roll` | 1.0 | Gain from scaled roll rate error to the immediate mixer command. | No |
| `rate_controller.proportional_gain.pitch` | 1.0 | Gain from scaled pitch rate error to the immediate mixer command. | No |
| `rate_controller.proportional_gain.yaw` | 1.0 | Gain from scaled yaw rate error to the immediate mixer command. | No |
| `rate_controller.integral_gain.roll` | 1.33 | Accumulates scaled roll rate error over time to correct steady offset. | No |
| `rate_controller.integral_gain.pitch` | 1.33 | Accumulates scaled pitch rate error over time to correct steady offset. | No |
| `rate_controller.integral_gain.yaw` | 0.5 | Accumulates scaled yaw rate error over time to correct steady offset. | No |
| `rate_controller.derivative_gain.roll` | 0.02 | Opposes changes in measured roll rate. Differentiates the observation so a setpoint jump does not directly enter this term. | No |
| `rate_controller.derivative_gain.pitch` | 0.02 | Opposes changes in measured pitch rate. Differentiates the observation so a setpoint jump does not directly enter this term. | No |
| `rate_controller.derivative_gain.yaw` | 0.0 | Opposes changes in measured yaw rate. Differentiates the observation so a setpoint jump does not directly enter this term. | No |
| `rate_controller.integral_limit.roll` | 0.3 | Symmetric absolute limit on the accumulated roll integral contribution in mixer command units. Zero disables that contribution. | No |
| `rate_controller.integral_limit.pitch` | 0.3 | Symmetric absolute limit on the accumulated pitch integral contribution in mixer command units. Zero disables that contribution. | No |
| `rate_controller.integral_limit.yaw` | 0.3 | Symmetric absolute limit on the accumulated yaw integral contribution in mixer command units. Zero disables that contribution. | No |

### Attitude Controller

| API path | Constructor default / enum choices | Meaning / units | Editable in Simulation |
| --- | --- | --- | --- |
| `attitude_controller.control_frequency` | 250.0 | Target update rate of the attitude-to-body-rate loop, in Hz. The attitude loop executes at most once per simulation step. | No |
| `attitude_controller.proportional_gain.roll` | 6.5 | Gain from the roll component of the attitude error to the desired body rate. | No |
| `attitude_controller.proportional_gain.pitch` | 6.5 | Gain from the pitch component of the attitude error to the desired body rate. | No |
| `attitude_controller.proportional_gain.yaw` | 2.8 | Gain from the yaw component of the attitude error to the desired body rate. | No |
| `attitude_controller.integral_gain.roll` | 0.0 | Accumulates roll attitude error into the requested body rate over time. | No |
| `attitude_controller.integral_gain.pitch` | 0.0 | Accumulates pitch attitude error into the requested body rate over time. | No |
| `attitude_controller.integral_gain.yaw` | 0.0 | Accumulates yaw attitude error into the requested body rate over time. | No |
| `attitude_controller.derivative_gain.roll` | 0.0 | Uses measured roll angular rate to damp the attitude loop's rate request. | No |
| `attitude_controller.derivative_gain.pitch` | 0.0 | Uses measured pitch angular rate to damp the attitude loop's rate request. | No |
| `attitude_controller.derivative_gain.yaw` | 0.0 | Uses measured yaw angular rate to damp the attitude loop's rate request. | No |
| `attitude_controller.max_output_angular_rate.roll` | 3.84 | Absolute bound on the roll rate requested by the attitude loop, in rad/s. Applied after yaw-rate feedforward. | No |
| `attitude_controller.max_output_angular_rate.pitch` | 3.84 | Absolute bound on the pitch rate requested by the attitude loop, in rad/s. Applied after yaw-rate feedforward. | No |
| `attitude_controller.max_output_angular_rate.yaw` | 3.49 | Absolute bound on the yaw rate requested by the attitude loop, in rad/s. Applied after yaw-rate feedforward. | No |
| `attitude_controller.yaw_weight` | 0.4 | Fraction of the desired yaw correction blended into the target orientation after aligning the thrust axes. Use 0 to prioritize thrust direction alone and 1 for the full yaw correction. | No |

### Position Controller

| API path | Constructor default / enum choices | Meaning / units | Editable in Simulation |
| --- | --- | --- | --- |
| `position_controller.control_frequency` | 250.0 | Target update rate of the position/velocity loop, in Hz. This loop generates attitude and throttle requests and executes at most once per simulation step. | No |
| `position_controller.velocity_proportional_gain` | (1.8, 1.8, 4.0) | XYZ gains from world velocity error to acceleration correction. The X gain must be nonzero for the horizontal saturation feedback calculation. | No |
| `position_controller.velocity_integral_gain` | (0.4, 0.4, 2.0) | XYZ gains accumulating world velocity error into an acceleration correction. | No |
| `position_controller.velocity_derivative_gain` | (0.2, 0.2, 0.0) | XYZ gains that oppose changes in measured world velocity. This term reacts to measured acceleration. | No |
| `position_controller.max_tilt` | 0.785 | Maximum tilt angle of the requested thrust direction away from upright, in radians. | No |
| `position_controller.hover_throttle` | 0.5 | Normalized throttle estimate for level hover. The controller uses it to convert requested vertical acceleration into throttle. Set a positive value consistent with the vehicle. | No |
| `position_controller.min_throttle` | 0.12 | Minimum normalized collective throttle used by the position loop, including vertical saturation feedback. | No |
| `position_controller.max_throttle` | 1.0 | Maximum magnitude of the position loop's normalized throttle vector. The loop shares this budget between vertical and horizontal demands. | No |
| `position_controller.horizontal_throttle_margin` | 0.3 | Normalized throttle budget reserved for horizontal control when vertical demand saturates. Keep it between zero and Max throttle. | No |
| `position_controller.position_proportional_gain` | (0.95, 0.95, 1.0) | XYZ gains converting world position error in meters to a velocity correction in m/s. | No |
| `position_controller.position_integral_gain` | (0.0, 0.0, 0.0) | XYZ gains accumulating position error into the velocity request. | No |
| `position_controller.position_derivative_gain` | (0.0, 0.0, 0.0) | XYZ gains that damp the position-loop velocity request using the measured change in position per second. | No |
| `position_controller.max_horizontal_velocity` | 12.0 | Maximum magnitude of the requested horizontal velocity vector, in m/s. Position correction takes priority over velocity feedforward when the request saturates. | No |
| `position_controller.max_up_velocity` | 3.0 | Positive limit on upward requested velocity, in m/s. | No |
| `position_controller.max_down_velocity` | 1.5 | Positive magnitude of the downward requested velocity limit, in m/s. | No |


## Simulation input/output

The first input selects a mode; supply the corresponding whole vector. No outputs: read Body Info and rotor Joint Sensors for feedback.

| Mode | Vector length | Fields after mode |
| --- | --- | --- |
| 0: Position | 12 | World position XYZ (m), world velocity XYZ (m/s), world acceleration XYZ (m/s²), yaw (rad), yaw rate (rad/s). Position-mode setpoint fields may use NaN to leave those targets unspecified. |
| 1: Attitude | 7 | Quaternion w/x/y/z, yaw rate (rad/s), throttle (0–1). |
| 2: Rate | 5 | Local roll/pitch/yaw rates (rad/s), throttle (0–1). |
| 3: Torque | 5 | Local roll/pitch/yaw torques (N·m), throttle (0–1). |
| Negative: Disabled | 1 | For example `[-1]`; disables the controller's motor commands. |

A position command for `(0, 0, 1)` m at yaw 0 is:

```python
import math
command = [0, 0, 0, 1, math.nan, math.nan, math.nan,
           math.nan, math.nan, math.nan, 0, math.nan]
```

The [P600 tutorial](https://docs.flarelive.manifolddynamics.com/manual/tutorials/p600/index.md) applies this command in a complete control loop.
