Gimbal

Gimbal class for managing camera gimbal control.

#include <gimbal.hpp>

Classes

class Gimbal

Handle for controlling a gimbal (physical or virtual) attached to a vehicle.

Supports absolute attitude commands, rate-based control, and status polling.

struct Attitude

Gimbal attitude in degrees.

FieldTypeDescription
pitch float degrees, positive = up
yaw float degrees, positive = right
roll float degrees, positive = clockwise

struct Limits

Gimbal limits in degrees.

FieldTypeDescription
min_pitch float Minimum pitch travel in degrees.
max_pitch float Maximum pitch travel in degrees.
min_yaw float Minimum yaw travel in degrees.
max_yaw float Maximum yaw travel in degrees.
min_roll float Minimum roll travel in degrees.
max_roll float Maximum roll travel in degrees.

struct Status

Current gimbal status as reported by the onboard system.

FieldTypeDescription
attitude Attitude Current gimbal attitude in degrees.
limits Limits Configured gimbal travel limits in degrees.
stabilized bool True when the gimbal stabilization loop is active.
available bool True when a gimbal is present and responsive.

enum Mode

Virtual-gimbal image processing mode.

ValueDescription
kRaw Full lens FOV, no crop (widest, not zoomed).
kCrop Videocrop pan/tilt, no distortion correction.
kDewarp Rectilinear remap; straight lines, crops to virtual FOV.
~Gimbal()

Destroys the Gimbal handle.

auto SetMode(Mode mode) -> void

Set the virtual-gimbal processing mode at runtime.

Note:

Best-effort. Has no effect on physical gimbals or a ground-side direct gimbal.

ParameterTypeDescription
mode Mode Desired processing mode (kRaw / kCrop / kDewarp).
auto SetAttitude(float pitch, float yaw, float roll) -> void

Set absolute gimbal orientation in degrees.

ParameterTypeDescription
pitch float Desired pitch angle in degrees, positive = up.
yaw float Desired yaw angle in degrees, positive = right.
roll float Desired roll angle in degrees, positive = clockwise.
auto SetAttitude(const Quaternion& orientation) -> void

Set absolute gimbal orientation from a quaternion (convenience overload).

Converts @p orientation to pitch/yaw/roll (ZYX convention) and forwards to SetAttitude(pitch, yaw, roll). The resulting angles are still subject to the gimbal's per-axis limits, and axes the device does not physically have (e.g. roll on a 2-axis gimbal) are ignored.

ParameterTypeDescription
orientation const Quaternion& Desired orientation as a unit quaternion (x, y, z, w).
auto SetSpeed(float pitch_rate, float yaw_rate, float roll_rate) -> void

Set angular velocity in degrees/second for rate-based (joystick-style) control.

ParameterTypeDescription
pitch_rate float Desired pitch rate in degrees/second, positive = up.
yaw_rate float Desired yaw rate in degrees/second, positive = right.
roll_rate float Desired roll rate in degrees/second, positive = clockwise.
auto RequestStatus() -> void

Request a status report from the onboard gimbal.

auto SetActiveCamera(uint8_t camera_index) -> void

Select which camera's gimbal subsequent commands target, in multi-camera setups.

Has no effect when the gimbal is directly controlled from the ground side.

ParameterTypeDescription
camera_index uint8_t Zero-based index of the camera whose gimbal should receive commands.