6#include <QtCore/QMutex>
65 bool hasRollAxis =
true,
66 bool hasPitchAxis =
true,
67 bool hasYawAxis =
true,
68 bool hasYawFollow =
true,
69 bool hasYawLock =
true,
70 bool hasRetract =
true,
71 bool hasNeutral =
true,
128 bool _handleGimbalManagerConfigure(
const mavlink_command_long_t &request, uint8_t senderSysid, uint8_t senderCompid);
132 void _sendGimbalManagerStatus();
133 void _sendGimbalManagerStatus(uint8_t deviceIdField);
135 void _sendStreamedManagerStatusNow();
136 void _sendGimbalDeviceAttitudeStatus();
137 void _sendGimbalDeviceAttitudeStatus(uint8_t sourceCompid, uint8_t deviceIdField);
138 void _sendGimbalManagerInformation();
139 void _sendGimbalManagerInformation(uint8_t deviceIdField);
140 void _sendGimbalDeviceInformation();
141 void _sendCommandAck(uint16_t command, uint8_t result, uint8_t sourceCompId);
144 static void _applyControlPair(
float sysidValue,
float compidValue, uint8_t senderSysid, uint8_t senderCompid,
145 uint8_t &targetSysid, uint8_t &targetCompid);
147 static void _applyControlField(
float value, uint8_t senderValue, uint8_t &target);
150 uint8_t _attitudeSourceCompid()
const {
return (_gimbalDeviceId <= 6) ?
static_cast<uint8_t
>(MAV_COMP_ID_AUTOPILOT1) : _gimbalDeviceId; }
151 uint8_t _attitudeDeviceIdField()
const {
return (_gimbalDeviceId <= 6) ? _gimbalDeviceId : 0; }
153 static constexpr int kDefaultIntervalUs = 1000000;
154 static constexpr const char* kVendorName =
"MockVendor";
155 static constexpr const char* kModelName =
"MockGimbal";
157 MockLink *_mockLink =
nullptr;
158 const uint8_t _gimbalDeviceId = MAV_COMP_ID_GIMBAL;
160 int _ignoreStatusIntervalRequests = 0;
161 QList<int> _statusIntervalRequests;
162 int _managerStatusIntervalUs = 0;
163 int _deviceAttitudeStatusIntervalUs = 0;
164 qint64 _managerStatusLastSentMs = 0;
165 qint64 _deviceAttitudeStatusLastSentMs = 0;
171 bool _manualControl =
false;
172 bool _yawLock =
false;
173 bool _yawInEarthFrame =
false;
175 float _deltaYawDeg = 0.0f;
182 mutable QMutex _stateMutex;
185 uint8_t _gimbalManagerSysidPrimary = 0;
186 uint8_t _gimbalManagerCompidPrimary = 0;
187 uint8_t _gimbalManagerSysidSecondary = 0;
188 uint8_t _gimbalManagerCompidSecondary = 0;
191 bool _hasRollAxis =
true;
192 bool _hasPitchAxis =
true;
193 bool _hasYawAxis =
true;
194 bool _hasYawFollow =
true;
195 bool _hasYawLock =
true;
196 bool _hasRetract =
true;
197 bool _hasNeutral =
true;
struct __mavlink_message mavlink_message_t
struct __mavlink_command_long_t mavlink_command_long_t
DeltaYawMode
Controls how GIMBAL_DEVICE_ATTITUDE_STATUS.delta_yaw and the yaw frame flags are reported.
@ 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().
void sendGimbalDeviceAttitudeStatusNow()
Sends GIMBAL_DEVICE_ATTITUDE_STATUS immediately instead of waiting for the 1Hz worker.
uint8_t gimbalDeviceId() const
SetAttitudeCommand lastSetAttitudeCommand() const
QList< int > statusIntervalRequests() const
Every GIMBAL_MANAGER_STATUS interval value (us) received, in order.
~MockLinkGimbal()=default
void setDeltaYawDeg(float deltaYawDeg)
void setInformationResponse(InformationResponse response)
void sendGimbalManagerStatusWithDeviceId(uint8_t deviceIdField)
void run1HzTasks()
Send periodic gimbal status messages (call from 1Hz tasks).
void setPrimaryControl(uint8_t sysid, uint8_t compid)
Overrides who holds primary control as reported in GIMBAL_MANAGER_STATUS.
bool handleMavlinkMessage(const mavlink_message_t &msg)
void sendGimbalManagerInformationWithDeviceId(uint8_t deviceIdField)
Raw sends with protocol-violating field overrides, for exercising QGC's rejection paths.
void setDeltaYawMode(DeltaYawMode mode)
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)
void setAttitudeDeg(float rollDeg, float pitchDeg, float yawDeg)
Pins gimbal attitude (degrees) and disables the automatic oscillation.
void setYawInEarthFrame(bool earthFrame)
void sendGimbalManagerStatusNow()
void setIgnoreStatusIntervalRequests(int count)
The first count MAV_CMD_SET_MESSAGE_INTERVAL requests for GIMBAL_MANAGER_STATUS are ACKed but not hon...
PitchYawCommand lastPitchYawCommand() const
InformationResponse
How the manager answers MAV_CMD_REQUEST_MESSAGE(GIMBAL_MANAGER_INFORMATION).
@ Silent
Swallow the request, no ACK, no message.
@ Nack
ACK with MAV_RESULT_UNSUPPORTED, no message.
@ Accept
ACK and send the message.
void sendGimbalDeviceAttitudeStatusFrom(uint8_t sourceCompid, uint8_t deviceIdField)
Last MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW received (angles in degrees, rates in deg/s).
Last GIMBAL_MANAGER_SET_ATTITUDE received (rates in deg/s).