QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MockLinkGimbal Class Reference

Simulates MAVLink Gimbal Manager Protocol for MockLink. More...

#include <MockLinkGimbal.h>

Classes

struct  PitchYawCommand
 Last MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW received (angles in degrees, rates in deg/s). More...
struct  SetAttitudeCommand
 Last GIMBAL_MANAGER_SET_ATTITUDE received (rates in deg/s). More...

Public Types

enum class  DeltaYawMode { Legacy , Unknown , Explicit }
 Controls how GIMBAL_DEVICE_ATTITUDE_STATUS.delta_yaw and the yaw frame flags are reported. More...
enum class  InformationResponse { Accept , Nack , Silent }
 How the manager answers MAV_CMD_REQUEST_MESSAGE(GIMBAL_MANAGER_INFORMATION). More...

Public Member Functions

 MockLinkGimbal (MockLink *mockLink, bool hasRollAxis=true, bool hasPitchAxis=true, bool hasYawAxis=true, bool hasYawFollow=true, bool hasYawLock=true, bool hasRetract=true, bool hasNeutral=true, uint8_t gimbalDeviceId=MAV_COMP_ID_GIMBAL)
 ~MockLinkGimbal ()=default
void run1HzTasks ()
 Send periodic gimbal status messages (call from 1Hz tasks).
bool handleMavlinkMessage (const mavlink_message_t &msg)
void setAttitudeDeg (float rollDeg, float pitchDeg, float yawDeg)
 Pins gimbal attitude (degrees) and disables the automatic oscillation.
void setDeltaYawMode (DeltaYawMode mode)
void setDeltaYawDeg (float deltaYawDeg)
void setYawInEarthFrame (bool earthFrame)
void setPrimaryControl (uint8_t sysid, uint8_t compid)
 Overrides who holds primary control as reported in GIMBAL_MANAGER_STATUS.
void sendGimbalDeviceAttitudeStatusNow ()
 Sends GIMBAL_DEVICE_ATTITUDE_STATUS immediately instead of waiting for the 1Hz worker.
void sendGimbalManagerStatusNow ()
void sendGimbalManagerInformationWithDeviceId (uint8_t deviceIdField)
 Raw sends with protocol-violating field overrides, for exercising QGC's rejection paths.
void sendGimbalManagerStatusWithDeviceId (uint8_t deviceIdField)
void sendGimbalDeviceAttitudeStatusFrom (uint8_t sourceCompid, uint8_t deviceIdField)
void setInformationResponse (InformationResponse response)
void setIgnoreStatusIntervalRequests (int count)
 The first count MAV_CMD_SET_MESSAGE_INTERVAL requests for GIMBAL_MANAGER_STATUS are ACKed but not honoured.
QList< int > statusIntervalRequests () const
 Every GIMBAL_MANAGER_STATUS interval value (us) received, in order.
PitchYawCommand lastPitchYawCommand () const
SetAttitudeCommand lastSetAttitudeCommand () const
bool yawLock () const
uint8_t gimbalDeviceId () const

Detailed Description

Simulates MAVLink Gimbal Manager Protocol for MockLink.

Supports a Gimbal Manager on MAV_COMPID_AUTOPILOT1 with a single gimbal device with the id MAV_COMP_ID_GIMBAL. Gimbal attitude is simulated with a slow oscillation when not under manual control.

Gimbal capabilities are configurable via MockLink config.

Supported MAVLink messages / commands: MAV_CMD_REQUEST_MESSAGE (GIMBAL_MANAGER_INFORMATION) MAV_CMD_SET_MESSAGE_INTERVAL (GIMBAL_MANAGER_STATUS, GIMBAL_DEVICE_ATTITUDE_STATUS) MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW MAV_CMD_DO_GIMBAL_MANAGER_CONFIGURE GIMBAL_MANAGER_SET_ATTITUDE (rate control) Periodic sending of GIMBAL_MANAGER_STATUS and GIMBAL_DEVICE_ATTITUDE_STATUS

Definition at line 27 of file MockLinkGimbal.h.

Member Enumeration Documentation

◆ DeltaYawMode

enum class MockLinkGimbal::DeltaYawMode
strong

Controls how GIMBAL_DEVICE_ATTITUDE_STATUS.delta_yaw and the yaw frame flags are reported.

Enumerator
Legacy 

No YAW_IN_*_FRAME flag, delta_yaw = 0 (pre-extension firmware wire image).

Unknown 

Frame flag set, delta_yaw = NaN.

Explicit 

Frame flag set, delta_yaw = value from setDeltaYawDeg().

Definition at line 31 of file MockLinkGimbal.h.

◆ InformationResponse

How the manager answers MAV_CMD_REQUEST_MESSAGE(GIMBAL_MANAGER_INFORMATION).

Enumerator
Accept 

ACK and send the message.

Nack 

ACK with MAV_RESULT_UNSUPPORTED, no message.

Silent 

Swallow the request, no ACK, no message.

Definition at line 57 of file MockLinkGimbal.h.

Constructor & Destructor Documentation

◆ MockLinkGimbal()

MockLinkGimbal::MockLinkGimbal ( MockLink * mockLink,
bool hasRollAxis = true,
bool hasPitchAxis = true,
bool hasYawAxis = true,
bool hasYawFollow = true,
bool hasYawLock = true,
bool hasRetract = true,
bool hasNeutral = true,
uint8_t gimbalDeviceId = MAV_COMP_ID_GIMBAL )
explicit

