Remove deprecated UAS class

This commit is contained in:
Holden
2024-02-10 19:15:39 -05:00
committed by Don Gagne
parent 3cfd79c6f8
commit 3b81f6cc6f
48 changed files with 50 additions and 786 deletions
-1
View File
@@ -21,7 +21,6 @@
#include <limits.h>
#include "Fact.h"
#include "UASInterface.h"
// Note how the Qt headers, System, headers and the QGroundControl headers above are kept in separate groups
-3
View File
@@ -731,8 +731,6 @@ HEADERS += \
src/comm/TCPLink.h \
src/comm/UDPLink.h \
src/comm/UdpIODevice.h \
src/uas/UAS.h \
src/uas/UASInterface.h \
src/uas/UASMessageHandler.h \
src/AnalyzeView/GeoTagController.h \
src/AnalyzeView/ExifParser.h \
@@ -989,7 +987,6 @@ SOURCES += \
src/comm/UDPLink.cc \
src/comm/UdpIODevice.cc \
src/main.cc \
src/uas/UAS.cc \
src/uas/UASMessageHandler.cc \
src/AnalyzeView/GeoTagController.cc \
src/AnalyzeView/ExifParser.cc \
+13 -19
View File
@@ -10,7 +10,6 @@
#include "LogDownloadController.h"
#include "MultiVehicleManager.h"
#include "UAS.h"
#include "QGCApplication.h"
#include "QGCToolbox.h"
#include "QGCMapEngine.h"
@@ -103,8 +102,7 @@ QGCLogEntry::sizeStr() const
//----------------------------------------------------------------------------------------
LogDownloadController::LogDownloadController(void)
: _uas(nullptr)
, _downloadData(nullptr)
: _downloadData(nullptr)
, _vehicle(nullptr)
, _requestingLogEntries(false)
, _downloadingLogs(false)
@@ -132,26 +130,24 @@ LogDownloadController::_processDownload()
void
LogDownloadController::_setActiveVehicle(Vehicle* vehicle)
{
if(_uas) {
if(_vehicle) {
_logEntriesModel.clearAndDeleteContents();
disconnect(_uas, &UASInterface::logEntry, this, &LogDownloadController::_logEntry);
disconnect(_uas, &UASInterface::logData, this, &LogDownloadController::_logData);
_uas = nullptr;
disconnect(_vehicle, &Vehicle::logEntry, this, &LogDownloadController::_logEntry);
disconnect(_vehicle, &Vehicle::logData, this, &LogDownloadController::_logData);
}
_vehicle = vehicle;
if(_vehicle) {
_uas = vehicle->uas();
connect(_uas, &UASInterface::logEntry, this, &LogDownloadController::_logEntry);
connect(_uas, &UASInterface::logData, this, &LogDownloadController::_logData);
connect(_vehicle, &Vehicle::logEntry, this, &LogDownloadController::_logEntry);
connect(_vehicle, &Vehicle::logData, this, &LogDownloadController::_logData);
}
}
//----------------------------------------------------------------------------------------
void
LogDownloadController::_logEntry(UASInterface* uas, uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t /*last_log_num*/)
LogDownloadController::_logEntry(uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t /*last_log_num*/)
{
//-- Do we care?
if(!_uas || uas != _uas || !_requestingLogEntries) {
if(!_requestingLogEntries) {
return;
}
//-- If this is the first, pre-fill it
@@ -312,9 +308,9 @@ void LogDownloadController::_updateDataRate(void)
//----------------------------------------------------------------------------------------
void
LogDownloadController::_logData(UASInterface* uas, uint32_t ofs, uint16_t id, uint8_t count, const uint8_t* data)
LogDownloadController::_logData(uint32_t ofs, uint16_t id, uint8_t count, const uint8_t* data)
{
if(!_uas || uas != _uas || !_downloadData) {
if(!_downloadData) {
return;
}
//-- APM "Fix"
@@ -499,7 +495,7 @@ LogDownloadController::refresh(void)
void
LogDownloadController::_requestLogList(uint32_t start, uint32_t end)
{
if(_vehicle && _uas) {
if(_vehicle) {
qCDebug(LogDownloadLog) << "Request log entry list (" << start << "through" << end << ")";
_setListing(true);
WeakLinkInterfacePtr weakLink = _vehicle->vehicleLinkManager()->primaryLink();
@@ -675,7 +671,7 @@ LogDownloadController::_setListing(bool active)
void
LogDownloadController::eraseAll(void)
{
if(_vehicle && _uas) {
if(_vehicle) {
WeakLinkInterfacePtr weakLink = _vehicle->vehicleLinkManager()->primaryLink();
if (!weakLink.expired()) {
SharedLinkInterfacePtr sharedLink = weakLink.lock();
@@ -697,9 +693,7 @@ LogDownloadController::eraseAll(void)
void
LogDownloadController::cancel(void)
{
if(_uas){
_receivedAllEntries();
}
_receivedAllEntries();
if(_downloadData) {
_downloadData->entry->setStatus(tr("Canceled"));
if (_downloadData->file.exists()) {
+2 -5
View File
@@ -19,12 +19,10 @@
#include <memory>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "QmlObjectListModel.h"
class MultiVehicleManager;
class UASInterface;
class Vehicle;
struct LogDownloadData;
@@ -107,8 +105,8 @@ signals:
private slots:
void _setActiveVehicle (Vehicle* vehicle);
void _logEntry (UASInterface *uas, uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t last_log_num);
void _logData (UASInterface *uas, uint32_t ofs, uint16_t id, uint8_t count, const uint8_t *data);
void _logEntry (uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t last_log_num);
void _logData (uint32_t ofs, uint16_t id, uint8_t count, const uint8_t *data);
void _processDownload ();
private:
@@ -129,7 +127,6 @@ private:
QGCLogEntry* _getNextSelected();
UASInterface* _uas;
LogDownloadData* _downloadData;
QTimer _timer;
QmlObjectListModel _logEntriesModel;
@@ -9,7 +9,6 @@
#include "MavlinkConsoleController.h"
#include "QGCApplication.h"
#include "UAS.h"
#include <QClipboard>
@@ -14,7 +14,6 @@
#include <QList>
#include <QAbstractListModel>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "FactPanelController.h"
@@ -9,7 +9,6 @@
#include "APMAutoPilotPlugin.h"
#include "UAS.h"
#include "APMParameterMetaData.h"
#include "APMFirmwarePlugin.h"
#include "ArduCopterFirmwarePlugin.h"
@@ -16,7 +16,6 @@
#include <QList>
#include <QStringList>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "FactPanelController.h"
#include "Vehicle.h"
@@ -10,7 +10,6 @@
#include "APMSensorsComponentController.h"
#include "QGCMAVLink.h"
#include "UAS.h"
#include "QGCApplication.h"
#include "APMAutoPilotPlugin.h"
#include "ParameterManager.h"
@@ -11,7 +11,6 @@
#include <QObject>
#include "UASInterface.h"
#include "FactPanelController.h"
#include "QGCLoggingCategory.h"
#include "APMSensorsComponent.h"
@@ -14,7 +14,6 @@
#include "ESP8266ComponentController.h"
#include "QGCApplication.h"
#include "UAS.h"
#include "ParameterManager.h"
#include <QHostAddress>
@@ -19,7 +19,6 @@
#include <QTimer>
#include "FactPanelController.h"
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h"
@@ -650,7 +650,7 @@ void RadioComponentController::_setInternalCalibrationValuesFromParameters(void)
void RadioComponentController::spektrumBindMode(int mode)
{
_uas->pairRX(0, mode);
_vehicle->pairRX(0, mode);
}
/// @brief Validates the current settings against the calibration rules resetting values as necessary.
@@ -702,7 +702,7 @@ void RadioComponentController::_validateCalibration(void)
/// @brief Saves the rc calibration values to the board parameters.
void RadioComponentController::_writeCalibration(void)
{
if (!_uas) return;
if (!_vehicle) return;
if (!_px4Vehicle() && (_vehicle->vehicleType() == MAV_TYPE_HELICOPTER || _vehicle->multiRotor()) && _rgChannelInfo[_rgFunctionChannelMapping[rcCalFunctionThrottle]].reversed) {
// A reversed throttle could lead to dangerous power up issues if the firmware doesn't handle it absolutely correctly in all places.
@@ -811,7 +811,7 @@ void RadioComponentController::_stopCalibration(void)
{
_currentStep = -1;
if (_uas) {
if (_vehicle) {
// Only PX4 is known to support this command in all versions. For other firmware which may or may not
// support this we don't show errors on failure.
_vehicle->stopCalibration(_px4Vehicle() ? true : false /* showError */);
@@ -19,7 +19,6 @@
#include <QTimer>
#include "FactPanelController.h"
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h"
@@ -9,7 +9,6 @@
#include "SyslinkComponentController.h"
#include "QGCApplication.h"
#include "UAS.h"
#include "ParameterManager.h"
#include <QHostAddress>
@@ -11,7 +11,6 @@
#define SyslinkComponentController_H
#include "FactPanelController.h"
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h"
@@ -19,7 +19,6 @@
#include <QList>
#include <QMap>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
/// MVC Controller for AirframeComponent.qml.
@@ -18,7 +18,6 @@
#include <QQuickItem>
#include <QList>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "FactPanelController.h"
@@ -25,10 +25,9 @@ QGC_LOGGING_CATEGORY(PX4AirframeLoaderLog, "PX4AirframeLoaderLog")
bool PX4AirframeLoader::_airframeMetaDataLoaded = false;
PX4AirframeLoader::PX4AirframeLoader(AutoPilotPlugin* autopilot, UASInterface* uas, QObject* parent)
PX4AirframeLoader::PX4AirframeLoader(AutoPilotPlugin* autopilot, QObject* parent)
{
Q_UNUSED(autopilot);
Q_UNUSED(uas);
Q_UNUSED(parent);
}
+1 -2
View File
@@ -18,7 +18,6 @@
#include "ParameterManager.h"
#include "FactSystem.h"
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
/// @file PX4AirframeLoader.h
@@ -34,7 +33,7 @@ class PX4AirframeLoader : QObject
public:
/// @param uas Uas which this set of facts is associated with
PX4AirframeLoader(AutoPilotPlugin* autpilot,UASInterface* uas, QObject* parent = nullptr);
PX4AirframeLoader(AutoPilotPlugin* autpilot, QObject* parent = nullptr);
static void loadAirframeMetaData(void);
@@ -11,7 +11,6 @@
#include "PX4AutoPilotPlugin.h"
#include "PX4AirframeLoader.h"
#include "AirframeComponentController.h"
#include "UAS.h"
#include "FirmwarePlugin/PX4/PX4ParameterMetaData.h" // FIXME: Hack
#include "FirmwarePlugin/PX4/PX4FirmwarePlugin.h" // FIXME: Hack
#include "QGCApplication.h"
@@ -48,7 +47,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(Vehicle* vehicle, QObject* parent)
return;
}
_airframeFacts = new PX4AirframeLoader(this, _vehicle->uas(), this);
_airframeFacts = new PX4AirframeLoader(this, this);
Q_CHECK_PTR(_airframeFacts);
PX4AirframeLoader::loadAirframeMetaData();
@@ -16,7 +16,6 @@
#include <QList>
#include <QStringList>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "FactPanelController.h"
#include "Vehicle.h"
@@ -9,7 +9,6 @@
#include "PowerComponentController.h"
#include "QGCMAVLink.h"
#include "UAS.h"
#include <QVariant>
#include <QQmlProperty>
@@ -17,7 +17,6 @@
#include <QObject>
#include <QQuickItem>
#include "UASInterface.h"
#include "FactPanelController.h"
/// Power Component MVC Controller for PowerComponent.qml.
@@ -9,7 +9,6 @@
#include "SensorsComponentController.h"
#include "QGCMAVLink.h"
#include "UAS.h"
#include "QGCApplication.h"
#include "ParameterManager.h"
@@ -17,7 +17,6 @@
#include <QObject>
#include <QQuickItem>
#include "UASInterface.h"
#include "FactPanelController.h"
#include "QGCLoggingCategory.h"
@@ -9,7 +9,6 @@
#include "FactPanelController.h"
#include "MultiVehicleManager.h"
#include "UAS.h"
#include "QGCApplication.h"
#include "ParameterManager.h"
@@ -24,7 +23,6 @@ FactPanelController::FactPanelController()
{
_vehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle();
if (_vehicle) {
_uas = _vehicle->uas();
_autopilot = _vehicle->autopilotPlugin();
} else {
_vehicle = qgcApp()->toolbox()->multiVehicleManager()->offlineEditingVehicle();
@@ -16,7 +16,6 @@
#include <QObject>
#include <QQuickItem>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "QGCLoggingCategory.h"
@@ -50,7 +49,6 @@ protected:
void _reportMissingParameter(int componentId, const QString& name);
Vehicle* _vehicle = nullptr;
UASInterface* _uas = nullptr;
AutoPilotPlugin* _autopilot = nullptr;
private slots:
-1
View File
@@ -15,7 +15,6 @@
#define FactSystemTestBase_H
#include "UnitTest.h"
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
// Base class for FactSystemTest[PX4|Generic] unit tests
-1
View File
@@ -15,7 +15,6 @@
#define FactSystemTestGeneric_H
#include "FactSystemTestBase.h"
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
// Unit Test for Fact System on PX4 autopilot
-1
View File
@@ -15,7 +15,6 @@
#define FactSystemTestPX4_H
#include "FactSystemTestBase.h"
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
// Unit Test for Fact System on PX4 autopilot
-1
View File
@@ -13,7 +13,6 @@
#include "QGCApplication.h"
#include "UASMessageHandler.h"
#include "FirmwarePlugin.h"
#include "UAS.h"
#include "JsonHelper.h"
#include "ComponentInformationManager.h"
#include "CompInfoParam.h"
-1
View File
@@ -11,7 +11,6 @@
#include "Joystick.h"
#include "QGC.h"
#include "AutoPilotPlugin.h"
#include "UAS.h"
#include "QGCApplication.h"
#include "VideoManager.h"
#include "QGCCameraManager.h"
@@ -13,7 +13,6 @@
#include <QList>
#include "AutoPilotPlugin.h"
#include "UASInterface.h"
#include "FactPanelController.h"
#include "QmlObjectListModel.h"
#include "ParameterManager.h"
@@ -14,7 +14,6 @@
#include <QTimer>
#include "FactPanelController.h"
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h"
-1
View File
@@ -14,7 +14,6 @@
#include <QTimer>
#include <QQueue>
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "QGCMAVLink.h"
-3
View File
@@ -10,7 +10,6 @@
#include "MultiVehicleManager.h"
#include "AutoPilotPlugin.h"
#include "MAVLinkProtocol.h"
#include "UAS.h"
#include "QGCApplication.h"
#include "FollowMe.h"
#include "ParameterManager.h"
@@ -205,8 +204,6 @@ void MultiVehicleManager::_deleteVehiclePhase1(Vehicle* vehicle)
qWarning() << "Vehicle not found in map!";
}
vehicle->uas()->shutdownVehicle();
// First we must signal that a vehicle is no longer available.
_activeVehicleAvailable = false;
_parameterReadyVehicleAvailable = false;
-2
View File
@@ -50,8 +50,6 @@ public:
Q_INVOKABLE Vehicle* getVehicleById(int vehicleId);
UAS* activeUas(void) { return _activeVehicle ? _activeVehicle->uas() : nullptr; }
// Property accessors
bool activeVehicleAvailable(void) const{ return _activeVehicleAvailable; }
+24 -12
View File
@@ -19,7 +19,6 @@
#include "FirmwarePluginManager.h"
#include "LinkManager.h"
#include "FirmwarePlugin.h"
#include "UAS.h"
#include "JoystickManager.h"
#include "MissionManager.h"
#include "MissionController.h"
@@ -201,9 +200,6 @@ Vehicle::Vehicle(LinkInterface* link,
connect(_toolbox->multiVehicleManager(), &MultiVehicleManager::parameterReadyVehicleAvailableChanged, this, &Vehicle::_vehicleParamLoaded);
_uas = new UAS(_mavlink, this, _firmwarePluginManager);
_uas->setParent(this);
connect(this, &Vehicle::remoteControlRSSIChanged, this, &Vehicle::_remoteControlRSSIChanged);
_commonInit();
@@ -242,8 +238,6 @@ Vehicle::Vehicle(LinkInterface* link,
_chunkedStatusTextTimer.setInterval(1000);
connect(&_chunkedStatusTextTimer, &QTimer::timeout, this, &Vehicle::_chunkedStatusTextTimeout);
_mav = uas();
// Listen for system messages
connect(_toolbox->uasMessageHandler(), &UASMessageHandler::textMessageCountChanged, this, &Vehicle::_handleTextMessage);
connect(_toolbox->uasMessageHandler(), &UASMessageHandler::textMessageReceived, this, &Vehicle::_handletextMessageReceived);
@@ -520,9 +514,6 @@ Vehicle::~Vehicle()
delete _autopilotPlugin;
_autopilotPlugin = nullptr;
delete _mav;
_mav = nullptr;
#ifdef CONFIG_UTM_ADAPTER
delete _utmspVehicle;
#endif
@@ -822,13 +813,25 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
_handleRangefinder(message);
break;
#endif
case MAVLINK_MSG_ID_LOG_ENTRY:
{
mavlink_log_entry_t log;
mavlink_msg_log_entry_decode(&message, &log);
emit logEntry(log.time_utc, log.size, log.id, log.num_logs, log.last_log_num);
break;
}
case MAVLINK_MSG_ID_LOG_DATA:
{
mavlink_log_data_t log;
mavlink_msg_log_data_decode(&message, &log);
emit logData(log.ofs, log.id, log.count, log.data);
break;
}
}
// This must be emitted after the vehicle processes the message. This way the vehicle state is up to date when anyone else
// does processing.
emit mavlinkMessageReceived(message);
_uas->receiveMessage(message);
}
#if !defined(NO_ARDUPILOT_DIALECT)
@@ -4582,4 +4585,13 @@ void Vehicle::setEstimatorOrigin(const QGeoCoordinate& centerCoord)
static_cast<float>(qQNaN())
);
sendMessageOnLinkThreadSafe(sharedLink.get(), msg);
}
}
void Vehicle::pairRX(int rxType, int rxSubType)
{
sendMavCommand(_defaultComponentId,
MAV_CMD_START_RX_PAIR,
true,
rxType,
rxSubType);
}
+5 -6
View File
@@ -60,7 +60,6 @@
class Actuators;
class EventHandler;
class UAS;
class UASInterface;
class FirmwarePlugin;
class FirmwarePluginManager;
class AutoPilotPlugin;
@@ -538,9 +537,6 @@ public:
/// guarantee that it makes it to the vehicle.
void sendMessageMultiple(mavlink_message_t message);
/// Provides access to uas from vehicle. Temporary workaround until UAS is fully phased out.
UAS* uas() { return _uas; }
/// Provides access to uas from vehicle. Temporary workaround until AutoPilotPlugin is fully phased out.
AutoPilotPlugin* autopilotPlugin() { return _autopilotPlugin; }
@@ -578,6 +574,8 @@ public:
void setGripperAction(GRIPPER_ACTIONS gripperAction);
Q_INVOKABLE void sendGripperAction(GRIPPER_OPTIONS gripperOption);
void pairRX(int rxType, int rxSubType);
bool fixedWing() const;
bool multiRotor() const;
bool vtol() const;
@@ -630,7 +628,6 @@ public:
QString formattedMessages ();
float latitude () { return static_cast<float>(_coordinate.latitude()); }
float longitude () { return static_cast<float>(_coordinate.longitude()); }
bool mavPresent () { return _mav != nullptr; }
int rcRSSI () const{ return _rcRSSI; }
bool px4Firmware () const { return _firmwareType == MAV_AUTOPILOT_PX4; }
bool apmFirmware () const { return _firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA; }
@@ -1061,6 +1058,9 @@ signals:
void sensorsParametersResetAck (bool success);
void logEntry (uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t last_log_num);
void logData (uint32_t ofs, uint16_t id, uint8_t count, const uint8_t* data);
private slots:
void _mavlinkMessageReceived (LinkInterface* link, mavlink_message_t message);
void _sendMessageMultipleNext ();
@@ -1183,7 +1183,6 @@ private:
QGeoCoordinate _homePosition;
QGeoCoordinate _armedPosition;
UASInterface* _mav = nullptr;
int _currentMessageCount = 0;
int _messageCount = 0;
int _currentErrorCount = 0;
-3
View File
@@ -21,9 +21,6 @@
#include <QFileInfo>
#include "MAVLinkProtocol.h"
#include "UASInterface.h"
#include "UASInterface.h"
#include "UAS.h"
#include "LinkManager.h"
#include "QGCMAVLink.h"
#include "QGC.h"
-4
View File
@@ -13,7 +13,6 @@
#include "FileManagerTest.h"
#include "MultiVehicleManager.h"
#include "UAS.h"
#include "QGCApplication.h"
FileManagerTest::FileManagerTest(void)
@@ -34,9 +33,6 @@ void FileManagerTest::init(void)
_fileServer = _mockLink->getFileServer();
QVERIFY(_fileServer != NULL);
_fileManager = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()->uas()->getFileManager();
QVERIFY(_fileManager != NULL);
Q_ASSERT(_multiSpy == NULL);
// Reset any internal state back to normal
-1
View File
@@ -17,7 +17,6 @@
#include "MockLink.h"
#include "QGCTemporaryFile.h"
#include "QGCApplication.h"
#include "UAS.h"
#include "MultiVehicleManager.h"
const char* MavlinkLogTest::_tempLogFileTemplate = "FlightDataXXXXXX"; ///< Template for temporary log file
-3
View File
@@ -1,8 +1,5 @@
add_library(uas
UAS.cc
UAS.h
UASInterface.h
UASMessageHandler.cc
UASMessageHandler.h
)
-398
View File
@@ -1,398 +0,0 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
// NO NEW CODE HERE
// UASInterface, UAS.h/cc are deprecated. All new functionality should go into Vehicle.h/cc
//
#include <QList>
#include <QTimer>
#include <QSettings>
#include <iostream>
#include <QDebug>
#include <cmath>
#include <qmath.h>
#include <limits>
#include <cstdlib>
#include "UAS.h"
#include "LinkInterface.h"
#include "QGC.h"
#include "MAVLinkProtocol.h"
#include "QGCMAVLink.h"
#include "LinkManager.h"
#ifndef NO_SERIAL_LINK
#include "SerialLink.h"
#endif
#include "FirmwarePluginManager.h"
#include "QGCLoggingCategory.h"
#include "Vehicle.h"
#include "Joystick.h"
#include "QGCApplication.h"
QGC_LOGGING_CATEGORY(UASLog, "UASLog")
// THIS CLASS IS DEPRECATED. ALL NEW FUNCTIONALITY SHOULD GO INTO Vehicle class
UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle, FirmwarePluginManager * firmwarePluginManager) : UASInterface(),
lipoFull(4.2f),
lipoEmpty(3.5f),
uasId(vehicle->id()),
unknownPackets(),
mavlink(protocol),
receiveDropRate(0),
sendDropRate(0),
status(-1),
startTime(QGC::groundTimeMilliseconds()),
onboardTimeOffset(0),
controlRollManual(true),
controlPitchManual(true),
controlYawManual(true),
controlThrustManual(true),
attitudeKnown(false),
attitudeStamped(false),
lastAttitude(0),
blockHomePositionChanges(false),
// Note variances calculated from flight case from this log: http://dash.oznet.ch/view/MRjW8NUNYQSuSZkbn8dEjY
// TODO: calibrate stand-still pixhawk variances
xacc_var(0.6457f),
yacc_var(0.7048f),
zacc_var(0.97885f),
rollspeed_var(0.8126f),
pitchspeed_var(0.6145f),
yawspeed_var(0.5852f),
xmag_var(0.2393f),
ymag_var(0.2283f),
zmag_var(0.1665f),
abs_pressure_var(0.5802f),
diff_pressure_var(0.5802f),
pressure_alt_var(0.5802f),
temperature_var(0.7145f),
/*
xacc_var(0.0f),
yacc_var(0.0f),
zacc_var(0.0f),
rollspeed_var(0.0f),
pitchspeed_var(0.0f),
yawspeed_var(0.0f),
xmag_var(0.0f),
ymag_var(0.0f),
zmag_var(0.0f),
abs_pressure_var(0.0f),
diff_pressure_var(0.0f),
pressure_alt_var(0.0f),
temperature_var(0.0f),
*/
// The protected members.
connectionLost(false),
lastVoltageWarning(0),
lastNonNullTime(0),
onboardTimeOffsetInvalidCount(0),
_vehicle(vehicle),
_firmwarePluginManager(firmwarePluginManager)
{
}
/**
* @ return the id of the uas
*/
int UAS::getUASID() const
{
return uasId;
}
// Ignore warnings from mavlink headers for both GCC/Clang and MSVC
#ifdef __GNUC__
#if __GNUC__ > 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Waddress-of-packed-member"
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#endif
#else
#pragma warning(push, 0)
#endif
void UAS::receiveMessage(mavlink_message_t message)
{
// Only accept messages from this system (condition 1)
// and only then if a) attitudeStamped is disabled OR b) attitudeStamped is enabled
// and we already got one attitude packet
if (message.sysid == uasId && (!attitudeStamped || lastAttitude != 0 || message.msgid == MAVLINK_MSG_ID_ATTITUDE))
{
switch (message.msgid)
{
case MAVLINK_MSG_ID_LOG_ENTRY:
{
mavlink_log_entry_t log;
mavlink_msg_log_entry_decode(&message, &log);
emit logEntry(this, log.time_utc, log.size, log.id, log.num_logs, log.last_log_num);
}
break;
case MAVLINK_MSG_ID_LOG_DATA:
{
mavlink_log_data_t log;
mavlink_msg_log_data_decode(&message, &log);
emit logData(this, log.ofs, log.id, log.count, log.data);
}
break;
default:
break;
}
}
}
// Pop warnings ignoring for mavlink headers for both GCC/Clang and MSVC
#ifdef __GNUC__
#if defined(__clang__)
#pragma clang diagnostic pop
#else
#pragma GCC diagnostic pop
#endif
#else
#pragma warning(pop, 0)
#endif
/**
* Check if time is smaller than 40 years, assuming no system without Unix
* timestamp runs longer than 40 years continuously without reboot. In worst case
* this will add/subtract the communication delay between GCS and MAV, it will
* never alter the timestamp in a safety critical way.
*/
quint64 UAS::getUnixReferenceTime(quint64 time)
{
// Same as getUnixTime, but does not react to attitudeStamped mode
if (time == 0)
{
// qDebug() << "XNEW time:" <<QGC::groundTimeMilliseconds();
return QGC::groundTimeMilliseconds();
}
// Check if time is smaller than 40 years,
// assuming no system without Unix timestamp
// runs longer than 40 years continuously without
// reboot. In worst case this will add/subtract the
// communication delay between GCS and MAV,
// it will never alter the timestamp in a safety
// critical way.
//
// Calculation:
// 40 years
// 365 days
// 24 hours
// 60 minutes
// 60 seconds
// 1000 milliseconds
// 1000 microseconds
#ifndef _MSC_VER
else if (time < 1261440000000000LLU)
#else
else if (time < 1261440000000000)
#endif
{
// qDebug() << "GEN time:" << time/1000 + onboardTimeOffset;
if (onboardTimeOffset == 0)
{
onboardTimeOffset = QGC::groundTimeMilliseconds() - time/1000;
}
return time/1000 + onboardTimeOffset;
}
else
{
// Time is not zero and larger than 40 years -> has to be
// a Unix epoch timestamp. Do nothing.
return time/1000;
}
}
/**
* @warning If attitudeStamped is enabled, this function will not actually return
* the precise time stamp of this measurement augmented to UNIX time, but will
* MOVE the timestamp IN TIME to match the last measured attitude. There is no
* reason why one would want this, except for system setups where the onboard
* clock is not present or broken and datasets should be collected that are still
* roughly synchronized. PLEASE NOTE THAT ENABLING ATTITUDE STAMPED RUINS THE
* SCIENTIFIC NATURE OF THE CORRECT LOGGING FUNCTIONS OF QGROUNDCONTROL!
*/
quint64 UAS::getUnixTimeFromMs(quint64 time)
{
return getUnixTime(time*1000);
}
/**
* @warning If attitudeStamped is enabled, this function will not actually return
* the precise time stam of this measurement augmented to UNIX time, but will
* MOVE the timestamp IN TIME to match the last measured attitude. There is no
* reason why one would want this, except for system setups where the onboard
* clock is not present or broken and datasets should be collected that are
* still roughly synchronized. PLEASE NOTE THAT ENABLING ATTITUDE STAMPED
* RUINS THE SCIENTIFIC NATURE OF THE CORRECT LOGGING FUNCTIONS OF QGROUNDCONTROL!
*/
quint64 UAS::getUnixTime(quint64 time)
{
quint64 ret = 0;
if (attitudeStamped)
{
ret = lastAttitude;
}
if (time == 0)
{
ret = QGC::groundTimeMilliseconds();
}
// Check if time is smaller than 40 years,
// assuming no system without Unix timestamp
// runs longer than 40 years continuously without
// reboot. In worst case this will add/subtract the
// communication delay between GCS and MAV,
// it will never alter the timestamp in a safety
// critical way.
//
// Calculation:
// 40 years
// 365 days
// 24 hours
// 60 minutes
// 60 seconds
// 1000 milliseconds
// 1000 microseconds
#ifndef _MSC_VER
else if (time < 1261440000000000LLU)
#else
else if (time < 1261440000000000)
#endif
{
// qDebug() << "GEN time:" << time/1000 + onboardTimeOffset;
if (onboardTimeOffset == 0 || time < (lastNonNullTime - 100))
{
lastNonNullTime = time;
onboardTimeOffset = QGC::groundTimeMilliseconds() - time/1000;
}
if (time > lastNonNullTime) lastNonNullTime = time;
ret = time/1000 + onboardTimeOffset;
}
else
{
// Time is not zero and larger than 40 years -> has to be
// a Unix epoch timestamp. Do nothing.
ret = time/1000;
}
return ret;
}
/**
* Get the status of the code and a description of the status.
* Status can be unitialized, booting up, calibrating sensors, active
* standby, cirtical, emergency, shutdown or unknown.
*/
void UAS::getStatusForCode(int statusCode, QString& uasState, QString& stateDescription)
{
switch (statusCode)
{
case MAV_STATE_UNINIT:
uasState = tr("UNINIT");
stateDescription = tr("Unitialized, booting up.");
break;
case MAV_STATE_BOOT:
uasState = tr("BOOT");
stateDescription = tr("Booting system, please wait.");
break;
case MAV_STATE_CALIBRATING:
uasState = tr("CALIBRATING");
stateDescription = tr("Calibrating sensors, please wait.");
break;
case MAV_STATE_ACTIVE:
uasState = tr("ACTIVE");
stateDescription = tr("Active, normal operation.");
break;
case MAV_STATE_STANDBY:
uasState = tr("STANDBY");
stateDescription = tr("Standby mode, ready for launch.");
break;
case MAV_STATE_CRITICAL:
uasState = tr("CRITICAL");
stateDescription = tr("FAILURE: Continuing operation.");
break;
case MAV_STATE_EMERGENCY:
uasState = tr("EMERGENCY");
stateDescription = tr("EMERGENCY: Land Immediately!");
break;
//case MAV_STATE_HILSIM:
//uasState = tr("HIL SIM");
//stateDescription = tr("HIL Simulation, Sensors read from SIM");
//break;
case MAV_STATE_POWEROFF:
uasState = tr("SHUTDOWN");
stateDescription = tr("Powering off system.");
break;
default:
uasState = tr("UNKNOWN");
stateDescription = tr("Unknown system state");
break;
}
}
/* MANAGEMENT */
/**
*
* @return The uptime in milliseconds
*
*/
quint64 UAS::getUptime() const
{
if(startTime == 0)
{
return 0;
}
else
{
return QGC::groundTimeMilliseconds() - startTime;
}
}
/**
* Order the robot to start receiver pairing
*/
void UAS::pairRX(int rxType, int rxSubType)
{
if (_vehicle) {
_vehicle->sendMavCommand(_vehicle->defaultComponentId(), // target component
MAV_CMD_START_RX_PAIR, // command id
true, // showError
rxType,
rxSubType);
}
}
void UAS::shutdownVehicle(void)
{
_vehicle = nullptr;
}
-190
View File
@@ -1,190 +0,0 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
// NO NEW CODE HERE
// UASInterface, UAS.h/cc are deprecated. All new functionality should go into Vehicle.h/cc
//
#pragma once
#include "UASInterface.h"
#include <MAVLinkProtocol.h>
#include <QVector3D>
#include "QGCMAVLink.h"
#include "Vehicle.h"
#include "FirmwarePluginManager.h"
Q_DECLARE_LOGGING_CATEGORY(UASLog)
class Vehicle;
/**
* @brief A generic MAVLINK-connected MAV/UAV
*
* This class represents one vehicle. It can be used like the real vehicle, e.g. a call to halt()
* will automatically send the appropriate messages to the vehicle. The vehicle state will also be
* automatically updated by the comm architecture, so when writing code to e.g. control the vehicle
* no knowledge of the communication infrastructure is needed.
*/
class UAS : public UASInterface
{
Q_OBJECT
public:
UAS(MAVLinkProtocol* protocol, Vehicle* vehicle, FirmwarePluginManager * firmwarePluginManager);
float lipoFull; ///< 100% charged voltage
float lipoEmpty; ///< Discharged voltage
/* MANAGEMENT */
/** @brief Get the unique system id */
int getUASID() const;
/** @brief The time interval the robot is switched on */
quint64 getUptime() const;
/// Vehicle is about to go away
void shutdownVehicle(void);
// Setters for HIL noise variance
void setXaccVar(float var){
xacc_var = var;
}
void setYaccVar(float var){
yacc_var = var;
}
void setZaccVar(float var){
zacc_var = var;
}
void setRollSpeedVar(float var){
rollspeed_var = var;
}
void setPitchSpeedVar(float var){
pitchspeed_var = var;
}
void setYawSpeedVar(float var){
pitchspeed_var = var;
}
void setXmagVar(float var){
xmag_var = var;
}
void setYmagVar(float var){
ymag_var = var;
}
void setZmagVar(float var){
zmag_var = var;
}
void setAbsPressureVar(float var){
abs_pressure_var = var;
}
void setDiffPressureVar(float var){
diff_pressure_var = var;
}
void setPressureAltVar(float var){
pressure_alt_var = var;
}
void setTemperatureVar(float var){
temperature_var = var;
}
protected:
/// LINK ID AND STATUS
int uasId; ///< Unique system ID
QList<int> unknownPackets; ///< Packet IDs which are unknown and have been received
MAVLinkProtocol* mavlink; ///< Reference to the MAVLink instance
float receiveDropRate; ///< Percentage of packets that were dropped on the MAV's receiving link (from GCS and other MAVs)
float sendDropRate; ///< Percentage of packets that were not received from the MAV by the GCS
/// BASIC UAS TYPE, NAME AND STATE
int status; ///< The current status of the MAV
/// TIMEKEEPING
quint64 startTime; ///< The time the UAS was switched on
quint64 onboardTimeOffset;
/// MANUAL CONTROL
bool controlRollManual; ///< status flag, true if roll is controlled manually
bool controlPitchManual; ///< status flag, true if pitch is controlled manually
bool controlYawManual; ///< status flag, true if yaw is controlled manually
bool controlThrustManual; ///< status flag, true if thrust is controlled manually
/// POSITION
bool isGlobalPositionKnown; ///< If the global position has been received for this MAV
/// ATTITUDE
bool attitudeKnown; ///< True if attitude was received, false else
bool attitudeStamped; ///< Should arriving data be timestamped with the last attitude? This helps with broken system time clocks on the MAV
quint64 lastAttitude; ///< Timestamp of last attitude measurement
bool blockHomePositionChanges; ///< Block changes to the home position
/// SIMULATION NOISE
float xacc_var; ///< variance of x acclerometer noise for HIL sim (mg)
float yacc_var; ///< variance of y acclerometer noise for HIL sim (mg)
float zacc_var; ///< variance of z acclerometer noise for HIL sim (mg)
float rollspeed_var; ///< variance of x gyroscope noise for HIL sim (rad/s)
float pitchspeed_var; ///< variance of y gyroscope noise for HIL sim (rad/s)
float yawspeed_var; ///< variance of z gyroscope noise for HIL sim (rad/s)
float xmag_var; ///< variance of x magnatometer noise for HIL sim (???)
float ymag_var; ///< variance of y magnatometer noise for HIL sim (???)
float zmag_var; ///< variance of z magnatometer noise for HIL sim (???)
float abs_pressure_var; ///< variance of absolute pressure noise for HIL sim (hPa)
float diff_pressure_var; ///< variance of differential pressure noise for HIL sim (hPa)
float pressure_alt_var; ///< variance of altitude pressure noise for HIL sim (hPa)
float temperature_var; ///< variance of temperature noise for HIL sim (C)
public:
/** @brief Get the human-readable status message for this code */
void getStatusForCode(int statusCode, QString& uasState, QString& stateDescription);
public slots:
/** @brief Order the robot to pair its receiver **/
void pairRX(int rxType, int rxSubType);
/** @brief Receive a message from one of the communication links. */
virtual void receiveMessage(mavlink_message_t message);
signals:
void rollChanged(double val,QString name);
void pitchChanged(double val,QString name);
void yawChanged(double val,QString name);
protected:
/** @brief Get the UNIX timestamp in milliseconds, enter microseconds */
quint64 getUnixTime(quint64 time=0);
/** @brief Get the UNIX timestamp in milliseconds, enter milliseconds */
quint64 getUnixTimeFromMs(quint64 time);
/** @brief Get the UNIX timestamp in milliseconds, ignore attitudeStamped mode */
quint64 getUnixReferenceTime(quint64 time);
bool connectionLost; ///< Flag indicates a timed out connection
quint64 connectionLossTime; ///< Time the connection was interrupted
quint64 lastVoltageWarning; ///< Time at which the last voltage warning occurred
quint64 lastNonNullTime; ///< The last timestamp from the MAV that was not null
unsigned int onboardTimeOffsetInvalidCount; ///< Count when the offboard time offset estimation seemed wrong
private:
Vehicle* _vehicle;
FirmwarePluginManager* _firmwarePluginManager;
};
-96
View File
@@ -1,96 +0,0 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
// NO NEW CODE HERE
// UASInterface, UAS.h/cc are deprecated. All new functionality should go into Vehicle.h/cc
//
#pragma once
#include <QObject>
#include <QList>
#include <QAction>
#include <QColor>
#include <QPointer>
#include "LinkInterface.h"
/**
* @brief Interface for all robots.
*
* This interface is abstract and thus cannot be instantiated. It serves only as type definition.
* It represents an unmanned aerial vehicle, e.g. a micro air vehicle.
**/
class UASInterface : public QObject
{
Q_OBJECT
public:
virtual ~UASInterface() {}
/* MANAGEMENT */
virtual int getUASID() const = 0; ///< Get the ID of the connected UAS
/** @brief The time interval the robot is switched on **/
virtual quint64 getUptime() const = 0;
public slots:
/** @brief Order the robot to pair its receiver **/
virtual void pairRX(int rxType, int rxSubType) = 0;
signals:
/** @brief The robot is connected **/
void connected();
/** @brief The robot is disconnected **/
void disconnected();
/**
* @brief The battery status has been updated
*
* @param uas sending system
* @param voltage battery voltage
* @param percent remaining capacity in percent
* @param seconds estimated remaining flight time in seconds
*/
void batteryChanged(UASInterface* uas, double voltage, double current, double percent, int seconds);
void statusChanged(UASInterface* uas, QString status);
void imageStarted(int imgid, int width, int height, int depth, int channels);
void imageDataReceived(int imgid, const unsigned char* imageData, int length, int startIndex);
/** @brief Optical flow status changed */
void opticalFlowStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Vision based localization status changed */
void visionLocalizationStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Infrared / Ultrasound status changed */
void distanceSensorStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Gyroscope status changed */
void gyroStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Accelerometer status changed */
void accelStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Magnetometer status changed */
void magSensorStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Barometer status changed */
void baroStatusChanged(bool supported, bool enabled, bool ok);
/** @brief Differential pressure / airspeed status changed */
void airspeedStatusChanged(bool supported, bool enabled, bool ok);
// ERROR AND STATUS SIGNALS
/** @brief Name of system changed */
void nameChanged(QString newName);
/** @brief Core specifications have changed */
void systemSpecsChanged(int uasId);
// Log Download Signals
void logEntry (UASInterface* uas, uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t last_log_num);
void logData (UASInterface* uas, uint32_t ofs, uint16_t id, uint8_t count, const uint8_t* data);
};
Q_DECLARE_INTERFACE(UASInterface, "org.qgroundcontrol/1.0")
-1
View File
@@ -16,7 +16,6 @@
#include "QGCToolbox.h"
class Vehicle;
class UASInterface;
class UASMessageHandler;
class QGCApplication;