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. More...
#include <PlanManager.h>
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 | _sendMissionItem (int seq) |
| 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 13 of file PlanManager.h.
|
protected |
Definition at line 84 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 45 of file PlanManager.h.
|
protected |
| Enumerator | |
|---|---|
| TransactionNone | |
| TransactionRead | |
| TransactionWrite | |
| TransactionRemoveAll | |
Definition at line 93 of file PlanManager.h.
| PlanManager::PlanManager | ( | Vehicle * | vehicle, |
| MAV_MISSION_TYPE | planType ) |
Definition at line 14 of file PlanManager.cc.
References _ackTimeoutTimer, _currentMissionIndex, _expectedAck, _lastCurrentIndex, _lastMissionRequest, _missionItemCountToRead, _planType, _resumeMission, _transactionInProgress, _vehicle, AckNone, PlanManager(), and TransactionNone.
Referenced by GeoFenceManager::GeoFenceManager(), MissionManager::MissionManager(), PlanManager(), and RallyPointManager::RallyPointManager().
| PlanManager::~PlanManager | ( | ) |
Definition at line 33 of file PlanManager.cc.
|
protected |
Definition at line 706 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 287 of file PlanManager.cc.
References _ackTimeoutTimer, _ackTypeToString(), _expectedAck, _planTypeString(), and AckNone.
Referenced by _handleMissionAck(), _handleMissionCount(), _handleMissionItem(), and _handleMissionRequest().
|
protected |
Definition at line 950 of file PlanManager.cc.
References _missionItems.
Referenced by _clearMissionItems(), _finishTransaction(), and removeAll().
|
protected |
Definition at line 960 of file PlanManager.cc.
References _writeMissionItems.
Referenced by _finishTransaction(), MissionManager::generateResumeMission(), and writeMissionItems().
|
protected |
Definition at line 498 of file PlanManager.cc.
References _clearAndDeleteMissionItems(), and _itemIndicesToRead.
Referenced by _requestList().
|
protected |
Definition at line 969 of file PlanManager.cc.
References _vehicle, and Vehicle::mavlinkMessageReceived().
Referenced by _removeAllWorker(), _writeMissionItemsWorker(), loadFromVehicle(), and MissionManager::writeArduPilotGuidedMissionItem().
|
protected |
Definition at line 974 of file PlanManager.cc.
References _vehicle, and Vehicle::mavlinkMessageReceived().
Referenced by _finishTransaction().
|
protected |
Definition at line 838 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 584 of file PlanManager.cc.
References _checkForExpectedAck(), _expectedAck, _finishTransaction(), _itemIndicesToWrite, _missionResultToString(), _planType, _planTypeString(), _retryCount, _sendError(), _vehicle, AckGuidedItem, AckMissionClearAll, AckMissionCount, AckMissionItem, AckMissionRequest, AckNone, ProtocolError, and VehicleAckError.
|
protected |
Definition at line 332 of file PlanManager.cc.
References _checkForExpectedAck(), _itemIndicesToRead, _missionItemCountToRead, _planType, _planTypeString(), _readTransactionComplete(), _requestNextMissionItem(), _retryCount, and AckMissionCount.
|
protected |
Definition at line 391 of file PlanManager.cc.
References _checkForExpectedAck(), _itemIndicesToRead, _missionItemCountToRead, _missionItems, _planType, _planTypeString(), _readTransactionComplete(), _requestNextMissionItem(), _retryCount, _startAckTimeout(), _vehicle, AckMissionItem, MissionItem::command(), MissionItem::param1(), progressPctChanged(), and MissionItem::setParam1().
|
protected |
Definition at line 504 of file PlanManager.cc.
References _checkForExpectedAck(), _finishTransaction(), _itemIndicesToWrite, _lastMissionRequest, _planType, _planTypeString(), _retryCount, _sendError(), _sendMissionItem(), _writeMissionItems, AckMissionRequest, progressPctChanged(), and RequestRangeError.
|
protected |
Definition at line 725 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 774 of file PlanManager.cc.
References _lastMissionReqestString(), _planTypeString(), and error().
Referenced by _handleMissionAck().
|
protected |
Definition at line 979 of file PlanManager.cc.
References _planType.
Referenced by _ackTypeToString(), _checkForExpectedAck(), _handleMissionAck(), _handleMissionCount(), _handleMissionItem(), _handleMissionRequest(), _missionResultToString(), _requestList(), _requestNextMissionItem(), _sendError(), _sendMissionItem(), _writeMissionCount(), _writeMissionItemsWorker(), loadFromVehicle(), removeAll(), and writeMissionItems().
|
protected |
Definition at line 306 of file PlanManager.cc.
References _finishTransaction(), _planType, _vehicle, MAVLinkProtocol::getComponentId(), and MAVLinkProtocol::instance().
Referenced by _handleMissionCount(), and _handleMissionItem().
|
protected |
Definition at line 903 of file PlanManager.cc.
References _connectToMavlink(), _planType, _startAckTimeout(), _vehicle, AckMissionClearAll, MAVLinkProtocol::getComponentId(), MAVLinkProtocol::instance(), and progressPctChanged().
Referenced by removeAll().
|
protected |
Internal call to request list of mission items. May be called during a retry sequence.
Definition at line 145 of file PlanManager.cc.
References _clearMissionItems(), _itemIndicesToRead, _planType, _planTypeString(), _retryCount, _startAckTimeout(), _vehicle, AckMissionCount, MAVLinkProtocol::getComponentId(), and MAVLinkProtocol::instance().
Referenced by loadFromVehicle().
|
protected |
Definition at line 365 of file PlanManager.cc.
References _itemIndicesToRead, _planType, _planTypeString(), _retryCount, _sendError(), _startAckTimeout(), _vehicle, AckMissionItem, MAVLinkProtocol::getComponentId(), MAVLinkProtocol::instance(), and InternalError.
Referenced by _handleMissionCount(), and _handleMissionItem().
|
protected |
Definition at line 699 of file PlanManager.cc.
References _planTypeString(), and error().
Referenced by _handleMissionAck(), _handleMissionRequest(), and _requestNextMissionItem().
|
protected |
Sends a single mission item to the vehicle as part of a write transaction and (re-)starts the ack timeout. Used both for the initial send in response to MISSION_REQUEST(_INT), and to resend the last item if the final MISSION_ACK times out (the vehicle may have stored it but the ack got dropped on the way back).
Definition at line 551 of file PlanManager.cc.
References _planType, _planTypeString(), _startAckTimeout(), _vehicle, _writeMissionItems, AckMissionRequest, MissionItem::autoContinue(), MissionItem::command(), MissionItem::frame(), MAVLinkProtocol::getComponentId(), MAVLinkProtocol::instance(), MissionItem::param1(), MissionItem::param2(), MissionItem::param3(), MissionItem::param4(), MissionItem::param5(), MissionItem::param6(), and MissionItem::param7().
Referenced by _handleMissionRequest().
|
protected |
Definition at line 257 of file PlanManager.cc.
References _ackTimeoutMilliseconds, _ackTimeoutTimer, _expectedAck, _retryTimeoutMilliseconds, AckGuidedItem, AckMissionClearAll, AckMissionCount, AckMissionItem, AckMissionRequest, AckNone, kTestAckTimeoutMs, and QGC::runningUnitTests().
Referenced by _handleMissionItem(), _removeAllWorker(), _requestList(), _requestNextMissionItem(), _sendMissionItem(), _writeMissionCount(), and MissionManager::writeArduPilotGuidedMissionItem().
|
protected |
This begins the write sequence with the vehicle. This may be called during a retry.
Definition at line 100 of file PlanManager.cc.
References _planType, _planTypeString(), _retryCount, _startAckTimeout(), _vehicle, _writeMissionItems, AckMissionRequest, MAVLinkProtocol::getComponentId(), and MAVLinkProtocol::instance().
Referenced by _writeMissionItemsWorker().
|
protected |
Definition at line 38 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 25 of file PlanManager.h.
References _currentMissionIndex.
Referenced by currentIndexChanged().
|
signal |
References currentIndex().
Referenced by _finishTransaction(), and removeAll().
|
signal |
| bool PlanManager::inProgress | ( | void | ) | const |
Definition at line 898 of file PlanManager.cc.
References _transactionInProgress, and TransactionNone.
Referenced by MissionManager::generateResumeMission(), GeoFenceManager::inProgressChanged(), inProgressChanged(), RallyPointManager::inProgressChanged(), loadFromVehicle(), removeAll(), MissionManager::writeArduPilotGuidedMissionItem(), and writeMissionItems().
|
signal |
References inProgress().
Referenced by GeoFenceManager::GeoFenceManager(), RallyPointManager::RallyPointManager(), and MissionManager::writeArduPilotGuidedMissionItem().
|
inline |
Last current mission item reported while in Mission flight mode.
Definition at line 28 of file PlanManager.h.
References _lastCurrentIndex.
Referenced by lastCurrentIndexChanged().
|
signal |
References lastCurrentIndex().
Referenced by _finishTransaction(), and removeAll().
| void PlanManager::loadFromVehicle | ( | void | ) |
Load the mission items from the vehicle Signals newMissionItemsAvailable when done
Definition at line 125 of file PlanManager.cc.
References _connectToMavlink(), _planTypeString(), _requestList(), _retryCount, _vehicle, inProgress(), and TransactionRead.
|
inline |
Definition at line 22 of file PlanManager.h.
References _missionItems.
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 927 of file PlanManager.cc.
References _clearAndDeleteMissionItems(), _currentMissionIndex, _lastCurrentIndex, _planType, _planTypeString(), _removeAllWorker(), _retryCount, currentIndexChanged(), inProgress(), lastCurrentIndexChanged(), and TransactionRemoveAll.
Referenced by GeoFenceManager::removeAll(), and RallyPointManager::removeAll().
|
signal |
References error().
Referenced by _finishTransaction(), GeoFenceManager::GeoFenceManager(), and RallyPointManager::RallyPointManager().
|
signal |
Referenced by _finishTransaction().
|
signal |
Referenced by _finishTransaction().
|
signal |
References error().
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 59 of file PlanManager.cc.
References _clearAndDeleteWriteMissionItems(), _planType, _planTypeString(), _vehicle, _writeMissionItems, _writeMissionItemsWorker(), MissionItem::command(), inProgress(), missionItems(), MissionItem::param1(), MissionItem::sequenceNumber(), MissionItem::setIsCurrentItem(), MissionItem::setParam1(), and MissionItem::setSequenceNumber().
Referenced by MissionController::sendItemsToVehicle(), GeoFenceManager::sendToVehicle(), and RallyPointManager::sendToVehicle().
|
staticconstexpr |
Definition at line 59 of file PlanManager.h.
Referenced by _startAckTimeout().
|
protected |
Definition at line 129 of file PlanManager.h.
Referenced by _checkForExpectedAck(), _startAckTimeout(), and PlanManager().
|
protected |
Definition at line 142 of file PlanManager.h.
Referenced by _finishTransaction(), MissionManager::currentIndex(), currentIndex(), PlanManager(), and removeAll().
|
protected |
Definition at line 130 of file PlanManager.h.
Referenced by _checkForExpectedAck(), _handleMissionAck(), _startAckTimeout(), and PlanManager().
|
protected |
List of mission items which still need to be requested from vehicle.
Definition at line 136 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 135 of file PlanManager.h.
Referenced by _finishTransaction(), _handleMissionAck(), _handleMissionRequest(), and _writeMissionItemsWorker().
|
protected |
Definition at line 143 of file PlanManager.h.
Referenced by _finishTransaction(), MissionManager::lastCurrentIndex(), lastCurrentIndex(), PlanManager(), and removeAll().
|
protected |
Index of item last requested by MISSION_REQUEST.
Definition at line 137 of file PlanManager.h.
Referenced by _handleMissionRequest(), _lastMissionReqestString(), _writeMissionItemsWorker(), and PlanManager().
|
staticconstexpr |
Definition at line 62 of file PlanManager.h.
|
protected |
Count of all mission items to read.
Definition at line 138 of file PlanManager.h.
Referenced by _handleMissionCount(), _handleMissionItem(), and PlanManager().
|
protected |
Set of mission items on vehicle.
Definition at line 140 of file PlanManager.h.
Referenced by _clearAndDeleteMissionItems(), _finishTransaction(), _handleMissionItem(), MissionManager::generateResumeMission(), and missionItems().
|
protected |
Definition at line 127 of file PlanManager.h.
Referenced by _finishTransaction(), _handleMissionAck(), _handleMissionCount(), _handleMissionItem(), _handleMissionRequest(), _planTypeString(), _readTransactionComplete(), _removeAllWorker(), _requestList(), _requestNextMissionItem(), _sendMissionItem(), _writeMissionCount(), PlanManager(), removeAll(), and writeMissionItems().
|
protected |
Definition at line 134 of file PlanManager.h.
Referenced by _finishTransaction(), MissionManager::generateResumeMission(), and PlanManager().
|
protected |
Definition at line 131 of file PlanManager.h.
Referenced by _handleMissionAck(), _handleMissionCount(), _handleMissionItem(), _handleMissionRequest(), _requestList(), _requestNextMissionItem(), _writeMissionCount(), _writeMissionItemsWorker(), loadFromVehicle(), and removeAll().
|
staticconstexpr |
Definition at line 61 of file PlanManager.h.
Referenced by _startAckTimeout().
|
protected |
Definition at line 133 of file PlanManager.h.
Referenced by _finishTransaction(), inProgress(), PlanManager(), and MissionManager::writeArduPilotGuidedMissionItem().
|
protected |
Definition at line 126 of file PlanManager.h.
Referenced by _connectToMavlink(), _disconnectFromMavlink(), _handleMissionAck(), _handleMissionItem(), _readTransactionComplete(), _removeAllWorker(), _requestList(), _requestNextMissionItem(), _sendMissionItem(), _writeMissionCount(), MissionManager::generateResumeMission(), loadFromVehicle(), MissionManager::MissionManager(), PlanManager(), GeoFenceManager::supported(), RallyPointManager::supported(), MissionManager::writeArduPilotGuidedMissionItem(), and writeMissionItems().
|
protected |
Set of mission items currently being written to vehicle.
Definition at line 141 of file PlanManager.h.
Referenced by _clearAndDeleteWriteMissionItems(), _finishTransaction(), _handleMissionRequest(), _lastMissionReqestString(), _sendMissionItem(), _writeMissionCount(), _writeMissionItemsWorker(), MissionManager::generateResumeMission(), and writeMissionItems().
|
staticconstexpr |
Ack timeout used in unit tests (much shorter for faster tests).
Definition at line 65 of file PlanManager.h.
Referenced by _startAckTimeout().