Definition at line 16 of file MockLinkGimbal.cc.

References gimbalDeviceId(), and MockLinkGimbal().

Referenced by MockLinkGimbal().

◆ ~MockLinkGimbal()

MockLinkGimbal::~MockLinkGimbal ( )
default

Member Function Documentation

◆ gimbalDeviceId()

uint8_t MockLinkGimbal::gimbalDeviceId ( ) const
inline

Definition at line 111 of file MockLinkGimbal.h.

Referenced by MockLinkGimbal().

◆ handleMavlinkMessage()

bool MockLinkGimbal::handleMavlinkMessage ( const mavlink_message_t & msg)

Handle all incoming MAVLink messages for gimbal.

Returns
true if the message was handled by the gimbal

Definition at line 74 of file MockLinkGimbal.cc.

References Accept, Nack, run1HzTasks(), and Silent.

◆ lastPitchYawCommand()

MockLinkGimbal::PitchYawCommand MockLinkGimbal::lastPitchYawCommand ( ) const

Definition at line 480 of file MockLinkGimbal.cc.

◆ lastSetAttitudeCommand()

MockLinkGimbal::SetAttitudeCommand MockLinkGimbal::lastSetAttitudeCommand ( ) const

Definition at line 486 of file MockLinkGimbal.cc.

◆ run1HzTasks()

void MockLinkGimbal::run1HzTasks ( )

Send periodic gimbal status messages (call from 1Hz tasks).

Definition at line 38 of file MockLinkGimbal.cc.

Referenced by handleMavlinkMessage().

◆ sendGimbalDeviceAttitudeStatusFrom()

void MockLinkGimbal::sendGimbalDeviceAttitudeStatusFrom ( uint8_t sourceCompid,
uint8_t deviceIdField )

Definition at line 456 of file MockLinkGimbal.cc.

◆ sendGimbalDeviceAttitudeStatusNow()

void MockLinkGimbal::sendGimbalDeviceAttitudeStatusNow ( )

Sends GIMBAL_DEVICE_ATTITUDE_STATUS immediately instead of waiting for the 1Hz worker.

Definition at line 424 of file MockLinkGimbal.cc.

◆ sendGimbalManagerInformationWithDeviceId()

void MockLinkGimbal::sendGimbalManagerInformationWithDeviceId ( uint8_t deviceIdField)

Raw sends with protocol-violating field overrides, for exercising QGC's rejection paths.

Definition at line 445 of file MockLinkGimbal.cc.

◆ sendGimbalManagerStatusNow()

void MockLinkGimbal::sendGimbalManagerStatusNow ( )

Definition at line 430 of file MockLinkGimbal.cc.

◆ sendGimbalManagerStatusWithDeviceId()

void MockLinkGimbal::sendGimbalManagerStatusWithDeviceId ( uint8_t deviceIdField)

Definition at line 450 of file MockLinkGimbal.cc.

◆ setAttitudeDeg()

void MockLinkGimbal::setAttitudeDeg ( float rollDeg,
float pitchDeg,
float yawDeg )

Pins gimbal attitude (degrees) and disables the automatic oscillation.

Definition at line 390 of file MockLinkGimbal.cc.

◆ setDeltaYawDeg()

void MockLinkGimbal::setDeltaYawDeg ( float deltaYawDeg)

Definition at line 405 of file MockLinkGimbal.cc.

◆ setDeltaYawMode()

void MockLinkGimbal::setDeltaYawMode ( DeltaYawMode mode)

Definition at line 399 of file MockLinkGimbal.cc.

◆ setIgnoreStatusIntervalRequests()

void MockLinkGimbal::setIgnoreStatusIntervalRequests ( int count)

The first count MAV_CMD_SET_MESSAGE_INTERVAL requests for GIMBAL_MANAGER_STATUS are ACKed but not honoured.

Definition at line 468 of file MockLinkGimbal.cc.

◆ setInformationResponse()

void MockLinkGimbal::setInformationResponse ( InformationResponse response)

Definition at line 462 of file MockLinkGimbal.cc.

◆ setPrimaryControl()

void MockLinkGimbal::setPrimaryControl ( uint8_t sysid,
uint8_t compid )

Overrides who holds primary control as reported in GIMBAL_MANAGER_STATUS.

Definition at line 417 of file MockLinkGimbal.cc.

◆ setYawInEarthFrame()

void MockLinkGimbal::setYawInEarthFrame ( bool earthFrame)

Reporting frame for yaw: flags carry YAW_IN_EARTH_FRAME and q encodes yaw + delta_yaw. A PITCHYAW command overrides this with its own frame flags.

Definition at line 411 of file MockLinkGimbal.cc.

◆ statusIntervalRequests()

QList< int > MockLinkGimbal::statusIntervalRequests ( ) const

Every GIMBAL_MANAGER_STATUS interval value (us) received, in order.

Definition at line 474 of file MockLinkGimbal.cc.

◆ yawLock()

bool MockLinkGimbal::yawLock ( ) const

Definition at line 492 of file MockLinkGimbal.cc.


The documentation for this class was generated from the following files: