|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <PlanManager.h>
Inheritance diagram for PlanManager:
Collaboration diagram for PlanManager:Public Types | |
| enum | ErrorCode_t { InternalError , AckTimeoutError , ProtocolError , RequestRangeError , ItemMismatchError , VehicleAckError , MissingRequestsError , MaxRetryExceeded , MissionTypeMismatch } |
| Error codes returned in error signal. More... | |
Signals | |
| void | newMissionItemsAvailable (bool removeAllRequested) |
| void | inProgressChanged (bool inProgress) |
| void | error (int errorCode, const QString &errorMsg) |
| void | currentIndexChanged (int currentIndex) |
| void | lastCurrentIndexChanged (int lastCurrentIndex) |
| void | progressPctChanged (double progressPercentPct) |
| void | removeAllComplete (bool error) |
| void | sendComplete (bool error) |
| void | resumeMissionReady (void) |
| void | resumeMissionUploadFail (void) |
Public Member Functions | |
| PlanManager (Vehicle *vehicle, MAV_MISSION_TYPE planType) | |
| ~PlanManager () | |
| bool | inProgress (void) const |
| const QList< MissionItem * > & | missionItems (void) |
| int | currentIndex (void) const |
| Current mission item as reported by MISSION_CURRENT. | |
| int | lastCurrentIndex (void) const |
| Last current mission item reported while in Mission flight mode. | |
| void | loadFromVehicle (void) |
| void | writeMissionItems (const QList< MissionItem * > &missionItems) |
| void | removeAll (void) |
Static Public Attributes | |
| static constexpr int | _ackTimeoutMilliseconds = 1500 |
| static constexpr int | _retryTimeoutMilliseconds = 250 |
| static constexpr int | _maxRetryCount = 5 |
| static constexpr int | kTestAckTimeoutMs = 50 |
| Ack timeout used in unit tests (much shorter for faster tests) | |
Protected Types | |
| enum | AckType_t { AckNone , AckMissionCount , AckMissionItem , AckMissionRequest , AckMissionClearAll , AckGuidedItem } |
| enum | TransactionType_t { TransactionNone , TransactionRead , TransactionWrite , TransactionRemoveAll } |
Protected Member Functions | |
| void | _startAckTimeout (AckType_t ack) |
| bool | _checkForExpectedAck (AckType_t receivedAck) |
| void | _readTransactionComplete (void) |
| void | _handleMissionCount (const mavlink_message_t &message) |
| void | _handleMissionItem (const mavlink_message_t &message) |
| void | _handleMissionRequest (const mavlink_message_t &message) |
| void | _handleMissionAck (const mavlink_message_t &message) |
| void | _requestNextMissionItem (void) |
| void | _clearMissionItems (void) |
| void | _sendError (ErrorCode_t errorCode, const QString &errorMsg) |
| QString | _ackTypeToString (AckType_t ackType) |
| QString | _missionResultToString (MAV_MISSION_RESULT result) |
| void | _finishTransaction (bool success, bool apmGuidedItemWrite=false) |
| void | _requestList (void) |
| Internal call to request list of mission items. May be called during a retry sequence. | |
| void | _writeMissionCount (void) |
| This begins the write sequence with the vehicle. This may be called during a retry. | |
| void | _writeMissionItemsWorker (void) |
| void | _clearAndDeleteMissionItems (void) |
| void | _clearAndDeleteWriteMissionItems (void) |
| QString | _lastMissionReqestString (MAV_MISSION_RESULT result) |
| void | _removeAllWorker (void) |
| void | _connectToMavlink (void) |
| void | _disconnectFromMavlink (void) |
| QString | _planTypeString (void) |
Protected Attributes | |
| Vehicle * | _vehicle = nullptr |
| MAV_MISSION_TYPE | _planType |
| QTimer * | _ackTimeoutTimer = nullptr |
| AckType_t | _expectedAck |
| int | _retryCount |
| TransactionType_t | _transactionInProgress |
| bool | _resumeMission |
| QList< int > | _itemIndicesToWrite |
| List of mission items which still need to be written to vehicle. | |
| QList< int > | _itemIndicesToRead |
| List of mission items which still need to be requested from vehicle. | |
| int | _lastMissionRequest |
| Index of item last requested by MISSION_REQUEST. | |
| int | _missionItemCountToRead |
| Count of all mission items to read. | |
| QList< MissionItem * > | _missionItems |
| Set of mission items on vehicle. | |
| QList< MissionItem * > | _writeMissionItems |
| Set of mission items currently being written to vehicle. | |
| int | _currentMissionIndex |
| int | _lastCurrentIndex |
The PlanManager class is the base class for the Mission, GeoFence and Rally Point managers. All of which use the new mavlink v2 mission protocol.
Definition at line 16 of file PlanManager.h.
|
protected |
Definition at line 87 of file PlanManager.h.
Error codes returned in error signal.
| Enumerator | |
|---|---|
| InternalError | |
| AckTimeoutError | Timed out waiting for response from vehicle. |
| ProtocolError | Incorrect protocol sequence from vehicle. |
| RequestRangeError | Vehicle requested item out of range. |
| ItemMismatchError | Vehicle returned item with seq # different than requested. |
| VehicleAckError | Vehicle returned error in ack. |
| MissingRequestsError | Vehicle did not request all items during write sequence. |
| MaxRetryExceeded | Retry failed. |
| MissionTypeMismatch | MAV_MISSION_TYPE does not match _planType. |
Definition at line 48 of file PlanManager.h.
|
protected |
| Enumerator | |
|---|---|
| TransactionNone | |
| TransactionRead | |
| TransactionWrite | |
| TransactionRemoveAll | |
Definition at line 96 of file PlanManager.h.
| PlanManager::PlanManager | ( | Vehicle * | vehicle, |
| MAV_MISSION_TYPE | planType | ||
| ) |
Definition at line 11 of file PlanManager.cc.
| PlanManager::~PlanManager | ( | ) |
Definition at line 30 of file PlanManager.cc.
|
protected |
Definition at line 672 of file PlanManager.cc.
References _planTypeString(), AckGuidedItem, AckMissionCount, AckMissionItem, AckMissionRequest, and AckNone.
Referenced by _checkForExpectedAck().
|
protected |
Checks the received ack against the expected ack. If they match the ack timeout timer will be stopped.
Definition at line 271 of file PlanManager.cc.
References _ackTimeoutTimer, _ackTypeToString(), _expectedAck, _planTypeString(), and AckNone.
Referenced by _handleMissionAck(), _handleMissionCount(), _handleMissionItem(), and _handleMissionRequest().
|
protected |
Definition at line 916 of file PlanManager.cc.
References _missionItems.
Referenced by _clearMissionItems(), _finishTransaction(), and removeAll().
|
protected |
Definition at line 926 of file PlanManager.cc.
References _writeMissionItems.
Referenced by _finishTransaction(), MissionManager::generateResumeMission(), and writeMissionItems().
|
protected |
Definition at line 480 of file PlanManager.cc.
References _clearAndDeleteMissionItems(), and _itemIndicesToRead.
Referenced by _requestList().
|
protected |
Definition at line 935 of file PlanManager.cc.
References _vehicle, and Vehicle::mavlinkMessageReceived().
Referenced by _removeAllWorker(), _writeMissionItemsWorker(), loadFromVehicle(), and MissionManager::writeArduPilotGuidedMissionItem().
|
protected |
Definition at line 940 of file PlanManager.cc.
References _vehicle, and Vehicle::mavlinkMessageReceived().
Referenced by _finishTransaction().
|
protected |
Definition at line 804 of file PlanManager.cc.
References _clearAndDeleteMissionItems(), _clearAndDeleteWriteMissionItems(), _currentMissionIndex, _disconnectFromMavlink(), _itemIndicesToRead, _itemIndicesToWrite, _lastCurrentIndex, _missionItems, _planType, _resumeMission, _transactionInProgress, _writeMissionItems, currentIndexChanged(), lastCurrentIndexChanged(), newMissionItemsAvailable(), progressPctChanged(), removeAllComplete(), resumeMissionReady(), resumeMissionUploadFail(), sendComplete(), TransactionNone, TransactionRead, TransactionRemoveAll, and TransactionWrite.
Referenced by _handleMissionAck(), _handleMissionRequest(), and _readTransactionComplete().
|
protected |
Definition at line 555 of file PlanManager.cc.
References _checkForExpectedAck(), _expectedAck, _finishTransaction(), _itemIndicesToWrite, _missionResultToString(), _planType, _planTypeString(), _sendError(), _vehicle, AckGuidedItem, AckMissionClearAll, AckMissionCount, AckMissionItem, AckMissionRequest, AckNone, Vehicle::apmFirmware(), and VehicleAckError.
|
protected |
Definition at line 316 of file PlanManager.cc.
References _checkForExpectedAck(), _itemIndicesToRead, _missionItemCountToRead, _planType, _planTypeString(), _readTransactionComplete(), _requestNextMissionItem(), _retryCount, and AckMissionCount.
|
protected |
Definition at line 375 of file PlanManager.cc.
References _checkForExpectedAck(), _itemIndicesToRead, _missionItemCountToRead, _missionItems, _planType, _planTypeString(), _readTransactionComplete(), _requestNextMissionItem(), _retryCount, Vehicle::_setHomePosition(), _startAckTimeout(), _vehicle, AckMissionItem, Vehicle::apmFirmware(), MissionItem::command(), Vehicle::firmwarePlugin(), MissionItem::param1(), progressPctChanged(), FirmwarePlugin::sendHomePositionToVehicle(), and MissionItem::setParam1().
|
protected |
Definition at line 486 of file PlanManager.cc.
References _checkForExpectedAck(), _finishTransaction(), _itemIndicesToWrite, _lastMissionRequest, _planType, _planTypeString(), _sendError(), _startAckTimeout(), _vehicle, _writeMissionItems, AckMissionRequest, MissionItem::autoContinue(), MissionItem::command(), MissionItem::frame(), MAVLinkProtocol::getComponentId(), Vehicle::id(), MAVLinkProtocol::instance(), MissionItem::param1(), MissionItem::param2(), MissionItem::param3(), MissionItem::param4(), MissionItem::param5(), MissionItem::param6(), MissionItem::param7(), VehicleLinkManager::primaryLink(), progressPctChanged(), RequestRangeError, Vehicle::sendMessageOnLinkThreadSafe(), and Vehicle::vehicleLinkManager().
|
protected |
Definition at line 691 of file PlanManager.cc.
References _lastMissionRequest, _writeMissionItems, MissionItem::command(), MissionItem::frame(), MissionCommandTree::instance(), MissionItem::param1(), MissionItem::param2(), MissionItem::param3(), MissionItem::param4(), MissionItem::param5(), MissionItem::param6(), and MissionItem::param7().
Referenced by _missionResultToString().
|
protected |
Definition at line 740 of file PlanManager.cc.
References _lastMissionReqestString(), _planTypeString(), and error.
Referenced by _handleMissionAck().
|
protected |
Definition at line 945 of file PlanManager.cc.
References _planType.
Referenced by _ackTypeToString(), _checkForExpectedAck(), _handleMissionAck(), _handleMissionCount(), _handleMissionItem(), _handleMissionRequest(), _missionResultToString(), _requestList(), _requestNextMissionItem(), _sendError(), _writeMissionCount(), _writeMissionItemsWorker(), loadFromVehicle(), removeAll(), and writeMissionItems().
|
protected |
Definition at line 290 of file PlanManager.cc.
References _finishTransaction(), _planType, _vehicle, MAVLinkProtocol::getComponentId(), Vehicle::id(), MAVLinkProtocol::instance(), VehicleLinkManager::primaryLink(), Vehicle::sendMessageOnLinkThreadSafe(), and Vehicle::vehicleLinkManager().
Referenced by _handleMissionCount(), and _handleMissionItem().
|
protected |
Definition at line 869 of file PlanManager.cc.
References _connectToMavlink(), _planType, _startAckTimeout(), _vehicle, AckMissionClearAll, MAVLinkProtocol::getComponentId(), Vehicle::id(), MAVLinkProtocol::instance(), VehicleLinkManager::primaryLink(), progressPctChanged(), Vehicle::sendMessageOnLinkThreadSafe(), and Vehicle::vehicleLinkManager().
Referenced by removeAll().
|
protected |
Internal call to request list of mission items. May be called during a retry sequence.
Definition at line 142 of file PlanManager.cc.
References _clearMissionItems(), _itemIndicesToRead, _planType, _planTypeString(), _retryCount, _startAckTimeout(), _vehicle, AckMissionCount, MAVLinkProtocol::getComponentId(), Vehicle::id(), MAVLinkProtocol::instance(), VehicleLinkManager::primaryLink(), Vehicle::sendMessageOnLinkThreadSafe(), and Vehicle::vehicleLinkManager().
Referenced by loadFromVehicle().
|
protected |
Definition at line 349 of file PlanManager.cc.
References _itemIndicesToRead, _planType, _planTypeString(), _retryCount, _sendError(), _startAckTimeout(), _vehicle, AckMissionItem, MAVLinkProtocol::getComponentId(), Vehicle::id(), MAVLinkProtocol::instance(), InternalError, VehicleLinkManager::primaryLink(), Vehicle::sendMessageOnLinkThreadSafe(), and Vehicle::vehicleLinkManager().
Referenced by _handleMissionCount(), and _handleMissionItem().
|
protected |
Definition at line 665 of file PlanManager.cc.
References _planTypeString(), and error.
Referenced by _handleMissionAck(), _handleMissionRequest(), and _requestNextMissionItem().
|
protected |
Definition at line 241 of file PlanManager.cc.
References _ackTimeoutMilliseconds, _ackTimeoutTimer, _expectedAck, _retryTimeoutMilliseconds, AckGuidedItem, AckMissionClearAll, AckMissionCount, AckMissionItem, AckMissionRequest, AckNone, kTestAckTimeoutMs, and qgcApp.
Referenced by _handleMissionItem(), _handleMissionRequest(), _removeAllWorker(), _requestList(), _requestNextMissionItem(), _writeMissionCount(), and MissionManager::writeArduPilotGuidedMissionItem().
|
protected |
This begins the write sequence with the vehicle. This may be called during a retry.
Definition at line 97 of file PlanManager.cc.
References _planType, _planTypeString(), _retryCount, _startAckTimeout(), _vehicle, _writeMissionItems, AckMissionRequest, MAVLinkProtocol::getComponentId(), Vehicle::id(), MAVLinkProtocol::instance(), VehicleLinkManager::primaryLink(), Vehicle::sendMessageOnLinkThreadSafe(), and Vehicle::vehicleLinkManager().
Referenced by _writeMissionItemsWorker().
|
protected |
Definition at line 35 of file PlanManager.cc.
References _connectToMavlink(), _itemIndicesToWrite, _lastMissionRequest, _planTypeString(), _retryCount, _writeMissionCount(), _writeMissionItems, progressPctChanged(), and TransactionWrite.
Referenced by MissionManager::generateResumeMission(), and writeMissionItems().
|
inline |
Current mission item as reported by MISSION_CURRENT.
Definition at line 28 of file PlanManager.h.
|
signal |
Referenced by _finishTransaction(), and removeAll().
|
signal |
Referenced by GeoFenceManager::GeoFenceManager(), and RallyPointManager::RallyPointManager().
| bool PlanManager::inProgress | ( | void | ) | const |
Definition at line 864 of file PlanManager.cc.
References _transactionInProgress, and TransactionNone.
Referenced by MissionManager::generateResumeMission(), loadFromVehicle(), removeAll(), GeoFenceController::syncInProgress(), MissionController::syncInProgress(), RallyPointController::syncInProgress(), MissionManager::writeArduPilotGuidedMissionItem(), and writeMissionItems().
|
signal |
|
inline |
Last current mission item reported while in Mission flight mode.
Definition at line 31 of file PlanManager.h.
|
signal |
Referenced by _finishTransaction(), and removeAll().
| void PlanManager::loadFromVehicle | ( | void | ) |
Load the mission items from the vehicle Signals newMissionItemsAvailable when done
Definition at line 122 of file PlanManager.cc.
References _connectToMavlink(), _planTypeString(), _requestList(), _retryCount, _vehicle, inProgress(), Vehicle::isOfflineEditingVehicle(), and TransactionRead.
Referenced by GeoFenceController::loadFromVehicle(), MissionController::loadFromVehicle(), and RallyPointController::loadFromVehicle().
|
inline |
Definition at line 25 of file PlanManager.h.
Referenced by writeMissionItems().
|
signal |
Referenced by _finishTransaction(), GeoFenceManager::GeoFenceManager(), and RallyPointManager::RallyPointManager().
|
signal |
Referenced by _finishTransaction(), _handleMissionItem(), _handleMissionRequest(), _removeAllWorker(), and _writeMissionItemsWorker().
| void PlanManager::removeAll | ( | void | ) |
Removes all mission items from vehicle Signals removeAllComplete when done
Definition at line 893 of file PlanManager.cc.
References _clearAndDeleteMissionItems(), _currentMissionIndex, _lastCurrentIndex, _planType, _planTypeString(), _removeAllWorker(), _retryCount, currentIndexChanged(), inProgress(), lastCurrentIndexChanged(), and TransactionRemoveAll.
Referenced by GeoFenceManager::removeAll(), RallyPointManager::removeAll(), and MissionController::removeAllFromVehicle().
|
signal |
Referenced by _finishTransaction(), GeoFenceManager::GeoFenceManager(), and RallyPointManager::RallyPointManager().
|
signal |
Referenced by _finishTransaction().
|
signal |
Referenced by _finishTransaction().
|
signal |
Referenced by _finishTransaction(), GeoFenceManager::GeoFenceManager(), and RallyPointManager::RallyPointManager().
| void PlanManager::writeMissionItems | ( | const QList< MissionItem * > & | missionItems | ) |
Writes the specified set of mission items to the vehicle IMPORTANT NOTE: PlanManager will take control of the MissionItem objects with the missionItems list. It will free them when done.
| missionItems | Items to send to vehicle Signals sendComplete when done |
Definition at line 56 of file PlanManager.cc.
References _clearAndDeleteWriteMissionItems(), _planType, _planTypeString(), _vehicle, _writeMissionItems, _writeMissionItemsWorker(), MissionItem::command(), Vehicle::firmwarePlugin(), inProgress(), Vehicle::isOfflineEditingVehicle(), missionItems(), MissionItem::param1(), FirmwarePlugin::sendHomePositionToVehicle(), MissionItem::sequenceNumber(), MissionItem::setIsCurrentItem(), MissionItem::setParam1(), and MissionItem::setSequenceNumber().
Referenced by MissionController::sendItemsToVehicle(), GeoFenceManager::sendToVehicle(), and RallyPointManager::sendToVehicle().
|
staticconstexpr |
Definition at line 62 of file PlanManager.h.
Referenced by _startAckTimeout().
|
protected |
Definition at line 131 of file PlanManager.h.
Referenced by _checkForExpectedAck(), and _startAckTimeout().
|
protected |
Definition at line 144 of file PlanManager.h.
Referenced by _finishTransaction(), MissionManager::currentIndex(), and removeAll().
|
protected |
Definition at line 132 of file PlanManager.h.
Referenced by _checkForExpectedAck(), _handleMissionAck(), and _startAckTimeout().
|
protected |
List of mission items which still need to be requested from vehicle.
Definition at line 138 of file PlanManager.h.
Referenced by _clearMissionItems(), _finishTransaction(), _handleMissionCount(), _handleMissionItem(), _requestList(), and _requestNextMissionItem().
|
protected |
List of mission items which still need to be written to vehicle.
Definition at line 137 of file PlanManager.h.
Referenced by _finishTransaction(), _handleMissionAck(), _handleMissionRequest(), and _writeMissionItemsWorker().
|
protected |
Definition at line 145 of file PlanManager.h.
Referenced by _finishTransaction(), MissionManager::lastCurrentIndex(), and removeAll().
|
protected |
Index of item last requested by MISSION_REQUEST.
Definition at line 139 of file PlanManager.h.
Referenced by _handleMissionRequest(), _lastMissionReqestString(), and _writeMissionItemsWorker().
|
staticconstexpr |
Definition at line 65 of file PlanManager.h.
|
protected |
Count of all mission items to read.
Definition at line 140 of file PlanManager.h.
Referenced by _handleMissionCount(), and _handleMissionItem().
|
protected |
Set of mission items on vehicle.
Definition at line 142 of file PlanManager.h.
Referenced by _clearAndDeleteMissionItems(), _finishTransaction(), _handleMissionItem(), and MissionManager::generateResumeMission().
|
protected |
Definition at line 129 of file PlanManager.h.
Referenced by _finishTransaction(), _handleMissionAck(), _handleMissionCount(), _handleMissionItem(), _handleMissionRequest(), _planTypeString(), _readTransactionComplete(), _removeAllWorker(), _requestList(), _requestNextMissionItem(), _writeMissionCount(), removeAll(), and writeMissionItems().
|
protected |
Definition at line 136 of file PlanManager.h.
Referenced by _finishTransaction(), and MissionManager::generateResumeMission().
|
protected |
Definition at line 133 of file PlanManager.h.
Referenced by _handleMissionCount(), _handleMissionItem(), _requestList(), _requestNextMissionItem(), _writeMissionCount(), _writeMissionItemsWorker(), loadFromVehicle(), and removeAll().
|
staticconstexpr |
Definition at line 64 of file PlanManager.h.
Referenced by _startAckTimeout().
|
protected |
Definition at line 135 of file PlanManager.h.
Referenced by _finishTransaction(), inProgress(), and MissionManager::writeArduPilotGuidedMissionItem().
|
protected |
Definition at line 128 of file PlanManager.h.
Referenced by _connectToMavlink(), _disconnectFromMavlink(), _handleMissionAck(), _handleMissionItem(), _handleMissionRequest(), _readTransactionComplete(), _removeAllWorker(), _requestList(), _requestNextMissionItem(), _writeMissionCount(), MissionManager::generateResumeMission(), loadFromVehicle(), GeoFenceManager::supported(), RallyPointManager::supported(), MissionManager::writeArduPilotGuidedMissionItem(), and writeMissionItems().
|
protected |
Set of mission items currently being written to vehicle.
Definition at line 143 of file PlanManager.h.
Referenced by _clearAndDeleteWriteMissionItems(), _finishTransaction(), _handleMissionRequest(), _lastMissionReqestString(), _writeMissionCount(), _writeMissionItemsWorker(), MissionManager::generateResumeMission(), and writeMissionItems().
|
staticconstexpr |
Ack timeout used in unit tests (much shorter for faster tests)
Definition at line 68 of file PlanManager.h.
Referenced by _startAckTimeout().