57#include <QtCore/QDateTime>
61#define UPDATE_TIMER 50
62#define DEFAULT_LAT 38.965767f
63#define DEFAULT_LON -120.083923f
64#define SET_HOME_TERRAIN_ALT_MAX 10000
65#define SET_HOME_TERRAIN_ALT_MIN -500
69#define REQUEST_OPERATOR_CONTROL_ALLOW_TAKEOVER_TIMEOUT_MSECS 10000
76 int defaultComponentId,
77 MAV_AUTOPILOT firmwareType,
81 , _systemID (vehicleId)
82 , _defaultComponentId (defaultComponentId)
83 , _firmwareType (firmwareType)
84 , _vehicleType (vehicleType)
85 , _defaultCruiseSpeed (
SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble())
86 , _defaultHoverSpeed (
SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble())
89 , _vehicleFactGroup (this)
90 , _gpsFactGroup (this)
91 , _gps2FactGroup (this)
92 , _gpsAggregateFactGroup (this)
93 , _windFactGroup (this)
94 , _vibrationFactGroup (this)
95 , _temperatureFactGroup (this)
96 , _clockFactGroup (this)
97 , _setpointFactGroup (this)
98 , _distanceSensorFactGroup (this)
99 , _localPositionFactGroup (this)
100 , _localPositionSetpointFactGroup(this)
101 , _estimatorStatusFactGroup (this)
102 , _hygrometerFactGroup (this)
103 , _generatorFactGroup (this)
104 , _efiFactGroup (this)
105 , _rpmFactGroup (this)
106 , _terrainFactGroup (this)
132 SettingsManager::instance()->videoSettings()->
lowLatencyMode()->setRawValue(
true);
136 _autopilotPlugin->setParent(
this);
139 connect(&_prearmErrorTimer, &QTimer::timeout,
this, &Vehicle::_prearmErrorTimeout);
140 _prearmErrorTimer.setInterval(_prearmErrorTimeoutMSecs);
141 _prearmErrorTimer.setSingleShot(
true);
144 _mavCommandResponseCheckTimer.setSingleShot(
false);
145 _mavCommandResponseCheckTimer.setInterval(_mavCommandResponseCheckTimeoutMSecs());
146 _mavCommandResponseCheckTimer.start();
147 connect(&_mavCommandResponseCheckTimer, &QTimer::timeout,
this, &Vehicle::_sendMavCommandResponseTimeoutCheck);
151 if (!
qgcApp()->runningUnitTests() || _vehicleType != MAV_TYPE_GENERIC) {
156 for(
auto& factName: factNames()) {
160 _sendMultipleTimer.start(_sendMessageMultipleIntraMessageDelay);
161 connect(&_sendMultipleTimer, &QTimer::timeout,
this, &Vehicle::_sendMessageMultipleNext);
163 connect(&_orbitTelemetryTimer, &QTimer::timeout,
this, &Vehicle::_orbitTelemetryTimeout);
166 connect(&_csvLogTimer, &QTimer::timeout,
this, &Vehicle::_writeCsvLine);
167 _csvLogTimer.start(1000);
175 MAV_TYPE vehicleType,
179 , _defaultComponentId (MAV_COMP_ID_ALL)
180 , _offlineEditingVehicle (true)
181 , _firmwareType (firmwareType)
182 , _vehicleType (vehicleType)
183 , _defaultCruiseSpeed (
SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble())
184 , _defaultHoverSpeed (
SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble())
185 , _capabilityBitsKnown (true)
186 , _capabilityBits (MAV_PROTOCOL_CAPABILITY_MISSION_FENCE | MAV_PROTOCOL_CAPABILITY_MISSION_RALLY)
189 , _vehicleFactGroup (this)
190 , _gpsFactGroup (this)
191 , _gps2FactGroup (this)
192 , _gpsAggregateFactGroup (this)
193 , _windFactGroup (this)
194 , _vibrationFactGroup (this)
195 , _clockFactGroup (this)
196 , _distanceSensorFactGroup (this)
197 , _localPositionFactGroup (this)
198 , _localPositionSetpointFactGroup (this)
205 _commonInit(
nullptr );
207 connect(SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed(), &
Fact::rawValueChanged,
this, &Vehicle::_offlineCruiseSpeedSettingChanged);
208 connect(SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed(), &
Fact::rawValueChanged,
this, &Vehicle::_offlineHoverSpeedSettingChanged);
280 this, &Vehicle::_gotProgressUpdate);
304 _createImageProtocolManager();
305 _createStatusTextHandler();
306 _createMAVLinkLogManager();
328 QMap<QString, FactGroup*>* fwFactGroups = _firmwarePlugin->
factGroups();
330 for (
auto it = fwFactGroups->keyValueBegin(); it != fwFactGroups->keyValueEnd(); ++it) {
335 _flightTimeUpdater.setInterval(1000);
336 _flightTimeUpdater.setSingleShot(
false);
337 connect(&_flightTimeUpdater, &QTimer::timeout,
this, &Vehicle::_updateFlightTime);
342 SettingsManager::instance()->videoSettings()->
lowLatencyMode()->setRawValue(
true);
348 _createCameraManager();
353 qCDebug(VehicleLog) <<
"~Vehicle" <<
this;
359 _mavCommandResponseCheckTimer.stop();
360 _mavCommandResponseCheckTimer.disconnect();
361 _sendMultipleTimer.stop();
362 _sendMultipleTimer.disconnect();
363 _prearmErrorTimer.stop();
364 _prearmErrorTimer.disconnect();
369 delete _autopilotPlugin;
370 _autopilotPlugin =
nullptr;
373void Vehicle::_deleteCameraManager()
377 _cameraManager->disconnect();
378 delete _cameraManager;
379 _cameraManager =
nullptr;
383void Vehicle::_deleteGimbalController()
385 if (_gimbalController) {
387 _gimbalController->disconnect();
388 delete _gimbalController;
389 _gimbalController =
nullptr;
393void Vehicle::_stopCommandProcessing()
395 qCDebug(VehicleLog) <<
"_stopCommandProcessing - stopping timers and clearing pending commands";
400 _mavCommandResponseCheckTimer.stop();
401 _mavCommandResponseCheckTimer.disconnect();
402 _sendMultipleTimer.stop();
403 _sendMultipleTimer.disconnect();
406 _mavCommandList.clear();
409 for (
auto& compIdEntry : _requestMessageInfoMap) {
410 qDeleteAll(compIdEntry);
412 _requestMessageInfoMap.clear();
414 for (
auto& requestQueue : _requestMessageQueueMap) {
415 qDeleteAll(requestQueue);
417 _requestMessageQueueMap.clear();
422 _firmwareType =
static_cast<MAV_AUTOPILOT
>(varFirmwareType.toInt());
424 if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
425 _capabilityBits |= MAV_PROTOCOL_CAPABILITY_TERRAIN;
427 _capabilityBits &= ~MAV_PROTOCOL_CAPABILITY_TERRAIN;
435 _vehicleType =
static_cast<MAV_TYPE
>(varVehicleType.toInt());
439void Vehicle::_offlineCruiseSpeedSettingChanged(QVariant value)
441 _defaultCruiseSpeed = value.toDouble();
445void Vehicle::_offlineHoverSpeedSettingChanged(QVariant value)
447 _defaultHoverSpeed = value.toDouble();
456void Vehicle::resetCounters()
458 _messagesReceived = 0;
467 if (message.sysid != _systemID && message.sysid != 0) {
481 if(message.msgid == MAVLINK_MSG_ID_HEARTBEAT) {
483 _compID = message.compid;
484 _messageSeq = message.seq + 1;
487 if(_compID == message.compid) {
488 uint16_t seq_received =
static_cast<uint16_t
>(message.seq);
489 uint16_t packet_lost_count = 0;
491 if(seq_received < _messageSeq) {
492 packet_lost_count = (seq_received + 255) - _messageSeq;
494 packet_lost_count = seq_received - _messageSeq;
496 _messageSeq = message.seq + 1;
497 _messagesLost += packet_lost_count;
498 if(packet_lost_count)
509 if (!QGCCorePlugin::instance()->mavlinkMessage(
this, link, message)) {
517 _parameterManager->mavlinkMessageReceived(message);
518 (void) QMetaObject::invokeMethod(_imageProtocolManager,
"mavlinkMessageReceived", Qt::AutoConnection, message);
521 _waitForMavlinkMessageMessageReceivedHandler(message);
528 for (
FactGroup* factGroup : factGroups()) {
529 factGroup->handleMessage(
this, message);
532 this->handleMessage(
this, message);
534 switch (message.msgid) {
535 case MAVLINK_MSG_ID_HOME_POSITION:
536 _handleHomePosition(message);
538 case MAVLINK_MSG_ID_HEARTBEAT:
539 _handleHeartbeat(message);
541 case MAVLINK_MSG_ID_RADIO_STATUS:
542 _handleRadioStatus(message);
544 case MAVLINK_MSG_ID_RC_CHANNELS:
545 _handleRCChannels(message);
547 case MAVLINK_MSG_ID_BATTERY_STATUS:
548 _handleBatteryStatus(message);
550 case MAVLINK_MSG_ID_SYS_STATUS:
551 _handleSysStatus(message);
553 case MAVLINK_MSG_ID_EXTENDED_SYS_STATE:
554 _handleExtendedSysState(message);
556 case MAVLINK_MSG_ID_COMMAND_ACK:
557 _handleCommandAck(message);
559 case MAVLINK_MSG_ID_LOGGING_DATA:
560 _handleMavlinkLoggingData(message);
562 case MAVLINK_MSG_ID_LOGGING_DATA_ACKED:
563 _handleMavlinkLoggingDataAcked(message);
565 case MAVLINK_MSG_ID_GPS_RAW_INT:
566 _handleGpsRawInt(message);
568 case MAVLINK_MSG_ID_GLOBAL_POSITION_INT:
569 _handleGlobalPositionInt(message);
571 case MAVLINK_MSG_ID_CAMERA_IMAGE_CAPTURED:
572 _handleCameraImageCaptured(message);
574 case MAVLINK_MSG_ID_ADSB_VEHICLE:
577 case MAVLINK_MSG_ID_HIGH_LATENCY:
578 _handleHighLatency(message);
580 case MAVLINK_MSG_ID_HIGH_LATENCY2:
581 _handleHighLatency2(message);
583 case MAVLINK_MSG_ID_STATUSTEXT:
586 case MAVLINK_MSG_ID_ORBIT_EXECUTION_STATUS:
587 _handleOrbitExecutionStatus(message);
589 case MAVLINK_MSG_ID_PING:
590 _handlePing(link, message);
592 case MAVLINK_MSG_ID_OBSTACLE_DISTANCE:
593 _handleObstacleDistance(message);
595 case MAVLINK_MSG_ID_FENCE_STATUS:
596 _handleFenceStatus(message);
599 case MAVLINK_MSG_ID_EVENT:
600 case MAVLINK_MSG_ID_CURRENT_EVENT_SEQUENCE:
601 case MAVLINK_MSG_ID_RESPONSE_EVENT_ERROR:
605 case MAVLINK_MSG_ID_SERIAL_CONTROL:
607 mavlink_serial_control_t ser;
608 mavlink_msg_serial_control_decode(&message, &ser);
609 if (
static_cast<size_t>(ser.count) >
sizeof(ser.data)) {
610 qCWarning(VehicleLog) <<
"Invalid count for SERIAL_CONTROL, discarding." << ser.count;
613 QByteArray(
reinterpret_cast<const char*
>(ser.data), ser.count));
617 case MAVLINK_MSG_ID_AVAILABLE_MODES_MONITOR:
621 mavlink_available_modes_monitor_t availableModesMonitor;
622 mavlink_msg_available_modes_monitor_decode(&message, &availableModesMonitor);
627 case MAVLINK_MSG_ID_CURRENT_MODE:
628 _handleCurrentMode(message);
632#if !defined(QGC_NO_ARDUPILOT_DIALECT)
633 case MAVLINK_MSG_ID_CAMERA_FEEDBACK:
634 _handleCameraFeedback(message);
637 case MAVLINK_MSG_ID_LOG_ENTRY:
639 mavlink_log_entry_t log{};
640 mavlink_msg_log_entry_decode(&message, &log);
641 emit
logEntry(log.time_utc, log.size, log.id, log.num_logs, log.last_log_num);
644 case MAVLINK_MSG_ID_LOG_DATA:
646 mavlink_log_data_t log{};
647 mavlink_msg_log_data_decode(&message, &log);
648 if (
static_cast<size_t>(log.count) >
sizeof(log.data)) {
649 qCWarning(VehicleLog) <<
"Invalid count for LOG_DATA, discarding." << log.count;
651 emit
logData(log.ofs, log.id, log.count, log.data);
655 case MAVLINK_MSG_ID_MESSAGE_INTERVAL:
657 _handleMessageInterval(message);
660 case MAVLINK_MSG_ID_CONTROL_STATUS:
661 _handleControlStatus(message);
663 case MAVLINK_MSG_ID_COMMAND_LONG:
664 _handleCommandLong(message);
673#if !defined(QGC_NO_ARDUPILOT_DIALECT)
676 mavlink_camera_feedback_t feedback;
678 mavlink_msg_camera_feedback_decode(&message, &feedback);
680 QGeoCoordinate imageCoordinate((
double)feedback.lat / qPow(10.0, 7.0), (
double)feedback.lng / qPow(10.0, 7.0), feedback.alt_msl);
681 qCDebug(VehicleLog) <<
"_handleCameraFeedback coord:index" << imageCoordinate << feedback.img_idx;
688 mavlink_orbit_execution_status_t orbitStatus;
690 mavlink_msg_orbit_execution_status_decode(&message, &orbitStatus);
692 double newRadius = qAbs(
static_cast<double>(orbitStatus.radius));
694 _orbitMapCircle.
radius()->setRawValue(newRadius);
697 bool newOrbitClockwise = orbitStatus.radius > 0 ? true :
false;
702 QGeoCoordinate newCenter(
static_cast<double>(orbitStatus.x) / qPow(10.0, 7.0),
static_cast<double>(orbitStatus.y) / qPow(10.0, 7.0));
703 if (_orbitMapCircle.
center() != newCenter) {
713 _orbitTelemetryTimer.start(_orbitTelemetryTimeoutMsecs);
716void Vehicle::_orbitTelemetryTimeout()
718 _orbitActive =
false;
724 mavlink_camera_image_captured_t feedback;
726 mavlink_msg_camera_image_captured_decode(&message, &feedback);
728 QGeoCoordinate imageCoordinate((
double)feedback.lat / qPow(10.0, 7.0), (
double)feedback.lon / qPow(10.0, 7.0), feedback.alt);
729 qCDebug(VehicleLog) <<
"_handleCameraFeedback coord:index" << imageCoordinate << feedback.image_index << feedback.capture_result;
730 if (feedback.capture_result == 1) {
738 mavlink_gps_raw_int_t gpsRawInt;
739 mavlink_msg_gps_raw_int_decode(&message, &gpsRawInt);
741 _gpsRawIntMessageAvailable =
true;
743 if (gpsRawInt.fix_type >= GPS_FIX_TYPE_3D_FIX) {
744 if (!_globalPositionIntMessageAvailable) {
745 QGeoCoordinate newPosition(gpsRawInt.lat / (
double)1E7, gpsRawInt.lon / (
double)1E7, gpsRawInt.alt / 1000.0);
746 if (newPosition != _coordinate) {
747 _coordinate = newPosition;
760 mavlink_global_position_int_t globalPositionInt;
761 mavlink_msg_global_position_int_decode(&message, &globalPositionInt);
770 if (globalPositionInt.lat == 0 && globalPositionInt.lon == 0) {
774 _globalPositionIntMessageAvailable =
true;
775 QGeoCoordinate newPosition(globalPositionInt.lat / (
double)1E7, globalPositionInt.lon / (
double)1E7, globalPositionInt.alt / 1000.0);
776 if (newPosition != _coordinate) {
777 _coordinate = newPosition;
785 mavlink_high_latency_t highLatency;
786 mavlink_msg_high_latency_decode(&message, &highLatency);
788 QString previousFlightMode;
789 if (_base_mode != 0 || _custom_mode != 0){
794 _base_mode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED;
801 if (_armed !=
true) {
809 const double altitude;
811 highLatency.latitude / (double)1E7,
812 highLatency.longitude / (
double)1E7,
813 static_cast<double>(highLatency.altitude_amsl)
817 _coordinate.setLongitude(
coordinate.longitude);
821 _airSpeedFact.setRawValue((
double)highLatency.airspeed / 5.0);
823 _climbRateFact.setRawValue((
double)highLatency.climb_rate / 10.0);
824 _headingFact.setRawValue((
double)highLatency.heading * 2.0);
832 mavlink_high_latency2_t highLatency2;
833 mavlink_msg_high_latency2_decode(&message, &highLatency2);
835 QString previousFlightMode;
836 if (_base_mode != 0 || _custom_mode != 0){
842 if (highLatency2.autopilot == MAV_AUTOPILOT_ARDUPILOTMEGA) {
843 _base_mode = (uint8_t)highLatency2.custom0;
845 _base_mode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED;
852 if (highLatency2.autopilot == MAV_AUTOPILOT_ARDUPILOTMEGA) {
853 if ((uint8_t)highLatency2.custom0 & MAV_MODE_FLAG_SAFETY_ARMED && _armed !=
true) {
856 }
else if (!((uint8_t)highLatency2.custom0 & MAV_MODE_FLAG_SAFETY_ARMED) && _armed !=
false) {
862 if (_armed !=
true) {
868 _coordinate.setLatitude(highLatency2.latitude / (
double)1E7);
869 _coordinate.setLongitude(highLatency2.longitude / (
double)1E7);
870 _coordinate.setAltitude(highLatency2.altitude);
873 _airSpeedFact.setRawValue((
double)highLatency2.airspeed / 5.0);
875 _climbRateFact.setRawValue((
double)highLatency2.climb_rate / 10.0);
876 _headingFact.setRawValue((
double)highLatency2.heading * 2.0);
882 if (newOnboardControlSensorsEnabled != _onboardControlSensorsEnabled) {
883 _onboardControlSensorsEnabled = newOnboardControlSensorsEnabled;
884 _onboardControlSensorsPresent = newOnboardControlSensorsEnabled;
885 _onboardControlSensorsUnhealthy = 0;
889void Vehicle::_setCapabilities(uint64_t capabilityBits)
892 _capabilityBitsKnown =
true;
897 QString doesNotSupport(
"does not support");
899 qCDebug(VehicleLog) << QString(
"Vehicle %1 Mavlink 2.0").arg(_capabilityBits & MAV_PROTOCOL_CAPABILITY_MAVLINK2 ?
supports : doesNotSupport);
900 qCDebug(VehicleLog) << QString(
"Vehicle %1 MISSION_ITEM_INT").arg(_capabilityBits & MAV_PROTOCOL_CAPABILITY_MISSION_INT ?
supports : doesNotSupport);
901 qCDebug(VehicleLog) << QString(
"Vehicle %1 MISSION_COMMAND_INT").arg(_capabilityBits & MAV_PROTOCOL_CAPABILITY_COMMAND_INT ?
supports : doesNotSupport);
902 qCDebug(VehicleLog) << QString(
"Vehicle %1 GeoFence").arg(_capabilityBits & MAV_PROTOCOL_CAPABILITY_MISSION_FENCE ?
supports : doesNotSupport);
903 qCDebug(VehicleLog) << QString(
"Vehicle %1 RallyPoints").arg(_capabilityBits & MAV_PROTOCOL_CAPABILITY_MISSION_RALLY ?
supports : doesNotSupport);
904 qCDebug(VehicleLog) << QString(
"Vehicle %1 Terrain").arg(_capabilityBits & MAV_PROTOCOL_CAPABILITY_TERRAIN ?
supports : doesNotSupport);
910 uint8_t* pUid = (uint8_t*)(
void*)&_uid;
911 uid = uid.asprintf(
"%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
925 mavlink_extended_sys_state_t extendedState;
926 mavlink_msg_extended_sys_state_decode(&message, &extendedState);
928 switch (extendedState.landed_state) {
929 case MAV_LANDED_STATE_ON_GROUND:
933 case MAV_LANDED_STATE_TAKEOFF:
934 case MAV_LANDED_STATE_IN_AIR:
938 case MAV_LANDED_STATE_LANDING:
955bool Vehicle::_apmArmingNotRequired()
957 QString armingRequireParam(
"ARMING_REQUIRE");
964 if (message.compid != _defaultComponentId) {
968 mavlink_sys_status_t sysStatus;
969 mavlink_msg_sys_status_decode(&message, &sysStatus);
971 _sysStatusSensorInfo.update(sysStatus);
973 if (sysStatus.onboard_control_sensors_enabled & MAV_SYS_STATUS_PREARM_CHECK) {
974 if (!_readyToFlyAvailable) {
975 _readyToFlyAvailable =
true;
979 bool newReadyToFly = sysStatus.onboard_control_sensors_health & MAV_SYS_STATUS_PREARM_CHECK;
980 if (newReadyToFly != _readyToFly) {
981 _readyToFly = newReadyToFly;
986 bool newAllSensorsHealthy = (sysStatus.onboard_control_sensors_enabled & sysStatus.onboard_control_sensors_health) == sysStatus.onboard_control_sensors_enabled;
987 if (newAllSensorsHealthy != _allSensorsHealthy) {
988 _allSensorsHealthy = newAllSensorsHealthy;
992 if (_onboardControlSensorsPresent != sysStatus.onboard_control_sensors_present) {
993 _onboardControlSensorsPresent = sysStatus.onboard_control_sensors_present;
997 if (_onboardControlSensorsEnabled != sysStatus.onboard_control_sensors_enabled) {
998 _onboardControlSensorsEnabled = sysStatus.onboard_control_sensors_enabled;
1001 if (_onboardControlSensorsHealth != sysStatus.onboard_control_sensors_health) {
1002 _onboardControlSensorsHealth = sysStatus.onboard_control_sensors_health;
1010 _updateArmed(_onboardControlSensorsEnabled & MAV_SYS_STATUS_SENSOR_MOTOR_OUTPUTS);
1013 uint32_t newSensorsUnhealthy = _onboardControlSensorsEnabled & ~_onboardControlSensorsHealth;
1014 if (newSensorsUnhealthy != _onboardControlSensorsUnhealthy) {
1015 _onboardControlSensorsUnhealthy = newSensorsUnhealthy;
1022 mavlink_battery_status_t batteryStatus;
1023 mavlink_msg_battery_status_decode(&message, &batteryStatus);
1029 QString batteryMessage;
1031 switch (batteryStatus.charge_state) {
1032 case MAV_BATTERY_CHARGE_STATE_OK:
1035 case MAV_BATTERY_CHARGE_STATE_LOW:
1038 batteryMessage = tr(
"battery %1 level low");
1041 case MAV_BATTERY_CHARGE_STATE_CRITICAL:
1044 batteryMessage = tr(
"battery %1 level is critical");
1047 case MAV_BATTERY_CHARGE_STATE_EMERGENCY:
1050 batteryMessage = tr(
"battery %1 level emergency");
1053 case MAV_BATTERY_CHARGE_STATE_FAILED:
1056 batteryMessage = tr(
"battery %1 failed");
1059 case MAV_BATTERY_CHARGE_STATE_UNHEALTHY:
1062 batteryMessage = tr(
"battery %1 unhealthy");
1067 if (!batteryMessage.isEmpty()) {
1068 QString batteryIdStr(
"%1");
1070 batteryIdStr = batteryIdStr.arg(batteryStatus.id);
1072 batteryIdStr = batteryIdStr.arg(
"");
1074 _say(tr(
"warning"));
1075 _say(QStringLiteral(
"%1 %2 ").arg(_vehicleIdSpeech()).arg(batteryMessage.arg(batteryIdStr)));
1081 if (homeCoord != _homePosition) {
1082 _homePosition = homeCoord;
1083 qCDebug(VehicleLog) <<
"new home location set at coordinate: " << homeCoord;
1090 mavlink_home_position_t homePos;
1092 mavlink_msg_home_position_decode(&message, &homePos);
1094 QGeoCoordinate newHomePosition (homePos.latitude / 10000000.0,
1095 homePos.longitude / 10000000.0,
1096 homePos.altitude / 1000.0);
1100void Vehicle::_updateArmed(
bool armed)
1102 if (_armed !=
armed) {
1107 _trajectoryPoints->
start();
1108 _flightTimerStart();
1109 _clearCameraTriggerPoints();
1113 _trajectoryPoints->
stop();
1116 if(SettingsManager::instance()->videoSettings()->disableWhenDisarmed()->rawValue().toBool()) {
1117 SettingsManager::instance()->videoSettings()->
streamEnabled()->setRawValue(
false);
1118 VideoManager::instance()->stopVideo();
1128 qCDebug(VehicleLog) <<
"_handlePing: primary link gone!";
1132 mavlink_ping_t ping;
1135 mavlink_msg_ping_decode(&message, &ping);
1137 if ((ping.target_system == 0) && (ping.target_component == 0)) {
1142 sharedLink->mavlinkChannel(),
1152void Vehicle::_handleEvent(uint8_t comp_id, std::unique_ptr<events::parser::ParsedEvent> event)
1155 switch (events::externalLogLevel(event->eventData().log_levels)) {
1156 case events::Log::Emergency: severity = MAV_SEVERITY_EMERGENCY;
break;
1157 case events::Log::Alert: severity = MAV_SEVERITY_ALERT;
break;
1158 case events::Log::Critical: severity = MAV_SEVERITY_CRITICAL;
break;
1159 case events::Log::Error: severity = MAV_SEVERITY_ERROR;
break;
1160 case events::Log::Warning: severity = MAV_SEVERITY_WARNING;
break;
1161 case events::Log::Notice: severity = MAV_SEVERITY_NOTICE;
break;
1162 case events::Log::Info: severity = MAV_SEVERITY_INFO;
break;
1167 if (event->group() ==
"health" || event->group() ==
"arming_check") {
1171 if (event->group() ==
"calibration") {
1173 QSharedPointer<events::parser::ParsedEvent>{
new events::parser::ParsedEvent{*
event}});
1179 if (event->group() ==
"default" && severity != -1) {
1180 std::string message =
event->message();
1181 std::string description =
event->description();
1183 if (event->type() ==
"append_health_and_arming_messages" && event->numArguments() > 0) {
1184 uint32_t
customMode =
event->argumentValue(0).value.val_uint32_t;
1185 const QSharedPointer<EventHandler>& eventHandler = _events[comp_id];
1186 int modeGroup = eventHandler->getModeGroup(
customMode);
1187 std::vector<events::HealthAndArmingChecks::Check> checks = eventHandler->healthAndArmingCheckResults().checks(modeGroup);
1188 QList<std::string> messageChecks;
1189 for (
const auto& check : checks) {
1190 if (events::externalLogLevel(check.log_levels) <= events::Log::Warning) {
1191 messageChecks.append(check.message);
1194 if (messageChecks.empty()) {
1196 for (
const auto& check : checks) {
1197 messageChecks.append(check.message);
1200 if (!message.empty() && !messageChecks.empty()) {
1203 if (messageChecks.size() == 1) {
1204 message += messageChecks[0];
1206 for (
const auto& messageCheck : messageChecks) {
1207 message +=
"- " + messageCheck +
"\n";
1212 if (!message.empty()) {
1213 const QString text = QString::fromStdString(message);
1215 if (
px4Firmware() && text.startsWith(QStringLiteral(
"[cal]"))) {
1219 m_statusTextHandler->
handleHTMLEscapedTextMessage(
static_cast<MAV_COMPONENT
>(comp_id),
static_cast<MAV_SEVERITY
>(severity), text, QString::fromStdString(description));
1226 auto eventData = _events.find(compid);
1227 if (eventData == _events.end()) {
1230 auto sendRequestEventMessageCB = [
this](
const mavlink_request_event_t& msg) {
1236 sharedLink->mavlinkChannel(),
1243 QString profile =
"dev";
1245 QSharedPointer<EventHandler> eventHandler{
new EventHandler(
this, profile,
1246 std::bind(&Vehicle::_handleEvent,
this, compid, std::placeholders::_1),
1247 sendRequestEventMessageCB,
1249 eventData = _events.insert(compid, eventHandler);
1253 const QSharedPointer<EventHandler>& evtHandler = _events[compid];
1254 _healthAndArmingCheckReport.update(compid, evtHandler->healthAndArmingCheckResults(),
1255 evtHandler->getModeGroup(_has_custom_mode_user_intention ? _custom_mode_user_intention : _custom_mode));
1258 const QSharedPointer<EventHandler>& evtHandler = _events[compid];
1259 if (evtHandler->healthAndArmingCheckResultsValid()) {
1260 _healthAndArmingCheckReport.update(compid, evtHandler->healthAndArmingCheckResults(),
1261 evtHandler->getModeGroup(_has_custom_mode_user_intention ? _custom_mode_user_intention : _custom_mode));
1265 return *eventData->data();
1270 _eventHandler(compid).
setMetadata(metadataJsonFileName);
1273 int modeGroups[2]{-1, -1};
1275 for (
size_t i = 0; i <
sizeof(modeGroups)/
sizeof(modeGroups[0]); ++i) {
1277 uint32_t custom_mode;
1278 if (setFlightModeCustom(modes[i], &base_mode, &custom_mode)) {
1279 modeGroups[i] = _eventHandler(compid).
getModeGroup(custom_mode);
1280 if (modeGroups[i] == -1) {
1281 qCDebug(VehicleLog) <<
"Failed to get mode group for mode" << modes[i] <<
"(Might not be in metadata)";
1285 _healthAndArmingCheckReport.
setModeGroups(modeGroups[0], modeGroups[1]);
1289 MAV_CMD_RUN_PREARM_CHECKS,
1294 const QString &metadataJsonFileName)
1304 if (message.compid != _defaultComponentId) {
1308 mavlink_heartbeat_t heartbeat;
1310 mavlink_msg_heartbeat_decode(&message, &heartbeat);
1312 bool newArmed = heartbeat.base_mode & MAV_MODE_FLAG_DECODE_POSITION_SAFETY;
1318 if (!_apmArmingNotRequired() || !(_onboardControlSensorsPresent & MAV_SYS_STATUS_SENSOR_MOTOR_OUTPUTS)) {
1320 _updateArmed(newArmed);
1324 _updateArmed(newArmed);
1327 if (heartbeat.base_mode != _base_mode || heartbeat.custom_mode != _custom_mode) {
1328 QString previousFlightMode;
1329 if (_base_mode != 0 || _custom_mode != 0){
1334 _base_mode = heartbeat.base_mode;
1335 _custom_mode = heartbeat.custom_mode;
1344 mavlink_current_mode_t currentMode;
1345 mavlink_msg_current_mode_decode(&message, ¤tMode);
1346 if (currentMode.intended_custom_mode != 0) {
1347 _has_custom_mode_user_intention =
true;
1349 bool changed = _custom_mode_user_intention != currentMode.intended_custom_mode;
1350 _custom_mode_user_intention = currentMode.intended_custom_mode;
1351 if (changed && previousFlightMode !=
flightMode()) {
1361 mavlink_radio_status_t rstatus;
1362 mavlink_msg_radio_status_decode(&message, &rstatus);
1364 int rssi = rstatus.rssi;
1365 int remrssi = rstatus.remrssi;
1366 int lnoise = (int)(int8_t)rstatus.noise;
1367 int rnoise = (int)(int8_t)rstatus.remnoise;
1369 if (message.sysid ==
'3' && message.compid ==
'D') {
1380 rssi = qMin(qMax(qRound(
static_cast<qreal
>(rssi) / 1.9 - 127.0), - 120), 0);
1381 remrssi = qMin(qMax(qRound(
static_cast<qreal
>(remrssi) / 1.9 - 127.0), - 120), 0);
1383 rssi = (int)(int8_t)rstatus.rssi;
1384 remrssi = (int)(int8_t)rstatus.remrssi;
1387 if(_telemetryLRSSI != rssi) {
1388 _telemetryLRSSI = rssi;
1391 if(_telemetryRRSSI != remrssi) {
1392 _telemetryRRSSI = remrssi;
1395 if(_telemetryRXErrors != rstatus.rxerrors) {
1396 _telemetryRXErrors = rstatus.rxerrors;
1399 if(_telemetryFixed != rstatus.fixed) {
1400 _telemetryFixed = rstatus.fixed;
1403 if(_telemetryTXBuffer != rstatus.txbuf) {
1404 _telemetryTXBuffer = rstatus.txbuf;
1407 if(_telemetryLNoise != lnoise) {
1408 _telemetryLNoise = lnoise;
1411 if(_telemetryRNoise != rnoise) {
1412 _telemetryRNoise = rnoise;
1419 mavlink_rc_channels_t channels;
1421 mavlink_msg_rc_channels_decode(&message, &channels);
1423 QVector<uint16_t> rawChannelValues({
1433 channels.chan10_raw,
1434 channels.chan11_raw,
1435 channels.chan12_raw,
1436 channels.chan13_raw,
1437 channels.chan14_raw,
1438 channels.chan15_raw,
1439 channels.chan16_raw,
1440 channels.chan17_raw,
1441 channels.chan18_raw,
1445 int validChannelCount = 0;
1446 int firstUnusedChannelIndex = -1;
1447 for (
int i=0; i<rawChannelValues.size(); i++) {
1448 if (rawChannelValues[i] != UINT16_MAX) {
1449 validChannelCount++;
1450 }
else if (firstUnusedChannelIndex == -1) {
1451 firstUnusedChannelIndex = i;
1454 if (firstUnusedChannelIndex != -1 && firstUnusedChannelIndex != validChannelCount) {
1455 qCWarning(VehicleLog) <<
"Non-contiguous RC channels detected. Not publishing data from RC_CHANNELS.";
1459 QVector<int> channelValues(validChannelCount);
1460 for (
int channelIndex = 0; channelIndex < validChannelCount; ++channelIndex) {
1461 int channelValue = rawChannelValues[channelIndex];
1463 channelValues[channelIndex] = std::min(std::max(channelValue, 1000), 2000);
1473 qCDebug(VehicleLog) <<
"sendMessageOnLinkThreadSafe" << link <<
"not connected!";
1481 uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
1482 int len = mavlink_msg_to_send_buffer(buffer, &message);
1493 uint8_t frameType = 0;
1494 if (_vehicleType == MAV_TYPE_SUBMARINE) {
1510void Vehicle::_activeVehicleChanged(
Vehicle *newActiveVehicle)
1512 _isActiveVehicle = newActiveVehicle ==
this;
1517 return _homePosition;
1524 MAV_CMD_COMPONENT_ARM_DISARM,
1526 armed ? 1.0f : 0.0f);
1532 MAV_CMD_COMPONENT_ARM_DISARM,
1551 return _firmwarePlugin->
flightMode(_base_mode, _custom_mode);
1554bool Vehicle::setFlightModeCustom(
const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode)
1562 uint32_t custom_mode;
1564 if (setFlightModeCustom(
flightMode, &base_mode, &custom_mode)) {
1567 qCDebug(VehicleLog) <<
"setFlightMode: primary link gone!";
1571 uint8_t newBaseMode = _base_mode & ~MAV_MODE_FLAG_DECODE_POSITION_CUSTOM_MODE;
1575 newBaseMode |= base_mode;
1579 MAV_CMD_DO_SET_MODE,
1581 MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
1587 sharedLink->mavlinkChannel(),
1595 qCWarning(VehicleLog) <<
"FirmwarePlugin::setFlightMode failed, flightMode:" <<
flightMode;
1600QVariantList Vehicle::links()
const {
1603 for(
const auto &item: _links )
1604 ret << QVariant::fromValue(item);
1614 qCDebug(VehicleLog) <<
"requestDataStream: primary link gone!";
1619 mavlink_request_data_stream_t dataStream;
1621 memset(&dataStream, 0,
sizeof(dataStream));
1623 dataStream.req_stream_id = stream;
1624 dataStream.req_message_rate = rate;
1625 dataStream.start_stop = 1;
1626 dataStream.target_system =
id();
1627 dataStream.target_component = _defaultComponentId;
1631 sharedLink->mavlinkChannel(),
1643void Vehicle::_sendMessageMultipleNext()
1645 if (_nextSendMessageMultipleIndex < _sendMessageMultipleList.count()) {
1646 uint32_t msgId = _sendMessageMultipleList[_nextSendMessageMultipleIndex].message.msgid;
1647 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(msgId);
1648 QString msgName = info ? info->name : QString::number(msgId);
1649 qCDebug(VehicleLog) <<
"_sendMessageMultipleNext:" << msgName;
1656 if (--_sendMessageMultipleList[_nextSendMessageMultipleIndex].retryCount <= 0) {
1657 _sendMessageMultipleList.removeAt(_nextSendMessageMultipleIndex);
1659 _nextSendMessageMultipleIndex++;
1663 if (_nextSendMessageMultipleIndex >= _sendMessageMultipleList.count()) {
1664 _nextSendMessageMultipleIndex = 0;
1670 SendMessageMultipleInfo_t info;
1672 info.message = message;
1673 info.retryCount = _sendMessageMultipleRetries;
1675 _sendMessageMultipleList.append(info);
1678void Vehicle::_missionManagerError(
int errorCode,
const QString& errorMsg)
1680 Q_UNUSED(errorCode);
1681 qgcApp()->showAppMessage(tr(
"Mission transfer failed. Error: %1").arg(errorMsg));
1684void Vehicle::_geoFenceManagerError(
int errorCode,
const QString& errorMsg)
1686 Q_UNUSED(errorCode);
1687 qgcApp()->showAppMessage(tr(
"GeoFence transfer failed. Error: %1").arg(errorMsg));
1690void Vehicle::_rallyPointManagerError(
int errorCode,
const QString& errorMsg)
1692 Q_UNUSED(errorCode);
1693 qgcApp()->showAppMessage(tr(
"Rally Point transfer failed. Error: %1").arg(errorMsg));
1696void Vehicle::_clearCameraTriggerPoints()
1701void Vehicle::_flightTimerStart()
1703 _flightTimer.start();
1704 _flightTimeUpdater.start();
1709void Vehicle::_flightTimerStop()
1711 _flightTimeUpdater.stop();
1714void Vehicle::_updateFlightTime()
1719void Vehicle::_gotProgressUpdate(
float progressValue)
1725 progressValue = 0.f;
1727 _loadProgress = progressValue;
1731void Vehicle::_firstMissionLoadComplete()
1736void Vehicle::_firstGeoFenceLoadComplete()
1741void Vehicle::_firstRallyPointLoadComplete()
1744 _initialPlanRequestComplete =
true;
1748void Vehicle::_parametersReady(
bool parametersReady)
1750 qCDebug(VehicleLog) <<
"_parametersReady" << parametersReady;
1753 _sendQGCTimeToVehicle();
1755 _sendQGCTimeToVehicle();
1756 if (parametersReady) {
1758 _setupAutoDisarmSignalling();
1768void Vehicle::_sendQGCTimeToVehicle()
1772 qCDebug(VehicleLog) <<
"_sendQGCTimeToVehicle: primary link gone!";
1777 mavlink_system_time_t cmd;
1780 cmd.time_unix_usec = QDateTime::currentDateTime().currentMSecsSinceEpoch()*1000;
1782 cmd.time_boot_ms = 0;
1785 sharedLink->mavlinkChannel(),
1792void Vehicle::_remoteControlRSSIChanged(uint8_t rssi)
1796 if(_rcRSSI != 255) {
1803 if(_rcRSSIstore == 255.) {
1804 _rcRSSIstore = (double)rssi;
1807 _rcRSSIstore = (_rcRSSIstore * 0.9f) + ((
float)rssi * 0.1);
1808 uint8_t filteredRSSI = (uint8_t)ceil(_rcRSSIstore);
1809 if(_rcRSSIstore < 0.1) {
1812 if(_rcRSSI != filteredRSSI) {
1813 _rcRSSI = filteredRSSI;
1821 bool isActiveVehicle = (MultiVehicleManager::instance()->activeVehicle() ==
this);
1822 bool joystickEnabled = isActiveVehicle && JoystickManager::instance()->activeJoystickEnabledForActiveVehicle();
1823 if (!joystickEnabled) {
1825 static_cast<float>(roll),
1826 static_cast<float>(pitch),
1827 static_cast<float>(yaw),
1828 static_cast<float>(thrust),
1830 NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN);
1834void Vehicle::_say(
const QString& text)
1885QString Vehicle::_vehicleIdSpeech()
1887 if (MultiVehicleManager::instance()->vehicles()->count() > 1) {
1888 return tr(
"Vehicle %1 ").arg(
id());
1894void Vehicle::_handleFlightModeChanged(
const QString& flightMode)
1896 _say(tr(
"%1 %2 flight mode").arg(_vehicleIdSpeech()).arg(
flightMode));
1900void Vehicle::_announceArmedChanged(
bool armed)
1902 _say(QString(
"%1 %2").arg(_vehicleIdSpeech()).arg(
armed ? tr(
"armed") : tr(
"disarmed")));
1905 _armedPosition = _coordinate;
2005 double maxDistance = SettingsManager::instance()->flyViewSettings()->
maxGoToLocationDistance()->rawValue().toDouble();
2006 if (
coordinate().distanceTo(gotoCoord) > maxDistance) {
2045 qgcApp()->showAppMessage(QStringLiteral(
"Orbit mode not supported by Vehicle."));
2054 static_cast<float>(radius),
2055 static_cast<float>(qQNaN()),
2056 static_cast<float>(ORBIT_YAW_BEHAVIOUR_UNCHANGED),
2057 static_cast<float>(qQNaN()),
2058 centerCoord.latitude(), centerCoord.longitude(),
static_cast<float>(amslAltitude));
2064 static_cast<float>(radius),
2065 static_cast<float>(qQNaN()),
2066 static_cast<float>(ORBIT_YAW_BEHAVIOUR_UNCHANGED),
2067 static_cast<float>(qQNaN()),
2068 static_cast<float>(centerCoord.latitude()),
2069 static_cast<float>(centerCoord.longitude()),
2070 static_cast<float>(amslAltitude));
2076 if (!centerCoord.isValid()) {
2079 if (!_vehicleSupports->
roiMode()) {
2080 qgcApp()->showAppMessage(QStringLiteral(
"ROI mode not supported by Vehicle."));
2096 QList<QGeoCoordinate> rgCoord;
2097 rgCoord.append(centerCoord);
2103 if ((centerCoord.altitude() >= 83000) || (centerCoord.altitude() <= -83000)) {
2106 _sendROICommand(centerCoord, MAV_FRAME_GLOBAL_RELATIVE_ALT,
static_cast<float>(centerCoord.altitude()));
2113void Vehicle::_roiTerrainReceived(
bool success, QList<double> heights)
2123 roiAltitude =
static_cast<float>(heights[0]);
2125 qCDebug(VehicleLog) <<
"_roiTerrainReceived: terrain query failed, falling back to home altitude";
2126 roiAltitude =
static_cast<float>(_homePosition.altitude());
2129 qCDebug(VehicleLog) <<
"guidedModeROI: lat" <<
_roiCoordinate.latitude() <<
"lon" <<
_roiCoordinate.longitude() <<
"terrainAltAMSL" << roiAltitude <<
"success" << success;
2136void Vehicle::_sendROICommand(
const QGeoCoordinate& coord, MAV_FRAME frame,
float altitude)
2141 MAV_CMD_DO_SET_ROI_LOCATION,
2144 static_cast<float>(qQNaN()),
2145 static_cast<float>(qQNaN()),
2146 static_cast<float>(qQNaN()),
2147 static_cast<float>(qQNaN()),
2154 MAV_CMD_DO_SET_ROI_LOCATION,
2156 static_cast<float>(qQNaN()),
2157 static_cast<float>(qQNaN()),
2158 static_cast<float>(qQNaN()),
2159 static_cast<float>(qQNaN()),
2160 static_cast<float>(coord.latitude()),
2161 static_cast<float>(coord.longitude()),
2168 if (!_vehicleSupports->
roiMode()) {
2169 qgcApp()->showAppMessage(QStringLiteral(
"ROI mode not supported by Vehicle."));
2175 MAV_CMD_DO_SET_ROI_NONE,
2178 static_cast<float>(qQNaN()),
2179 static_cast<float>(qQNaN()),
2180 static_cast<float>(qQNaN()),
2181 static_cast<float>(qQNaN()),
2182 static_cast<double>(qQNaN()),
2183 static_cast<double>(qQNaN()),
2184 static_cast<float>(qQNaN()));
2188 MAV_CMD_DO_SET_ROI_NONE,
2190 static_cast<float>(qQNaN()),
2191 static_cast<float>(qQNaN()),
2192 static_cast<float>(qQNaN()),
2193 static_cast<float>(qQNaN()),
2194 static_cast<float>(qQNaN()),
2195 static_cast<float>(qQNaN()),
2196 static_cast<float>(qQNaN()));
2203 qgcApp()->showAppMessage(tr(
"Change Heading not supported by Vehicle."));
2213 qgcApp()->showAppMessage(QStringLiteral(
"Pause not supported by vehicle."));
2223 MAV_CMD_DO_GO_AROUND,
2225 static_cast<float>(climbOutAltitude));
2247 _defaultComponentId,
2248 MAV_CMD_COMPONENT_ARM_DISARM,
2258 MAV_CMD_AIRFRAME_CONFIGURATION,
2268 MAV_CMD_AIRFRAME_CONFIGURATION,
2285 qCDebug(VehicleLog) <<
"setCurrentMissionSequence: primary link gone!";
2292 mavlink_msg_mission_set_current_pack_chan(
2295 sharedLink->mavlinkChannel(),
2297 static_cast<uint8_t
>(
id()),
2299 static_cast<uint16_t
>(seq));
2303 MAV_CMD_DO_SET_MISSION_CURRENT,
2305 static_cast<uint16_t
>(seq)
2309void Vehicle::sendMavCommand(
int compId, MAV_CMD command,
bool showError,
float param1,
float param2,
float param3,
float param4,
float param5,
float param6,
float param7)
2317 param1, param2, param3, param4, param5, param6, param7);
2320void Vehicle::sendMavCommandDelayed(
int compId, MAV_CMD command,
bool showError,
int milliseconds,
float param1,
float param2,
float param3,
float param4,
float param5,
float param6,
float param7)
2322 QTimer::singleShot(milliseconds,
this, [=,
this] {
sendMavCommand(
compId, command, showError, param1, param2, param3, param4, param5, param6, param7); });
2325void Vehicle::sendCommand(
int compId,
int command,
bool showError,
double param1,
double param2,
double param3,
double param4,
double param5,
double param6,
double param7)
2328 compId,
static_cast<MAV_CMD
>(command),
2330 static_cast<float>(param1),
2331 static_cast<float>(param2),
2332 static_cast<float>(param3),
2333 static_cast<float>(param4),
2334 static_cast<float>(param5),
2335 static_cast<float>(param6),
2336 static_cast<float>(param7));
2347 param1, param2, param3, param4, param5, param6, param7);
2350void Vehicle::sendMavCommandInt(
int compId, MAV_CMD command, MAV_FRAME frame,
bool showError,
float param1,
float param2,
float param3,
float param4,
double param5,
double param6,
float param7)
2358 param1, param2, param3, param4, param5, param6, param7);
2361void Vehicle::sendMavCommandIntWithHandler(
const MavCmdAckHandlerInfo_t* ackHandlerInfo,
int compId, MAV_CMD command, MAV_FRAME frame,
float param1,
float param2,
float param3,
float param4,
double param5,
double param6,
float param7)
2369 param1, param2, param3, param4, param5, param6, param7);
2381 auto* vehicle = data->
vehicle;
2384 switch (ack.result) {
2385 case MAV_RESULT_ACCEPTED:
2388 case MAV_RESULT_UNSUPPORTED:
2391 data->unsupported_lambda();
2394 if (data->showError) {
2403void Vehicle::sendMavCommandWithLambdaFallback(std::function<
void()> lambda,
int compId, MAV_CMD command,
bool showError,
float param1,
float param2,
float param3,
float param4,
float param5,
float param6,
float param7)
2408 switch (instanceData->getCommandSupported(command)) {
2433 data->vehicle =
this;
2434 data->showError = showError;
2435 data->unsupported_lambda = lambda;
2469 for (
int i=0; i<_mavCommandList.count(); i++) {
2470 const MavCommandListEntry_t& entry = _mavCommandList[i];
2471 if (entry.targetCompId == targetCompId && entry.command == command) {
2479int Vehicle::_mavCommandResponseCheckTimeoutMSecs()
2482 return qgcApp()->runningUnitTests() ? 50 : 500;
2485int Vehicle::_mavCommandAckTimeoutMSecs()
2511 case MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES:
2512 case MAV_CMD_REQUEST_MESSAGE:
2513 case MAV_CMD_PREFLIGHT_STORAGE:
2514 case MAV_CMD_RUN_PREARM_CHECKS:
2528 case MAV_CMD_DO_MOTOR_TEST:
2530 case MAV_CMD_SET_MESSAGE_INTERVAL:
2544 float param1,
float param2,
float param3,
float param4,
double param5,
double param6,
float param7)
2551 bool compIdAll = targetCompId == MAV_COMP_ID_ALL;
2554 qCDebug(VehicleLog) << QStringLiteral(
"_sendMavCommandWorker failing %1").arg(compIdAll ?
"MAV_COMP_ID_ALL not supported" :
"duplicate command") << rawCommandName << param1 << param2 << param3 << param4 << param5 << param6 << param7;
2558 mavlink_command_ack_t ack = {};
2559 ack.result = MAV_RESULT_FAILED;
2562 emit
mavCommandResult(_systemID, targetCompId, command, MAV_RESULT_FAILED, failureCode);
2565 qgcApp()->showAppMessage(tr(
"Unable to send command: %1.").arg(compIdAll ? tr(
"Internal error - MAV_COMP_ID_ALL not supported") : tr(
"Waiting on previous response to same command.")));
2573 qCDebug(VehicleLog) <<
"_sendMavCommandWorker: primary link gone!";
2577 mavlink_command_ack_t ack = {};
2578 ack.command = command;
2579 ack.result = MAV_RESULT_FAILED;
2582 emit
mavCommandResult(_systemID, targetCompId, command, MAV_RESULT_FAILED, failureCode);
2586 qgcApp()->showAppMessage(tr(
"Unable to send command: Vehicle is not connected."));
2591 MavCommandListEntry_t entry;
2593 entry.useCommandInt = commandInt;
2594 entry.targetCompId = targetCompId;
2595 entry.command = command;
2596 entry.frame = frame;
2597 entry.showError = showError;
2598 entry.ackHandlerInfo = {};
2599 if (ackHandlerInfo) {
2600 entry.ackHandlerInfo = *ackHandlerInfo;
2602 entry.rgParam1 = param1;
2603 entry.rgParam2 = param2;
2604 entry.rgParam3 = param3;
2605 entry.rgParam4 = param4;
2606 entry.rgParam5 = param5;
2607 entry.rgParam6 = param6;
2608 entry.rgParam7 = param7;
2610 entry.ackTimeoutMSecs = sharedLink->linkConfiguration()->isHighLatency() ? _mavCommandAckTimeoutMSecsHighLatency : _mavCommandAckTimeoutMSecs();
2611 entry.elapsedTimer.start();
2613 QString commandStr = _formatMavCommand(command, param1);
2614 qCDebug(VehicleLog) <<
"Sending" << commandStr <<
"param1-7:" << command << param1 << param2 << param3 << param4 << param5 << param6 << param7;
2616 _mavCommandList.append(entry);
2622 MavCommandListEntry_t commandEntry = _mavCommandList[index];
2627 if (++_mavCommandList[index].tryCount > commandEntry.maxTries) {
2628 QString logMsg = QStringLiteral(
"Giving up sending command after max retries: %1").arg(rawCommandName);
2631 if (commandEntry.command == MAV_CMD_REQUEST_MESSAGE) {
2632 int requestedMsgId =
static_cast<int>(commandEntry.rgParam1);
2633 const mavlink_message_info_t *info = mavlink_get_message_info_by_id(requestedMsgId);
2634 logMsg += QStringLiteral(
" requesting: %1").arg(info->name);
2637 qCWarning(VehicleLog) << logMsg;
2639 _mavCommandList.removeAt(index);
2640 if (commandEntry.ackHandlerInfo.resultHandler) {
2641 mavlink_command_ack_t ack = {};
2642 ack.result = MAV_RESULT_FAILED;
2647 if (commandEntry.showError) {
2648 qgcApp()->showAppMessage(tr(
"Vehicle did not respond to command: %1").arg(friendlyName));
2653 if (commandEntry.tryCount > 1 && !
px4Firmware() && commandEntry.command == MAV_CMD_START_RX_PAIR) {
2659 QString commandStr = _formatMavCommand(commandEntry.command, commandEntry.rgParam1);
2660 qCDebug(VehicleLog) <<
"Sending" << commandStr <<
"tryCount:param1-7" << commandEntry.tryCount << commandEntry.rgParam1 << commandEntry.rgParam2 << commandEntry.rgParam3 << commandEntry.rgParam4 << commandEntry.rgParam5 << commandEntry.rgParam6 << commandEntry.rgParam7;
2664 qCDebug(VehicleLog) <<
"_sendMavCommandFromList: primary link gone!";
2670 if (commandEntry.useCommandInt) {
2671 mavlink_command_int_t cmd;
2673 memset(&cmd, 0,
sizeof(cmd));
2674 cmd.target_system = _systemID;
2675 cmd.target_component = commandEntry.targetCompId;
2676 cmd.command = commandEntry.command;
2677 cmd.frame = commandEntry.frame;
2678 cmd.param1 = commandEntry.rgParam1;
2679 cmd.param2 = commandEntry.rgParam2;
2680 cmd.param3 = commandEntry.rgParam3;
2681 cmd.param4 = commandEntry.rgParam4;
2682 cmd.x = commandEntry.frame == MAV_FRAME_MISSION ? commandEntry.rgParam5 : commandEntry.rgParam5 * 1e7;
2683 cmd.y = commandEntry.frame == MAV_FRAME_MISSION ? commandEntry.rgParam6 : commandEntry.rgParam6 * 1e7;
2684 cmd.z = commandEntry.rgParam7;
2687 sharedLink->mavlinkChannel(),
2691 mavlink_command_long_t cmd;
2693 memset(&cmd, 0,
sizeof(cmd));
2694 cmd.target_system = _systemID;
2695 cmd.target_component = commandEntry.targetCompId;
2696 cmd.command = commandEntry.command;
2697 cmd.confirmation = 0;
2698 cmd.param1 = commandEntry.rgParam1;
2699 cmd.param2 = commandEntry.rgParam2;
2700 cmd.param3 = commandEntry.rgParam3;
2701 cmd.param4 = commandEntry.rgParam4;
2702 cmd.param5 =
static_cast<float>(commandEntry.rgParam5);
2703 cmd.param6 =
static_cast<float>(commandEntry.rgParam6);
2704 cmd.param7 = commandEntry.rgParam7;
2707 sharedLink->mavlinkChannel(),
2715void Vehicle::_sendMavCommandResponseTimeoutCheck(
void)
2717 if (_mavCommandList.isEmpty()) {
2722 for (
int i=_mavCommandList.count()-1; i>=0; i--) {
2723 MavCommandListEntry_t& commandEntry = _mavCommandList[i];
2724 if (commandEntry.elapsedTimer.elapsed() > commandEntry.ackTimeoutMSecs) {
2737 if (friendlyName.isEmpty()) {
2738 commandStr = rawName;
2740 commandStr = QStringLiteral(
"%1 (%2)").arg(friendlyName).arg(rawName);
2743 switch (ack.result) {
2744 case MAV_RESULT_TEMPORARILY_REJECTED:
2745 qgcApp()->showAppMessage(tr(
"%1 command temporarily rejected").arg(commandStr));
2747 case MAV_RESULT_DENIED:
2748 qgcApp()->showAppMessage(tr(
"%1 command denied").arg(commandStr));
2750 case MAV_RESULT_UNSUPPORTED:
2751 qgcApp()->showAppMessage(tr(
"%1 command not supported").arg(commandStr));
2753 case MAV_RESULT_FAILED:
2754 qgcApp()->showAppMessage(tr(
"%1 command failed").arg(commandStr));
2764 mavlink_command_ack_t ack;
2765 mavlink_msg_command_ack_decode(&message, &ack);
2768 QString logMsg = QStringLiteral(
"_handleCommandAck command(%1) result(%2)").arg(rawCommandName).arg(
QGCMAVLink::mavResultToString(
static_cast<MAV_RESULT
>(ack.result)));
2771 if (ack.command == MAV_CMD_REQUEST_MESSAGE) {
2773 if (entryIndex != -1) {
2774 int requestedMsgId =
static_cast<int>(_mavCommandList[entryIndex].rgParam1);
2775 const mavlink_message_info_t *info = mavlink_get_message_info_by_id(requestedMsgId);
2776 QString msgName = info ? QString(info->name) : QString::number(requestedMsgId);
2777 logMsg += QStringLiteral(
" msgId(%1)").arg(msgName);
2781 qCDebug(VehicleLog) << logMsg;
2783 if (ack.command == MAV_CMD_DO_SET_ROI_LOCATION) {
2784 if (ack.result == MAV_RESULT_ACCEPTED) {
2785 _isROIEnabled =
true;
2790 if (ack.command == MAV_CMD_DO_SET_ROI_NONE) {
2791 if (ack.result == MAV_RESULT_ACCEPTED) {
2792 _isROIEnabled =
false;
2797 if (ack.command == MAV_CMD_PREFLIGHT_STORAGE) {
2798 auto result = (ack.result == MAV_RESULT_ACCEPTED);
2802#if !defined(QGC_NO_ARDUPILOT_DIALECT)
2803 if (ack.command == MAV_CMD_FLASH_BOOTLOADER && ack.result == MAV_RESULT_ACCEPTED) {
2804 qgcApp()->showAppMessage(tr(
"Bootloader flash succeeded"));
2809 if (entryIndex != -1) {
2810 if (ack.result == MAV_RESULT_IN_PROGRESS) {
2811 MavCommandListEntry_t commandEntry;
2812 if (
px4Firmware() && ack.command == MAV_CMD_DO_AUTOTUNE_ENABLE) {
2814 commandEntry = _mavCommandList.takeAt(entryIndex);
2817 MavCommandListEntry_t& commandEntryRef = _mavCommandList[entryIndex];
2818 commandEntryRef.maxTries = 1;
2819 commandEntryRef.elapsedTimer.start();
2820 commandEntry = commandEntryRef;
2823 if (commandEntry.ackHandlerInfo.progressHandler) {
2824 (*commandEntry.ackHandlerInfo.progressHandler)(commandEntry.ackHandlerInfo.progressHandlerData, message.compid, ack);
2827 MavCommandListEntry_t commandEntry = _mavCommandList.takeAt(entryIndex);
2829 if (commandEntry.ackHandlerInfo.resultHandler) {
2830 (*commandEntry.ackHandlerInfo.resultHandler)(commandEntry.ackHandlerInfo.resultHandlerData, message.compid, ack,
MavCmdResultCommandResultOnly);
2832 if (commandEntry.showError) {
2839 qCDebug(VehicleLog) <<
"_handleCommandAck Ack not in list" << rawCommandName;
2843 if (ack.command == MAV_CMD_SET_MESSAGE_INTERVAL) {
2848void Vehicle::_removeRequestMessageInfo(
int compId,
int msgId)
2850 if (_requestMessageInfoMap.contains(
compId) && _requestMessageInfoMap[
compId].contains(msgId)) {
2851 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(msgId);
2852 const QString msgName = info ? QString(info->name) : QString::number(msgId);
2854 delete _requestMessageInfoMap[
compId][msgId];
2855 _requestMessageInfoMap[
compId].remove(msgId);
2857 <<
"removed active request compId:msgId"
2860 <<
"remainingActive"
2861 << _requestMessageInfoMap[
compId].count();
2862 if (_requestMessageInfoMap[
compId].isEmpty()) {
2863 _requestMessageInfoMap.remove(
compId);
2865 _requestMessageSendNextFromQueue(
compId);
2867 qWarning() <<
"compId:msgId not found" <<
compId << msgId;
2871bool Vehicle::_requestMessageDuplicate(
int compId,
int msgId)
const
2873 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(msgId);
2874 const QString msgName = info ? QString(info->name) : QString::number(msgId);
2876 if (_requestMessageInfoMap.contains(
compId) && _requestMessageInfoMap[
compId].contains(msgId)) {
2877 qCDebug(VehicleLog) <<
"duplicate in active map - compId:msgId" <<
compId << msgName;
2881 if (_requestMessageQueueMap.contains(
compId)) {
2882 for (
const RequestMessageInfo_t* requestMessageInfo : _requestMessageQueueMap[
compId]) {
2883 if (requestMessageInfo->msgId == msgId) {
2884 qCDebug(VehicleLog) <<
"duplicate in queue - compId:msgId" <<
compId << msgName;
2893void Vehicle::_requestMessageSendNow(RequestMessageInfo_t* requestMessageInfo)
2895 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(requestMessageInfo->msgId);
2896 const QString msgName = info ? QString(info->name) : QString::number(requestMessageInfo->msgId);
2898 _requestMessageInfoMap[requestMessageInfo->compId][requestMessageInfo->msgId] = requestMessageInfo;
2900 const int queueDepth = _requestMessageQueueMap.contains(requestMessageInfo->compId)
2901 ? _requestMessageQueueMap[requestMessageInfo->compId].count()
2904 <<
"sending now compId:msgId"
2905 << requestMessageInfo->compId
2911 handlerInfo.
resultHandler = _requestMessageCmdResultHandler;
2917 requestMessageInfo->compId,
2918 MAV_CMD_REQUEST_MESSAGE,
2920 requestMessageInfo->msgId,
2921 requestMessageInfo->param1,
2922 requestMessageInfo->param2,
2923 requestMessageInfo->param3,
2924 requestMessageInfo->param4,
2925 requestMessageInfo->param5,
2929void Vehicle::_requestMessageSendNextFromQueue(
int compId)
2931 if (_requestMessageInfoMap.contains(
compId) && !_requestMessageInfoMap[
compId].isEmpty()) {
2933 <<
"active request still in progress for compId"
2936 << _requestMessageInfoMap[
compId].count();
2940 if (!_requestMessageQueueMap.contains(
compId) || _requestMessageQueueMap[
compId].isEmpty()) {
2941 qCDebug(VehicleLog) <<
"no queued request for compId" <<
compId;
2942 _requestMessageQueueMap.remove(
compId);
2946 RequestMessageInfo_t* requestMessageInfo = _requestMessageQueueMap[
compId].takeFirst();
2947 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(requestMessageInfo->msgId);
2948 const QString msgName = info ? QString(info->name) : QString::number(requestMessageInfo->msgId);
2949 const int remainingQueue = _requestMessageQueueMap[
compId].count();
2951 <<
"dequeued next request compId:msgId"
2957 if (_requestMessageQueueMap[
compId].isEmpty()) {
2958 _requestMessageQueueMap.remove(
compId);
2961 _requestMessageSendNow(requestMessageInfo);
2965void Vehicle::_waitForMavlinkMessageMessageReceivedHandler(
const mavlink_message_t& message)
2967 if (_requestMessageInfoMap.contains(message.compid) && _requestMessageInfoMap[message.compid].contains(message.msgid)) {
2968 auto pInfo = _requestMessageInfoMap[message.compid][message.msgid];
2969 auto resultHandler = pInfo->resultHandler;
2970 auto resultHandlerData = pInfo->resultHandlerData;
2972 pInfo->messageReceived =
true;
2973 pInfo->message = message;
2975 const mavlink_message_info_t *info = mavlink_get_message_info_by_id(message.msgid);
2976 QString msgName = info ? QString(info->name) : QString::number(message.msgid);
2977 const int activeCount = _requestMessageInfoMap.contains(message.compid) ? _requestMessageInfoMap[message.compid].count() : 0;
2978 const int queueDepth = _requestMessageQueueMap.contains(message.compid) ? _requestMessageQueueMap[message.compid].count() : 0;
2980 <<
"message received - compId:msgId"
2988 if (pInfo->commandAckReceived) {
2989 _removeRequestMessageInfo(message.compid, message.msgid);
2995 for (
auto& compIdEntry : _requestMessageInfoMap) {
2996 for (
auto requestMessageInfo : compIdEntry) {
2999 const int messageWaitTimeoutMs =
qgcApp()->runningUnitTests() ? 500 : 1000;
3000 if (requestMessageInfo->messageWaitElapsedTimer.isValid() && requestMessageInfo->messageWaitElapsedTimer.elapsed() > messageWaitTimeoutMs) {
3001 auto resultHandler = requestMessageInfo->resultHandler;
3002 auto resultHandlerData = requestMessageInfo->resultHandlerData;
3004 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(requestMessageInfo->msgId);
3005 QString msgName = info ? info->name : QString::number(requestMessageInfo->msgId);
3006 const int queueDepth = _requestMessageQueueMap.contains(requestMessageInfo->compId) ? _requestMessageQueueMap[requestMessageInfo->compId].count() : 0;
3008 <<
"request message timed out - compId:msgId"
3009 << requestMessageInfo->compId
3014 _removeRequestMessageInfo(requestMessageInfo->compId, requestMessageInfo->msgId);
3026void Vehicle::_requestMessageCmdResultHandler(
void* resultHandlerData_, [[maybe_unused]]
int compId,
const mavlink_command_ack_t& ack, MavCmdResultFailureCode_t failureCode)
3028 auto requestMessageInfo =
static_cast<RequestMessageInfo_t*
>(resultHandlerData_);
3029 auto resultHandler = requestMessageInfo->resultHandler;
3030 auto resultHandlerData = requestMessageInfo->resultHandlerData;
3031 Vehicle* vehicle = requestMessageInfo->vehicle;
3035 qCDebug(VehicleLog) <<
"Vehicle destroyed before callback - skipping";
3036 delete requestMessageInfo;
3040 requestMessageInfo->commandAckReceived =
true;
3041 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(requestMessageInfo->msgId);
3042 const QString msgName = info ? QString(info->name) : QString::number(requestMessageInfo->msgId);
3044 <<
"ack for requestMessage compId:msgId"
3045 << requestMessageInfo->compId
3052 if (ack.result != MAV_RESULT_ACCEPTED) {
3056 switch (failureCode) {
3068 vehicle->_removeRequestMessageInfo(requestMessageInfo->compId, requestMessageInfo->msgId);
3070 (*resultHandler)(resultHandlerData,
static_cast<MAV_RESULT
>(ack.result), requestMessageFailureCode, ackMessage);
3075 if (requestMessageInfo->messageReceived) {
3076 auto message = requestMessageInfo->message;
3077 vehicle->_removeRequestMessageInfo(requestMessageInfo->compId, requestMessageInfo->msgId);
3083 requestMessageInfo->messageWaitElapsedTimer.start();
3086void Vehicle::_requestMessageWaitForMessageResultHandler(
void* resultHandlerData,
bool noResponsefromVehicle,
const mavlink_message_t& message)
3088 RequestMessageInfo_t* pInfo =
static_cast<RequestMessageInfo_t*
>(resultHandlerData);
3090 pInfo->messageReceived =
true;
3091 if (pInfo->commandAckReceived) {
3095 pInfo->message = message;
3099void Vehicle::requestMessage(RequestMessageResultHandler resultHandler,
void* resultHandlerData,
int compId,
int messageId,
float param1,
float param2,
float param3,
float param4,
float param5)
3101 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(messageId);
3102 const QString msgName = info ? QString(info->name) : QString::number(messageId);
3103 const int activeCount = _requestMessageInfoMap.contains(
compId) ? _requestMessageInfoMap[
compId].count() : 0;
3104 const int queueDepth = _requestMessageQueueMap.contains(
compId) ? _requestMessageQueueMap[
compId].count() : 0;
3106 <<
"incoming request compId:msgId"
3114 auto requestMessageInfo =
new RequestMessageInfo_t;
3115 requestMessageInfo->vehicle =
this;
3116 requestMessageInfo->compId =
compId;
3117 requestMessageInfo->msgId = messageId;
3118 requestMessageInfo->param1 = param1;
3119 requestMessageInfo->param2 = param2;
3120 requestMessageInfo->param3 = param3;
3121 requestMessageInfo->param4 = param4;
3122 requestMessageInfo->param5 = param5;
3123 requestMessageInfo->resultHandler = resultHandler;
3124 requestMessageInfo->resultHandlerData = resultHandlerData;
3126 if (_requestMessageDuplicate(
compId, messageId)) {
3128 qCWarning(VehicleLog) <<
"failing exact duplicate compId:msgId" <<
compId << msgName;
3129 (*resultHandler)(resultHandlerData,
3133 delete requestMessageInfo;
3137 if (_requestMessageInfoMap.contains(
compId) && !_requestMessageInfoMap[
compId].isEmpty()) {
3138 _requestMessageQueueMap[
compId].append(requestMessageInfo);
3140 <<
"queued request compId:msgId"
3144 << _requestMessageQueueMap[
compId].count();
3148 _requestMessageSendNow(requestMessageInfo);
3155 if (!_prearmError.isEmpty()) {
3156 _prearmErrorTimer.start();
3160void Vehicle::_prearmErrorTimeout()
3167 _firmwareMajorVersion = majorVersion;
3168 _firmwareMinorVersion = minorVersion;
3169 _firmwarePatchVersion = patchVersion;
3170 _firmwareVersionType = versionType;
3176 _firmwareCustomMajorVersion = majorVersion;
3177 _firmwareCustomMinorVersion = minorVersion;
3178 _firmwareCustomPatchVersion = patchVersion;
3187void Vehicle::_rebootCommandResultHandler(
void* resultHandlerData,
int ,
const mavlink_command_ack_t& ack, MavCmdResultFailureCode_t failureCode)
3191 if (ack.result != MAV_RESULT_ACCEPTED) {
3192 switch (failureCode) {
3194 qCDebug(VehicleLog) << QStringLiteral(
"MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN error(%1)").arg(ack.result);
3197 qCDebug(VehicleLog) <<
"MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN failed: no response from vehicle";
3200 qCDebug(VehicleLog) <<
"MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN failed: duplicate command";
3203 qgcApp()->showAppMessage(tr(
"Vehicle reboot failed."));
3222 qCDebug(VehicleLog) <<
"startCalibration: primary link gone!";
3288 sharedLink->mavlinkChannel(),
3292 MAV_CMD_PREFLIGHT_CALIBRATION,
3294 param1, param2, param3, param4, param5, param6, param7);
3301 MAV_CMD_PREFLIGHT_CALIBRATION,
3315 MAV_CMD_PREFLIGHT_UAVCAN,
3323 MAV_CMD_PREFLIGHT_UAVCAN,
3338 sendMavCommand(_defaultComponentId, MAV_CMD_DO_MOTOR_TEST, showError, motor, MOTOR_TEST_THROTTLE_PERCENT, percent, timeoutSecs, 0, MOTOR_TEST_ORDER_BOARD);
3353 if (_offlineEditingVehicle) {
3356 qCWarning(VehicleLog) <<
"Call to Vehicle::setOfflineEditingDefaultComponentId on vehicle which is not offline";
3364 MAV_CMD_DO_VTOL_TRANSITION,
3373 sendMavCommand(_defaultComponentId, MAV_CMD_LOGGING_START,
false );
3378 sendMavCommand(_defaultComponentId, MAV_CMD_LOGGING_STOP,
false );
3381void Vehicle::_ackMavlinkLogData(uint16_t sequence)
3385 qCDebug(VehicleLog) <<
"_ackMavlinkLogData: primary link gone!";
3390 mavlink_logging_ack_t ack;
3392 memset(&ack, 0,
sizeof(ack));
3393 ack.sequence = sequence;
3394 ack.target_component = _defaultComponentId;
3395 ack.target_system =
id();
3396 mavlink_msg_logging_ack_encode_chan(
3399 sharedLink->mavlinkChannel(),
3407 mavlink_logging_data_t log;
3408 mavlink_msg_logging_data_decode(&message, &log);
3409 if (
static_cast<size_t>(log.length) >
sizeof(log.data)) {
3410 qWarning() <<
"Invalid length for LOGGING_DATA, discarding." << log.length;
3412 emit
mavlinkLogData(
this, log.target_system, log.target_component, log.sequence,
3413 log.first_message_offset, QByteArray((
const char*)log.data, log.length),
false);
3419 mavlink_logging_data_acked_t log;
3420 mavlink_msg_logging_data_acked_decode(&message, &log);
3421 _ackMavlinkLogData(log.sequence);
3422 if (
static_cast<size_t>(log.length) >
sizeof(log.data)) {
3423 qWarning() <<
"Invalid length for LOGGING_DATA_ACKED, discarding." << log.length;
3425 emit
mavlinkLogData(
this, log.target_system, log.target_component, log.sequence,
3426 log.first_message_offset, QByteArray((
const char*)log.data, log.length),
false);
3499 if(_firmwarePlugin) {
3502 static QVariantList emptyList;
3506void Vehicle::_setupAutoDisarmSignalling()
3523 return fact->rawValue().toDouble() > 0;
3529void Vehicle::_updateDistanceHeadingHome()
3547void Vehicle::_updateHeadingToNextWP()
3552 if(llist.size()>currentIndex && currentIndex!=-1
3553 && llist[currentIndex]->coordinate().longitude()!=0.0
3563void Vehicle::_updateMissionItemIndex()
3567 unsigned offset = 0;
3575void Vehicle::_updateDistanceHeadingGCS()
3577 QGeoCoordinate gcsPosition = QGCPositionManager::instance()->gcsPosition();
3578 if (
coordinate().isValid() && gcsPosition.isValid()) {
3587void Vehicle::_updateHomepoint()
3590 const bool updateHomeActivated = SettingsManager::instance()->flyViewSettings()->
updateHomePosition()->rawValue().toBool();
3591 if(setHomeCmdSupported && updateHomeActivated){
3592 QGeoCoordinate gcsPosition = QGCPositionManager::instance()->gcsPosition();
3593 if (
coordinate().isValid() && gcsPosition.isValid()) {
3595 MAV_CMD_DO_SET_HOME,
false,
3598 static_cast<float>(gcsPosition.latitude()) ,
3599 static_cast<float>(gcsPosition.longitude()),
3600 static_cast<float>(gcsPosition.altitude()));
3605void Vehicle::_updateHobbsMeter()
3612 _initialPlanRequestComplete =
true;
3626void Vehicle::_vehicleParamLoaded(
bool ready)
3635void Vehicle::_mavlinkMessageStatus(
int uasId, uint64_t totalSent, uint64_t totalReceived, uint64_t totalLoss,
float lossPercent)
3637 if(uasId == _systemID) {
3638 _mavlinkSentCount = totalSent;
3639 _mavlinkReceivedCount = totalReceived;
3640 _mavlinkLossCount = totalLoss;
3641 _mavlinkLossPercent = lossPercent;
3653 return _firmwarePlugin->
versionCompare(
this, major, minor, patch);
3659 setLiveUpdates(liveUpdate);
3686void Vehicle::_setMessageInterval(
int messageId,
int rate)
3689 MAV_CMD_SET_MESSAGE_INTERVAL,
3695QString Vehicle::_formatMavCommand(MAV_CMD command,
float param1)
3699 if (command == MAV_CMD_REQUEST_MESSAGE && param1 > 0) {
3700 const mavlink_message_info_t* info = mavlink_get_message_info_by_id(
static_cast<uint32_t
>(param1));
3701 QString param1Str = info ? QString(
"%1(%2)").arg(param1).arg(info->name) : QString::number(param1);
3702 return QString(
"%1: %2").arg(commandName).arg(param1Str);
3704 return QString(
"%1: %2").arg(commandName).arg(param1);
3712void Vehicle::_initializeCsv()
3714 if (!SettingsManager::instance()->mavlinkSettings()->saveCsvTelemetry()->rawValue().toBool()) {
3717 QString now = QDateTime::currentDateTime().toString(
"yyyy-MM-dd hh-mm-ss");
3718 QString fileName = QString(
"%1 vehicle%2.csv").arg(now).arg(_systemID);
3719 QDir saveDir(SettingsManager::instance()->appSettings()->telemetrySavePath());
3720 _csvLogFile.setFileName(saveDir.absoluteFilePath(fileName));
3722 if (!_csvLogFile.open(QIODevice::Append)) {
3723 qCWarning(VehicleLog) <<
"unable to open file for csv logging, Stopping csv logging!";
3727 QTextStream stream(&_csvLogFile);
3728 QStringList allFactNames;
3729 allFactNames << factNames();
3730 for (
const QString& groupName: factGroupNames()) {
3731 for(
const QString& factName: getFactGroup(groupName)->factNames()){
3732 allFactNames << QString(
"%1.%2").arg(groupName, factName);
3735 qCDebug(VehicleLog) <<
"Facts logged to csv:" << allFactNames;
3736 stream <<
"Timestamp," << allFactNames.join(
",") <<
"\n";
3739void Vehicle::_writeCsvLine()
3742 if(!_csvLogFile.isOpen() &&
3743 (_armed || SettingsManager::instance()->mavlinkSettings()->telemetrySaveNotArmed()->rawValue().toBool())){
3747 if(!_csvLogFile.isOpen()){
3751 QStringList allFactValues;
3752 QTextStream stream(&_csvLogFile);
3755 allFactValues << QDateTime::currentDateTime().toString(QStringLiteral(
"yyyy-MM-dd hh:mm:ss.zzz"));
3757 for (
const QString& factName : factNames()) {
3758 allFactValues << getFact(factName)->cookedValueString();
3761 for (
const QString& groupName: factGroupNames()) {
3762 for (
const QString& factName : getFactGroup(groupName)->factNames()) {
3763 allFactValues << getFactGroup(groupName)->getFact(factName)->cookedValueString();
3767 stream << allFactValues.join(
",") <<
"\n";
3772 if (coord.isValid()) {
3786 QList<QGeoCoordinate> rgCoord;
3787 rgCoord.append(coord);
3793void Vehicle::_doSetHomeTerrainReceived(
bool success, QList<double> heights)
3796 double terrainAltitude = heights[0];
3801 MAV_CMD_DO_SET_HOME,
3806 static_cast<float>(qQNaN()),
3812 qCDebug(VehicleLog) <<
"_doSetHomeTerrainReceived: internal error, elevation data out of limits ";
3814 qCDebug(VehicleLog) <<
"_doSetHomeTerrainReceived: internal error, cached home coordinate is not valid";
3817 qgcApp()->showAppMessage(tr(
"Set Home failed, terrain data not available for selected coordinate"));
3824void Vehicle::_updateAltAboveTerrain()
3828 const qreal minimumDistanceTraveled = 2;
3829 const float minimumAltitudeChanged = 0.5f;
3834 int altitudeAboveTerrQueryMinInterval = 500;
3840 if (_coordinate.isValid()) {
3860 QList<QGeoCoordinate> rgCoord;
3861 rgCoord.append(_coordinate);
3867void Vehicle::_altitudeAboveTerrainReceived(
bool success, QList<double> heights)
3870 qCDebug(VehicleLog) <<
"_altitudeAboveTerrainReceived: terrain data not available for vehicle coordinate";
3873 double terrainAltitude = heights[0];
3874 double altitudeAboveTerrain = altitudeAMSL()->rawValue().toDouble() - terrainAltitude;
3883 mavlink_obstacle_distance_t o;
3884 mavlink_msg_obstacle_distance_decode(&message, &o);
3885 _objectAvoidance->
update(&o);
3890 mavlink_fence_status_t fenceStatus;
3892 mavlink_msg_fence_status_decode(&message, &fenceStatus);
3894 qCDebug(VehicleLog) <<
"_handleFenceStatus breach_status" << fenceStatus.breach_status;
3896 static qint64 lastUpdate = 0;
3897 qint64 now = QDateTime::currentMSecsSinceEpoch();
3898 if (fenceStatus.breach_status == 1) {
3899 if (now - lastUpdate > 3000) {
3901 QString breachTypeStr;
3902 switch (fenceStatus.breach_type) {
3903 case FENCE_BREACH_NONE:
3905 case FENCE_BREACH_MINALT:
3906 breachTypeStr = tr(
"minimum altitude");
3908 case FENCE_BREACH_MAXALT:
3909 breachTypeStr = tr(
"maximum altitude");
3911 case FENCE_BREACH_BOUNDARY:
3912 breachTypeStr = tr(
"boundary");
3918 _say(breachTypeStr +
" " + tr(
"fence breached"));
3930void Vehicle::sendParamMapRC(
const QString& paramName,
double scale,
double centerValue,
int tuningID,
double minValue,
double maxValue)
3934 qCDebug(VehicleLog) <<
"sendParamMapRC: primary link gone!";
3940 char param_id_cstr[MAVLINK_MSG_PARAM_MAP_RC_FIELD_PARAM_ID_LEN] = {};
3942 for (
unsigned int i = 0; i <
sizeof(param_id_cstr); i++) {
3943 if ((
int)i < paramName.length()) {
3944 param_id_cstr[i] = paramName.toLatin1()[i];
3950 sharedLink->mavlinkChannel(),
3953 MAV_COMP_ID_AUTOPILOT1,
3956 static_cast<uint8_t
>(tuningID),
3957 static_cast<float>(centerValue),
3958 static_cast<float>(scale),
3959 static_cast<float>(minValue),
3960 static_cast<float>(maxValue));
3968 qCDebug(VehicleLog)<<
"clearAllParamMapRC: primary link gone!";
3972 char param_id_cstr[MAVLINK_MSG_PARAM_MAP_RC_FIELD_PARAM_ID_LEN] = {};
3974 for (
int i = 0; i < 3; i++) {
3978 sharedLink->mavlinkChannel(),
3981 MAV_COMP_ID_AUTOPILOT1,
3990void Vehicle::sendJoystickDataThreadSafe(
float roll,
float pitch,
float yaw,
float thrust, quint16 buttons, quint16 buttons2,
float pitchExtension,
float rollExtension,
float aux1,
float aux2,
float aux3,
float aux4,
float aux5,
float aux6)
3994 qCDebug(VehicleLog)<<
"sendJoystickDataThreadSafe: primary link gone!";
3998 if (sharedLink->linkConfiguration()->isHighLatency()) {
4004 float axesScaling = 1.0 * 1000.0;
4005 uint8_t extensions = 0;
4008 float newRollCommand = roll * axesScaling;
4009 float newPitchCommand = pitch * axesScaling;
4010 float newYawCommand = yaw * axesScaling;
4011 float newThrustCommand = thrust * axesScaling;
4014 float incomingExtensionValues[] = { pitchExtension, rollExtension, aux1, aux2, aux3, aux4, aux5, aux6 };
4015 int16_t outgoingExtensionValues[std::size(incomingExtensionValues)];
4016 for (
size_t i = 0; i < std::size(incomingExtensionValues); i++) {
4017 int16_t scaledValue = 0;
4018 if (!qIsNaN(incomingExtensionValues[i])) {
4019 scaledValue =
static_cast<int16_t
>(incomingExtensionValues[i] * axesScaling);
4020 extensions |= (1 << i);
4022 outgoingExtensionValues[i] = scaledValue;
4024 mavlink_msg_manual_control_pack_chan(
4027 sharedLink->mavlinkChannel(),
4029 static_cast<uint8_t
>(_systemID),
4030 static_cast<int16_t
>(newPitchCommand),
4031 static_cast<int16_t
>(newRollCommand),
4032 static_cast<int16_t
>(newThrustCommand),
4033 static_cast<int16_t
>(newYawCommand),
4036 outgoingExtensionValues[0],
4037 outgoingExtensionValues[1],
4038 outgoingExtensionValues[2],
4039 outgoingExtensionValues[3],
4040 outgoingExtensionValues[4],
4041 outgoingExtensionValues[5],
4042 outgoingExtensionValues[6],
4043 outgoingExtensionValues[7]
4051 MAV_CMD_DO_DIGICAM_CONTROL,
4060 _defaultComponentId,
4071 qCDebug(VehicleLog) <<
"setEstimatorOrigin: primary link gone!";
4076 mavlink_msg_set_gps_global_origin_pack_chan(
4079 sharedLink->mavlinkChannel(),
4082 centerCoord.latitude() * 1e7,
4083 centerCoord.longitude() * 1e7,
4084 centerCoord.altitude() * 1e3,
4085 static_cast<float>(qQNaN())
4093 MAV_CMD_START_RX_PAIR,
4101 mavlink_message_interval_t data;
4102 mavlink_msg_message_interval_decode(&message, &data);
4104 const MavCompMsgId compMsgId = {message.compid, data.message_id};
4105 const int32_t rate = ( data.interval_us > 0 ) ? 1000000.0 / data.interval_us : data.interval_us;
4107 if(!_mavlinkMsgIntervals.contains(compMsgId) || _mavlinkMsgIntervals.value(compMsgId) != rate)
4109 (void) _mavlinkMsgIntervals.insert(compMsgId, rate);
4116 _timerRevertAllowTakeover.stop();
4117 _timerRevertAllowTakeover.setSingleShot(
true);
4118 _timerRevertAllowTakeover.setInterval(operatorControlTakeoverTimeoutMsecs());
4120 disconnect(&_timerRevertAllowTakeover, &QTimer::timeout,
nullptr,
nullptr);
4122 connect(&_timerRevertAllowTakeover, &QTimer::timeout,
this, [
this](){
4127 _timerRevertAllowTakeover.start();
4132 int safeRequestTimeoutSecs;
4133 int requestTimeoutSecsMin = SettingsManager::instance()->flyViewSettings()->
requestControlTimeout()->cookedMin().toInt();
4134 int requestTimeoutSecsMax = SettingsManager::instance()->flyViewSettings()->
requestControlTimeout()->cookedMax().toInt();
4135 if (requestTimeoutSecs >= requestTimeoutSecsMin && requestTimeoutSecs <= requestTimeoutSecsMax) {
4136 safeRequestTimeoutSecs = requestTimeoutSecs;
4139 safeRequestTimeoutSecs = SettingsManager::instance()->flyViewSettings()->
requestControlTimeout()->cookedDefaultValue().toInt();
4142 const MavCmdAckHandlerInfo_t handlerInfo = {&Vehicle::_requestOperatorControlAckHandler,
this,
nullptr,
nullptr};
4145 _defaultComponentId,
4146 MAV_CMD_REQUEST_OPERATOR_CONTROL,
4149 allowOverride ? 1 : 0,
4150 safeRequestTimeoutSecs
4154 if (requestTimeoutSecs > 0) {
4155 requestOperatorControlStartTimer(requestTimeoutSecs * 1000);
4159void Vehicle::_requestOperatorControlAckHandler(
void* resultHandlerData,
int compId,
const mavlink_command_ack_t& ack, MavCmdResultFailureCode_t failureCode)
4165 switch (failureCode) {
4167 qgcApp()->showAppMessage(tr(
"Waiting for previous operator control request"));
4170 qgcApp()->showAppMessage(tr(
"No response to operator control request"));
4181 if (ack.result == MAV_RESULT_ACCEPTED) {
4182 qCDebug(VehicleLog) <<
"Operator control request accepted";
4184 qCDebug(VehicleLog) <<
"Operator control request rejected";
4188void Vehicle::requestOperatorControlStartTimer(
int requestTimeoutMsecs)
4191 _sendControlRequestAllowed =
false;
4194 _timerRequestOperatorControl.stop();
4195 _timerRequestOperatorControl.setSingleShot(
true);
4196 _timerRequestOperatorControl.setInterval(requestTimeoutMsecs);
4198 disconnect(&_timerRequestOperatorControl, &QTimer::timeout,
nullptr,
nullptr);
4199 connect(&_timerRequestOperatorControl, &QTimer::timeout,
this, [
this](){
4200 _sendControlRequestAllowed =
true;
4203 _timerRequestOperatorControl.start();
4208 mavlink_control_status_t controlStatus;
4209 mavlink_msg_control_status_decode(&message, &controlStatus);
4211 bool updateControlStatusSignals =
false;
4212 if (_gcsControlStatusFlags != controlStatus.flags) {
4213 _gcsControlStatusFlags = controlStatus.flags;
4214 _gcsControlStatusFlags_SystemManager = controlStatus.flags & GCS_CONTROL_STATUS_FLAGS_SYSTEM_MANAGER;
4215 _gcsControlStatusFlags_TakeoverAllowed = controlStatus.flags & GCS_CONTROL_STATUS_FLAGS_TAKEOVER_ALLOWED;
4216 updateControlStatusSignals =
true;
4219 if (_sysid_in_control != controlStatus.sysid_in_control) {
4220 _sysid_in_control = controlStatus.sysid_in_control;
4221 updateControlStatusSignals =
true;
4224 if (!_firstControlStatusReceived) {
4225 _firstControlStatusReceived =
true;
4226 updateControlStatusSignals =
true;
4229 if (updateControlStatusSignals) {
4235 if (!sendControlRequestAllowed() && _gcsControlStatusFlags_TakeoverAllowed) {
4236 disconnect(&_timerRequestOperatorControl, &QTimer::timeout,
nullptr,
nullptr);
4237 _sendControlRequestAllowed =
true;
4242void Vehicle::_handleCommandRequestOperatorControl(
const mavlink_command_long_t commandLong)
4249 mavlink_command_long_t commandLong;
4250 mavlink_msg_command_long_decode(&message, &commandLong);
4255 if (commandLong.command == MAV_CMD_REQUEST_OPERATOR_CONTROL) {
4256 _handleCommandRequestOperatorControl(commandLong);
4260int Vehicle::operatorControlTakeoverTimeoutMsecs()
const
4265void Vehicle::_requestMessageMessageIntervalResultHandler(
void* resultHandlerData, MAV_RESULT result, RequestMessageResultHandlerFailureCode_t failureCode,
const mavlink_message_t& message)
4269 mavlink_message_interval_t data;
4270 mavlink_msg_message_interval_decode(&message, &data);
4273 (void) vehicle->_unsupportedMessageIds.insert(message.compid, data.message_id);
4277void Vehicle::_requestMessageInterval(uint8_t compId, uint16_t msgId)
4279 if(!_unsupportedMessageIds.contains(
compId, msgId))
4282 &Vehicle::_requestMessageMessageIntervalResultHandler,
4285 MAVLINK_MSG_ID_MESSAGE_INTERVAL,
4294 const MavCompMsgId compMsgId = {
compId, msgId};
4296 if(_mavlinkMsgIntervals.contains(compMsgId))
4298 rate = _mavlinkMsgIntervals.value(compMsgId);
4302 _requestMessageInterval(
compId, msgId);
4307void Vehicle::_setMessageRateCommandResultHandler(
void* resultHandlerData,
int compId,
const mavlink_command_ack_t& ack, MavCmdResultFailureCode_t failureCode)
4314 vehicle->_requestMessageInterval(
compId, vehicle->_lastSetMsgIntervalMsgId);
4322 &Vehicle::_setMessageRateCommandResultHandler,
4328 const float interval = (rate > 0) ? 1000000.0 / rate : rate;
4329 _lastSetMsgIntervalMsgId = msgId;
4334 MAV_CMD_SET_MESSAGE_INTERVAL,
4350 return QStringLiteral(
"No Failure");
4352 return QStringLiteral(
"Command Error");
4354 return QStringLiteral(
"Command Not Acked");
4356 return QStringLiteral(
"Message Not Received");
4358 return QStringLiteral(
"Duplicate Request");
4360 return QStringLiteral(
"Unknown (%1)").arg(failureCode);
4369 return QStringLiteral(
"Command Result Only");
4371 return QStringLiteral(
"No Response To Command");
4373 return QStringLiteral(
"Duplicate Command");
4375 return QStringLiteral(
"Unknown (%1)").arg(failureCode);
4388 MAV_CMD_FLASH_BOOTLOADER,
4400 MAV_CMD_DO_AUX_FUNCTION,
4403 enable ? MAV_CMD_DO_AUX_FUNCTION_SWITCH_LEVEL_HIGH : MAV_CMD_DO_AUX_FUNCTION_SWITCH_LEVEL_LOW);
4412void Vehicle::resetAllMessages() { m_statusTextHandler->
resetAllMessages(); }
4414void Vehicle::clearMessages() { m_statusTextHandler->
clearMessages(); }
4415bool Vehicle::messageTypeNone()
const {
return m_statusTextHandler->
messageTypeNone(); }
4416bool Vehicle::messageTypeNormal()
const {
return m_statusTextHandler->
messageTypeNormal(); }
4417bool Vehicle::messageTypeWarning()
const {
return m_statusTextHandler->
messageTypeWarning(); }
4418bool Vehicle::messageTypeError()
const {
return m_statusTextHandler->
messageTypeError(); }
4419int Vehicle::messageCount()
const {
return m_statusTextHandler->
messageCount(); }
4420QString Vehicle::formattedMessages()
const {
return m_statusTextHandler->
formattedMessages(); }
4422void Vehicle::_createStatusTextHandler()
4432void Vehicle::_textMessageReceived(MAV_COMPONENT componentid, MAV_SEVERITY severity, QString text, QString description)
4436 qCDebug(VehicleLog) <<
"Dropping message (expected as event):" << text;
4440 bool skipSpoken =
false;
4441 const bool ardupilotPrearm = text.startsWith(QStringLiteral(
"PreArm"));
4442 const bool px4Prearm = text.startsWith(QStringLiteral(
"preflight"), Qt::CaseInsensitive) && (severity >= MAV_SEVERITY::MAV_SEVERITY_CRITICAL);
4443 if (ardupilotPrearm || px4Prearm) {
4444 auto eventData = _events.find(componentid);
4445 if (eventData != _events.end()) {
4446 if (eventData->data()->healthAndArmingChecksSupported()) {
4447 qCDebug(VehicleLog) <<
"Dropping preflight message (expected as event):" << text;
4453 if (_noisySpokenPrearmMap.contains(text) && _noisySpokenPrearmMap.value(text).msecsTo(QTime::currentTime()) < (10 * 1000)) {
4456 (void) _noisySpokenPrearmMap.insert(text, QTime::currentTime());
4461 bool readAloud =
false;
4463 if (text.startsWith(
"#")) {
4464 (void) text.remove(0, 1);
4466 }
else if (severity <= MAV_SEVERITY::MAV_SEVERITY_NOTICE) {
4470 if (readAloud && !skipSpoken) {
4478void Vehicle::_errorMessageReceived(QString message)
4480 if (_isActiveVehicle) {
4481 qgcApp()->showCriticalVehicleMessage(message);
4494 qCDebug(VehicleLog) <<
"Primary Link Gone!";
4500 mavlink_setup_signing_t setup_signing;
4502 mavlink_system_t target_system;
4503 target_system.sysid =
id();
4512 for (uint8_t i = 0; i < 2; ++i) {
4522void Vehicle::_createImageProtocolManager()
4527 qgcApp()->qgcImageProvider()->setImage(image, _systemID);
4533 return (_imageProtocolManager ? _imageProtocolManager->
flowImageIndex() : 0);
4541void Vehicle::_createMAVLinkLogManager()
4548 return _mavlinkLogManager;
4556void Vehicle::_createCameraManager()
4558 if (!_cameraManager && _firmwarePlugin) {
4564const QVariantList &Vehicle::staticCameraList()
const
4566 if (_cameraManager) {
4567 return _cameraManager->cameraList();
4570 static QVariantList emptyCameraList;
4571 return emptyCameraList;
static const QString guided_mode_not_supported_by_vehicle
std::shared_ptr< LinkInterface > SharedLinkInterfacePtr
struct __mavlink_message mavlink_message_t
#define QGC_LOGGING_CATEGORY(name, categoryStr)
static QString placeholders(int n)
#define SET_HOME_TERRAIN_ALT_MIN
static void _sendMavCommandWithLambdaFallbackHandler(void *resultHandlerData, int, const mavlink_command_ack_t &ack, Vehicle::MavCmdResultFailureCode_t)
#define REQUEST_OPERATOR_CONTROL_ALLOW_TAKEOVER_TIMEOUT_MSECS
const QString guided_mode_not_supported_by_vehicle
void mavlinkMessageReceived(const mavlink_message_t &message)
static ADSBVehicleManager * instance()
void load(const QString &json_file)
void say(const QString &text, TextMods textMods=TextMod::None)
static AudioOutput * instance()
void handleEvents(const mavlink_message_t &message)
void healthAndArmingChecksUpdated()
void setMetadata(const QString &metadataJsonFileName)
int getModeGroup(int32_t customMode)
void handleMessageForFactGroupCreation(Vehicle *vehicle, const mavlink_message_t &message)
Allows for creation/updating of dynamic FactGroups based on incoming messages.
Used to group Facts together into an object hierarachy.
void _addFactGroup(FactGroup *factGroup, const QString &name)
A Fact is used to hold a single value within the system.
void rawValueChanged(const QVariant &value)
void setCommandSupported(MAV_CMD cmd, CommandSupportedResult status)
FirmwarePlugin * firmwarePluginForAutopilot(MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType)
static FirmwarePluginManager * instance()
virtual QString motorDetectionFlightMode() const
Returns the flight mode for Motor Detection.
virtual QString pauseFlightMode() const
Returns The flight mode which indicates the vehicle is paused.
virtual QString brandImageOutdoor(const Vehicle *) const
Return the resource file which contains the brand image for the vehicle for Outdoor theme.
virtual void guidedModeChangeEquivalentAirspeedMetersSecond(Vehicle *vehicle, double airspeed_equiv) const
virtual void guidedModeChangeAltitude(Vehicle *vehicle, double altitudeChange, bool pauseVehicle)
virtual void startMission(Vehicle *vehicle) const
Command the vehicle to start the mission.
virtual double maximumHorizontalSpeedMultirotor(Vehicle *) const
virtual bool multiRotorCoaxialMotors(Vehicle *) const
virtual double minimumEquivalentAirspeed(Vehicle *) const
virtual const QVariantList & toolIndicators(const Vehicle *vehicle)
virtual void guidedModeChangeGroundSpeedMetersSecond(Vehicle *vehicle, double groundspeed) const
virtual bool setFlightMode(const QString &flightMode, uint8_t *base_mode, uint32_t *custom_mode) const
@ SetFlightModeCapability
FirmwarePlugin::setFlightMode method is supported.
virtual QString vehicleImageOutline(const Vehicle *) const
Return the resource file which contains the vehicle icon used in the flight view when the view is lig...
virtual void guidedModeTakeoff(Vehicle *vehicle, double takeoffAltRel) const
Command vehicle to takeoff from current location to the specified height.
virtual bool isCapable(const Vehicle *, FirmwareCapabilities) const
virtual double maximumEquivalentAirspeed(Vehicle *) const
virtual QString missionFlightMode() const
Returns the flight mode for running missions.
virtual void adjustMetaData(MAV_TYPE, FactMetaData *)
virtual bool adjustIncomingMavlinkMessage(Vehicle *, mavlink_message_t *)
virtual bool fixedWingAirSpeedLimitsAvailable(Vehicle *) const
virtual void guidedModeChangeHeading(Vehicle *vehicle, const QGeoCoordinate &headingCoord) const
Command vehicle to rotate towards specified location.
virtual QString smartRTLFlightMode() const
Returns the flight mode for Smart RTL.
virtual bool multiRotorXConfig(Vehicle *) const
virtual QString takeControlFlightMode() const
Returns the flight mode to use when the operator wants to take back control from autonomouse flight.
virtual QString flightMode(uint8_t base_mode, uint32_t custom_mode) const
virtual QString vehicleImageOpaque(const Vehicle *) const
Return the resource file which contains the vehicle icon used in the flight view when the view is dar...
virtual void startTakeoff(Vehicle *vehicle) const
Command the vehicle to start a takeoff.
virtual QList< MAV_CMD > supportedMissionCommands(QGCMAVLink::VehicleClass_t) const
List of supported mission commands. Empty list for all commands supported.
virtual void pauseVehicle(Vehicle *vehicle) const
virtual QVariant expandedToolbarIndicatorSource(const Vehicle *, const QString &) const
virtual bool mulirotorSpeedLimitsAvailable(Vehicle *) const
int versionCompare(const Vehicle *vehicle, const QString &compare) const
virtual bool hasGripper(const Vehicle *) const
virtual QString landFlightMode() const
Returns the flight mode for Land.
virtual QString gotoFlightMode() const
Returns the flight mode which the vehicle will be in if it is performing a goto location.
virtual Autotune * createAutotune(Vehicle *vehicle) const
Creates Autotune object.
virtual QStringList flightModes(Vehicle *) const
virtual AutoPilotPlugin * autopilotPlugin(Vehicle *vehicle) const
virtual void guidedModeRTL(Vehicle *vehicle, bool smartRTL) const
Command vehicle to return to launch.
virtual QString autoDisarmParameter(Vehicle *) const
virtual QString stabilizedFlightMode() const
Returns the flight mode for Stabilized.
virtual QString brandImageIndoor(const Vehicle *) const
Return the resource file which contains the brand image for the vehicle for Indoor theme.
virtual void adjustOutgoingMavlinkMessageThreadSafe(Vehicle *, LinkInterface *, mavlink_message_t *)
void toolIndicatorsChanged()
virtual void setGuidedMode(Vehicle *vehicle, bool guidedMode) const
Set guided flight mode.
virtual QString takeOffFlightMode() const
Returns the flight mode for TakeOff.
virtual void guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoordinate &gotoCoord, double forwardFlightLoiterRadius=0.0) const
Command vehicle to move to specified location (altitude is included and relative)
virtual QString followFlightMode() const
Returns the flight mode which the vehicle will be for follow me.
virtual uint32_t highLatencyCustomModeTo32Bits(uint16_t hlCustomMode) const
Convert from HIGH_LATENCY2.custom_mode value to correct 32 bit value.
virtual QGCCameraManager * createCameraManager(Vehicle *vehicle) const
Creates vehicle camera manager.
virtual QMap< QString, FactGroup * > * factGroups()
Returns a pointer to a dictionary of firmware-specific FactGroups.
virtual void initializeVehicle(Vehicle *)
Called when Vehicle is first created to perform any firmware specific setup.
virtual bool MAV_CMD_DO_SET_MODE_is_supported() const
returns true if this flight stack supports MAV_CMD_DO_SET_MODE
virtual QString rtlFlightMode() const
Returns the flight mode for RTL.
virtual void guidedModeLand(Vehicle *vehicle) const
Command vehicle to land at current location.
virtual bool sendHomePositionToVehicle() const
virtual bool isGuidedMode(const Vehicle *) const
Returns whether the vehicle is in guided mode or not.
virtual double minimumTakeoffAltitudeMeters(Vehicle *) const
virtual QString getHobbsMeter(Vehicle *vehicle) const
gets hobbs meter from autopilot. This should be reimplmeented for each firmware
Fact *updateHomePosition READ updateHomePosition CONSTANT Fact * updateHomePosition()
Fact *maxGoToLocationDistance READ maxGoToLocationDistance CONSTANT Fact * maxGoToLocationDistance()
Fact *requestControlTimeout READ requestControlTimeout CONSTANT Fact * requestControlTimeout()
void error(int errorCode, const QString &errorMsg)
void setModeGroups(int takeoffModeGroup, int missionModeGroup)
uint32_t flowImageIndex() const
void flowImageIndexChanged(uint32_t index)
void imageReady(const QImage &image)
The link interface defines the interface for all links used to communicate with the ground station ap...
virtual bool isConnected() const =0
void writeBytesThreadSafe(const char *bytes, int length)
static int getComponentId()
Get the component id of this application.
void mavlinkMessageStatus(int sysid, uint64_t totalSent, uint64_t totalReceived, uint64_t totalLoss, float lossPercent)
void messageReceived(LinkInterface *link, const mavlink_message_t &message)
Message received and directly copied via signal.
static MAVLinkProtocol * instance()
int getSystemId() const
Get the system id of this application.
void gotSetMessageIntervalAck()
void setHighRateAltAirspeed()
void setHighRateRateAndAttitude()
void setHighRateVelAndPos()
static MissionCommandTree * instance()
QString rawName(MAV_CMD command) const
Returns the raw name for the specified command.
QString friendlyName(MAV_CMD command) const
Returns the friendly name for the specified command.
int currentIndex(void) const
Current mission item as reported by MISSION_CURRENT.
static constexpr MAV_CMD MAV_CMD_MOCKLINK_ALWAYS_RESULT_ACCEPTED
static constexpr MAV_CMD MAV_CMD_MOCKLINK_SECOND_ATTEMPT_RESULT_ACCEPTED
static constexpr MAV_CMD MAV_CMD_MOCKLINK_ALWAYS_RESULT_FAILED
static constexpr MAV_CMD MAV_CMD_MOCKLINK_SECOND_ATTEMPT_RESULT_FAILED
static constexpr MAV_CMD MAV_CMD_MOCKLINK_NO_RESPONSE
void parameterReadyVehicleAvailableChanged(bool parameterReadyVehicleAvailable)
void activeVehicleChanged(Vehicle *activeVehicle)
Fact * getParameter(int componentId, const QString ¶mName)
void parametersReadyChanged(bool parametersReady)
static constexpr int defaultComponentId
void loadProgressChanged(float value)
void currentIndexChanged(int currentIndex)
void sendComplete(bool error)
void newMissionItemsAvailable(bool removeAllRequested)
const QList< MissionItem * > & missionItems(void)
void error(int errorCode, const QString &errorMsg)
static void sendPlanToVehicle(Vehicle *vehicle, const QString &filename)
void showAdvancedUIChanged(bool showAdvancedUI)
static QGCPressure * instance()
static bool isMultiRotor(MAV_TYPE mavType)
static uint32_t highLatencyFailuresToMavSysStatus(mavlink_high_latency2_t &highLatency2)
static QString mavTypeToString(MAV_TYPE mavType)
static int motorCount(MAV_TYPE mavType, uint8_t frameType=0)
static bool isAirship(MAV_TYPE mavType)
@ CalibrationAPMPressureAirspeed
@ CalibrationAPMAccelSimple
@ CalibrationAPMCompassMot
@ CalibrationAPMPreFlight
static bool isSpacecraft(MAV_TYPE mavType)
static QString firmwareClassToString(FirmwareClass_t firmwareClass)
static bool isVTOL(MAV_TYPE mavType)
static QString firmwareVersionTypeToString(FIRMWARE_VERSION_TYPE firmwareVersionType)
static bool isFixedWing(MAV_TYPE mavType)
static QString mavResultToString(uint8_t result)
static bool isSub(MAV_TYPE mavType)
static QString vehicleClassToInternalString(VehicleClass_t vehicleClass)
static bool isRoverBoat(MAV_TYPE mavType)
bool clockwiseRotation(void) const
void setClockwiseRotation(bool clockwiseRotation)
void setShowRotation(bool showRotation)
void setCenter(QGeoCoordinate newCenter)
QGeoCoordinate center(void) const
void gcsPositionChanged(QGeoCoordinate gcsPosition)
This is a QGeoCoordinate within a QObject such that it can be used on a QmlObjectListModel.
void progressUpdate(float progress)
void append(QObject *object)
Caller maintains responsibility for object ownership and deletion.
int count() const override final
void clearAndDeleteContents() override final
Clears the list and calls deleteLater on each entry.
void error(int errorCode, const QString &errorMsg)
void mavlinkMessageReceived(mavlink_message_t &message)
Provides access to all app settings.
void availableModesMonitorReceived(uint8_t seq)
bool messageTypeNone() const
bool messageTypeError() const
void handleHTMLEscapedTextMessage(MAV_COMPONENT componentid, MAV_SEVERITY severity, const QString &text, const QString &description)
bool messageTypeNormal() const
void newErrorMessage(QString message)
void resetErrorLevelMessages()
void mavlinkMessageReceived(const mavlink_message_t &message)
void messageCountChanged(uint32_t newCount)
void textMessageReceived(MAV_COMPONENT componentid, MAV_SEVERITY severity, QString text, QString description)
uint32_t messageCount() const
void newFormattedMessage(QString message)
QString formattedMessages() const
void messageTypeChanged()
bool messageTypeWarning() const
NOTE: TerrainAtCoordinateQuery is not thread safe. All instances/calls to ElevationProvider must be o...
void terrainDataReceived(bool success, const QList< double > &heights)
void requestData(const QList< QGeoCoordinate > &coordinates)
bool mavlinkMessageReceived(const mavlink_message_t &message)
Fact _headingFromHomeFact
Fact _altitudeRelativeFact
Fact _missionItemIndexFact
Fact _altitudeTuningSetpointFact
Fact _headingToNextWPFact
Fact _altitudeAboveTerrFact
bool _altitudeMessageAvailable
WeakLinkInterfacePtr primaryLink() const
void mavlinkMessageReceived(LinkInterface *link, const mavlink_message_t &message)
bool containsLink(LinkInterface *link)
void update(mavlink_obstacle_distance_t *message)
bool changeHeading() const
bool pauseVehicle() const
void triggerSimpleCamera(void)
Trigger camera using MAV_CMD_DO_DIGICAM_CONTROL command.
VehicleGPSAggregateFactGroup _gpsAggregateFactGroup
bool isInitialConnectComplete() const
void guidedModeChangeAltitude(double altitudeChange, bool pauseVehicle)
void _setLanding(bool landing)
Vehicle(LinkInterface *link, int vehicleId, int defaultComponentId, MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType, QObject *parent=nullptr)
QGeoCoordinate _roiCoordinate
void motorInterlock(bool enable)
Command vehicle to Enable/Disable Motor Interlock.
void virtualTabletJoystickValue(double roll, double pitch, double yaw, double thrust)
int32_t getMessageRate(uint8_t compId, uint16_t msgId)
TerrainProtocolHandler * _terrainProtocolHandler
void firmwareTypeChanged()
QGCMAVLink::VehicleClass_t vehicleClass(void) const
void setInitialGCSPressure(qreal pressure)
void sensorsPresentBitsChanged(int sensorsPresentBits)
void defaultHoverSpeedChanged(double hoverSpeed)
friend class InitialConnectStateMachine
const QString _vibrationFactGroupName
bool _multirotor_speed_limits_available
void gcsControlStatusChanged()
void defaultCruiseSpeedChanged(double cruiseSpeed)
const QString _gpsFactGroupName
VehicleVibrationFactGroup _vibrationFactGroup
void haveMRSpeedLimChanged()
void sendMavCommandWithLambdaFallback(std::function< void()> lambda, int compId, MAV_CMD command, bool showError, float param1=0.0f, float param2=0.0f, float param3=0.0f, float param4=0.0f, float param5=0.0f, float param6=0.0f, float param7=0.0f)
void sendMavCommand(int compId, MAV_CMD command, bool showError, float param1=0.0f, float param2=0.0f, float param3=0.0f, float param4=0.0f, float param5=0.0f, float param6=0.0f, float param7=0.0f)
const QString _hygrometerFactGroupName
void messagesLostChanged()
void rebootVehicle()
Reboot vehicle.
const QString _localPositionFactGroupName
void vtolInFwdFlightChanged(bool vtolInFwdFlight)
QString missionFlightMode() const
void readyToFlyAvailableChanged(bool readyToFlyAvailable)
void forceInitialPlanRequestComplete()
void isROIEnabledChanged()
void guidedModeOrbit(const QGeoCoordinate ¢erCoord, double radius, double amslAltitude)
const QString _terrainFactGroupName
const QString _temperatureFactGroupName
void _offlineVehicleTypeSettingChanged(QVariant varVehicleType)
void guidedModeTakeoff(double altitudeRelative)
Command vehicle to takeoff from current location.
QString flightMode() const
static QString mavCmdResultFailureCodeToString(MavCmdResultFailureCode_t failureCode)
QString stabilizedFlightMode() const
void requestOperatorControlReceived(int sysIdRequestingControl, int allowTakeover, int requestTimeoutSecs)
QVariant expandedToolbarIndicatorSource(const QString &indicatorName)
void setActuatorsMetadata(uint8_t compid, const QString &metadataJsonFileName)
void setSoloFirmware(bool soloFirmware)
void requestDataStream(MAV_DATA_STREAM stream, uint16_t rate, bool sendMultiple=true)
QGeoCoordinate homePosition()
const QString _estimatorStatusFactGroupName
QString vehicleImageOutline() const
MissionManager * _missionManager
void textMessageReceived(int sysid, int componentid, int severity, QString text, QString description)
void initialPlanRequestCompleteChanged(bool initialPlanRequestComplete)
double minimumEquivalentAirspeed()
QString brandImageIndoor() const
const QString _clockFactGroupName
TerrainFactGroup _terrainFactGroup
void firmwareCustomVersionChanged()
QString pauseFlightMode() const
QString prearmError() const
void guidedModeROI(const QGeoCoordinate ¢erCoord)
const QString _efiFactGroupName
void inFwdFlightChanged()
void flyingChanged(bool flying)
void setFirmwarePluginInstanceData(FirmwarePluginInstanceData *firmwarePluginInstanceData)
TerrainAtCoordinateQuery * _currentDoSetHomeTerrainAtCoordinateQuery
void remoteControlRSSIChanged(uint8_t rssi)
Remote control RSSI changed (0% - 100%)
void sendMessageMultiple(mavlink_message_t message)
void capabilityBitsChanged(uint64_t capabilityBits)
void _setHomePosition(QGeoCoordinate &homeCoord)
uint64_t capabilityBits() const
void abortLanding(double climbOutAltitude)
Command vehicle to abort landing.
VehicleTemperatureFactGroup _temperatureFactGroup
void setGuidedMode(bool guidedMode)
void readyToFlyChanged(bool readyToFy)
QString firmwareVersionTypeString() const
QString landFlightMode() const
static void showCommandAckError(const mavlink_command_ack_t &ack)
void newFormattedMessage(QString formattedMessage)
MAV_TYPE vehicleType() const
VehicleLinkManager * vehicleLinkManager()
uint32_t customMode() const
void cameraManagerChanged()
void sendParamMapRC(const QString ¶mName, double scale, double centerValue, int tuningID, double minValue, double maxValue)
Sends PARAM_MAP_RC message to vehicle.
double maximumHorizontalSpeedMultirotor()
void armedChanged(bool armed)
void firmwareVersionChanged()
void logEntry(uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t last_log_num)
void sendControlRequestAllowedChanged(bool sendControlRequestAllowed)
FirmwarePlugin * firmwarePlugin()
Provides access to the Firmware Plugin for this Vehicle.
void sendMavCommandInt(int compId, MAV_CMD command, MAV_FRAME frame, bool showError, float param1, float param2, float param3, float param4, double param5, double param6, float param7)
double minimumTakeoffAltitudeMeters()
InitialConnectStateMachine * _initialConnectStateMachine
void sensorsParametersResetAck(bool success)
void sendMavCommandDelayed(int compId, MAV_CMD command, bool showError, int milliseconds, float param1=0.0f, float param2=0.0f, float param3=0.0f, float param4=0.0f, float param5=0.0f, float param6=0.0f, float param7=0.0f)
MavCmdResultFailureCode_t
@ MavCmdResultFailureNoResponseToCommand
No response from vehicle to command.
@ MavCmdResultCommandResultOnly
commandResult specifies full success/fail info
@ MavCmdResultFailureDuplicateCommand
Unable to send command since duplicate is already being waited on for response.
void telemetryLNoiseChanged(int value)
const QString _distanceSensorFactGroupName
double maximumEquivalentAirspeed()
@ ModeAltitudeAndAirspeed
@ ModeVelocityAndPosition
void setPrearmError(const QString &prearmError)
void setFirmwareCustomVersion(int majorVersion, int minorVersion, int patchVersion)
void startTimerRevertAllowTakeover()
const QString _generatorFactGroupName
QElapsedTimer _altitudeAboveTerrQueryTimer
void messagesSentChanged()
VehicleDistanceSensorFactGroup _distanceSensorFactGroup
void sendPlan(QString planFile)
bool vtolInFwdFlight() const
bool isMavCommandPending(int targetCompId, MAV_CMD command)
isMavCommandPending Query whether the specified MAV_CMD is in queue to be sent or has already been se...
void capabilitiesKnownChanged(bool capabilitiesKnown)
void sendGripperAction(QGCMAVLink::GripperActions gripperOption)
void requestOperatorControl(bool allowOverride, int requestTimeoutSecs=0)
QGeoCoordinate _altitudeAboveTerrLastCoord
bool soloFirmware() const
void coordinateChanged(QGeoCoordinate coordinate)
QString vehicleImageOpaque() const
float _altitudeTuningOffset
QString brandImageOutdoor() const
void setPIDTuningTelemetryMode(PIDTuningTelemetryMode mode)
void mavlinkLogData(Vehicle *vehicle, uint8_t target_system, uint8_t target_component, uint16_t sequence, uint8_t first_message, QByteArray data, bool acked)
void emergencyStop()
Command vehicle to kill all motors no matter what state.
void updateFlightDistance(double distance)
const QString _gpsAggregateFactGroupName
void pairRX(int rxType, int rxSubType)
const QString _setpointFactGroupName
void setCurrentMissionSequence(int seq)
Alter the current mission item on the vehicle.
void guidedModeGotoLocation(const QGeoCoordinate &gotoCoord, double forwardFlightLoiterRadius=0.0f)
Command vehicle to move to specified location (altitude is ignored)
void toolIndicatorsChanged()
void sensorsUnhealthyBitsChanged(int sensorsUnhealthyBits)
void landingChanged(bool landing)
bool sendMessageOnLinkThreadSafe(LinkInterface *link, mavlink_message_t message)
VehicleLocalPositionSetpointFactGroup _localPositionSetpointFactGroup
TerrainAtCoordinateQuery * _roiTerrainAtCoordinateQuery
const QString _rpmFactGroupName
static const MAV_AUTOPILOT MAV_AUTOPILOT_TRACK
VehicleGPS2FactGroup _gps2FactGroup
VehicleEstimatorStatusFactGroup _estimatorStatusFactGroup
void setFlightMode(const QString &flightMode)
void sendCommand(int compId, int command, bool showError, double param1=0.0, double param2=0.0, double param3=0.0, double param4=0.0, double param5=0.0, double param6=0.0, double param7=0.0)
Same as sendMavCommand but available from Qml.
void loadProgressChanged(float value)
QString smartRTLFlightMode() const
QString followFlightMode() const
bool _fixed_wing_airspeed_limits_available
void motorTest(int motor, int percent, int timeoutSecs, bool showError)
void mavlinkMessageReceived(const mavlink_message_t &message)
void setMessageRate(uint8_t compId, uint16_t msgId, int32_t rate)
void _sendMavCommandFromList(int index)
VehicleRPMFactGroup _rpmFactGroup
const QVariantList & toolIndicators()
void _offlineFirmwareTypeSettingChanged(QVariant varFirmwareType)
void guidedModeChangeEquivalentAirspeedMetersSecond(double airspeed)
float _altitudeAboveTerrLastRelAlt
void guidedModeChanged(bool guidedMode)
void setEventsMetadata(uint8_t compid, const QString &metadataJsonFileName)
int _findMavCommandListEntryIndex(int targetCompId, MAV_CMD command)
QString motorDetectionFlightMode() const
RequestMessageResultHandlerFailureCode_t
@ RequestMessageFailureMessageNotReceived
@ RequestMessageNoFailure
@ RequestMessageFailureCommandNotAcked
@ RequestMessageFailureCommandError
@ RequestMessageFailureDuplicate
Exact duplicate request already active or queued for this component/message id.
void orbitActiveChanged(bool orbitActive)
void allSensorsHealthyChanged(bool allSensorsHealthy)
void guidedModeRTL(bool smartRTL)
Command vehicle to return to launch.
VehicleSetpointFactGroup _setpointFactGroup
void trackFirmwareVehicleTypeChanges(void)
void landingGearDeploy()
Command vichecle to deploy landing gear.
static constexpr int kTestMavCommandAckTimeoutMs
void armedPositionChanged()
void rcRSSIChanged(int rcRSSI)
static QString requestMessageResultHandlerFailureCodeToString(RequestMessageResultHandlerFailureCode_t failureCode)
RemoteIDManager * _remoteIDManager
void doSetHome(const QGeoCoordinate &coord)
Set home from flight map coordinate.
void stopUAVCANBusConfig(void)
bool _commandCanBeDuplicated(MAV_CMD command)
EscStatusFactGroupListModel _escStatusFactGroupListModel
void soloFirmwareChanged(bool soloFirmware)
uint32_t flowImageIndex() const
void homePositionChanged(const QGeoCoordinate &homePosition)
QMap< uint8_t, uint8_t > _lowestBatteryChargeStateAnnouncedMap
VehicleHygrometerFactGroup _hygrometerFactGroup
void stopTrackingFirmwareVehicleTypeChanges(void)
VehicleClockFactGroup _clockFactGroup
void flightModesChanged()
const QString _gps2FactGroupName
void flightModeChanged(const QString &flightMode)
void telemetryLRSSIChanged(int value)
void flowImageIndexChanged()
void roiCoordChanged(const QGeoCoordinate ¢erCoord)
void clearAllParamMapRC(void)
Clears all PARAM_MAP_RC settings from vehicle.
void messageTypeChanged()
void setEstimatorOrigin(const QGeoCoordinate ¢erCoord)
void setVtolInFwdFlight(bool vtolInFwdFlight)
void guidedModeChangeGroundSpeedMetersSecond(double groundspeed)
int defaultComponentId() const
void setInitialGCSTemperature(qreal temperature)
void mavlinkStatusChanged()
MAVLinkLogManager * mavlinkLogManager() const
void sendJoystickDataThreadSafe(float roll, float pitch, float yaw, float thrust, quint16 buttons, quint16 buttons2, float pitchExtension, float rollExtension, float aux1, float aux2, float aux3, float aux4, float aux5, float aux6)
GeoFenceManager * _geoFenceManager
bool flightModeSetAvailable()
ParameterManager * parameterManager()
void sensorsHealthBitsChanged(int sensorsHealthBits)
void _setFlying(bool flying)
VehicleLocalPositionFactGroup _localPositionFactGroup
void guidedModeChangeHeading(const QGeoCoordinate &headingCoord)
QGeoCoordinate _doSetHomeCoordinate
QString takeControlFlightMode() const
void messagesReceivedChanged()
const QString _localPositionSetpointFactGroupName
void setOfflineEditingDefaultComponentId(int defaultComponentId)
Sets the default component id for an offline editing vehicle.
TerrainAtCoordinateQuery * _altitudeAboveTerrTerrainAtCoordinateQuery
void setFirmwareVersion(int majorVersion, int minorVersion, int patchVersion, FIRMWARE_VERSION_TYPE versionType=FIRMWARE_VERSION_TYPE_OFFICIAL)
QString rtlFlightMode() const
VehicleGeneratorFactGroup _generatorFactGroup
VehicleEFIFactGroup _efiFactGroup
void requestMessage(RequestMessageResultHandler resultHandler, void *resultHandlerData, int compId, int messageId, float param1=0.0f, float param2=0.0f, float param3=0.0f, float param4=0.0f, float param5=0.0f)
QGeoCoordinate coordinate()
void startCalibration(QGCMAVLink::CalibrationType calType)
QString firmwareTypeString() const
void stopCalibration(bool showError)
void messageCountChanged()
void rcChannelsChanged(QVector< int > channelValues)
BatteryFactGroupListModel _batteryFactGroupListModel
void telemetryTXBufferChanged(unsigned int value)
friend class VehicleLinkManager
void haveFWSpeedLimChanged()
RallyPointManager * _rallyPointManager
void startUAVCANBusConfig(void)
QString gotoFlightMode() const
void sendMavCommandIntWithHandler(const MavCmdAckHandlerInfo_t *ackHandlerInfo, int compId, MAV_CMD command, MAV_FRAME frame, float param1=0.0f, float param2=0.0f, float param3=0.0f, float param4=0.0f, double param5=0.0f, double param6=0.0f, float param7=0.0f)
void telemetryRRSSIChanged(int value)
void landingGearRetract()
Command vichecle to retract landing gear.
VehicleSupports * supports()
void telemetryFixedChanged(unsigned int value)
const QString _windFactGroupName
void mavCommandResult(int vehicleId, int targetComponent, int command, int ackResult, int failureCode)
void calibrationEventReceived(int uasid, int componentid, int severity, QSharedPointer< events::parser::ParsedEvent > event)
void sensorsEnabledBitsChanged(int sensorsEnabledBits)
class FirmwarePluginInstanceData * firmwarePluginInstanceData()
int versionCompare(const QString &compare) const
Used to check if running current version is equal or higher than the one being compared.
void requiresGpsFixChanged()
void setArmed(bool armed, bool showError)
void closeVehicle(void)
Removes the vehicle from the system.
bool _sendMavCommandShouldRetry(MAV_CMD command)
QStringList flightModes()
void mavlinkMsgIntervalsChanged(uint8_t compid, uint16_t msgId, int32_t rate)
void mavlinkSerialControl(uint8_t device, uint8_t flags, uint16_t timeout, uint32_t baudrate, QByteArray data)
QString vehicleClassInternalName() const
VehicleLinkManager * _vehicleLinkManager
VehicleWindFactGroup _windFactGroup
VehicleGPSFactGroup _gpsFactGroup
void prearmErrorChanged(const QString &prearmError)
void vehicleTypeChanged()
void guidedModeLand()
Command vehicle to land at current location.
void sendMavCommandWithHandler(const MavCmdAckHandlerInfo_t *ackHandlerInfo, int compId, MAV_CMD command, float param1=0.0f, float param2=0.0f, float param3=0.0f, float param4=0.0f, float param5=0.0f, float param6=0.0f, float param7=0.0f)
Sends the command and calls the callback with the result.
void _sendMavCommandWorker(bool commandInt, bool showError, const MavCmdAckHandlerInfo_t *ackHandlerInfo, int compId, MAV_CMD command, MAV_FRAME frame, float param1, float param2, float param3, float param4, double param5, double param6, float param7)
StandardModes * _standardModes
void telemetryRNoiseChanged(int value)
friend class GimbalController
QString vehicleTypeString() const
void logData(uint32_t ofs, uint16_t id, uint8_t count, const uint8_t *data)
void telemetryRXErrorsChanged(unsigned int value)
static constexpr const char * videoSourceUDPH264
Fact *streamEnabled READ streamEnabled CONSTANT Fact * streamEnabled()
static constexpr const char * videoDisabled
Fact *videoSource READ videoSource CONSTANT Fact * videoSource()
Fact *lowLatencyMode READ lowLatencyMode CONSTANT Fact * lowLatencyMode()
void createSetupSigning(mavlink_channel_t channel, mavlink_system_t target_system, mavlink_setup_signing_t &setup_signing)
bool fuzzyCompare(double value1, double value2)
Returns true if the two values are equal or close. Correctly handles 0 and NaN values.
MavCmdResultHandler resultHandler
void * resultHandlerData
‍nullptr for no handler
std::function< void()> unsupported_lambda