Skip to content
Vehicle.h 73.7 KiB
Newer Older
    bool            _receivingAttitudeQuaternion = false;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    CheckList       _checkListState                         = CheckListNotSetup;
    bool            _readyToFlyAvailable                    = false;
    bool            _readyToFly                             = false;
    bool            _allSensorsHealthy                      = true;

    SysStatusSensorInfo _sysStatusSensorInfo;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    QGCCameraManager* _cameraManager = nullptr;
Don Gagne's avatar
Don Gagne committed
    QString             _prearmError;
    QTimer              _prearmErrorTimer;
    static const int    _prearmErrorTimeoutMSecs = 35 * 1000;   ///< Take away prearm error after 35 seconds

    bool                _initialPlanRequestComplete = false;
    LinkManager*                    _linkManager                    = nullptr;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    ParameterManager*               _parameterManager               = nullptr;
    FirmwarePluginManager*          _firmwarePluginManager          = nullptr;
    JoystickManager*                _joystickManager                = nullptr;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    ComponentInformationManager*    _componentInformationManager    = nullptr;
    VehicleObjectAvoidance*         _objectAvoidance                = nullptr;
#if defined(QGC_AIRMAP_ENABLED)
    AirspaceVehicleManager*         _airspaceVehicleManager         = nullptr;
    bool    _armed = false;         ///< true: vehicle is armed
    uint8_t _base_mode = 0;     ///< base_mode from HEARTBEAT
    uint32_t _custom_mode = 0;  ///< custom_mode from HEARTBEAT

    /// Used to store a message being sent by sendMessageMultiple
    typedef struct {
        mavlink_message_t   message;    ///< Message to send multiple times
        int                 retryCount; ///< Number of retries left
    } SendMessageMultipleInfo_t;
    QList<SendMessageMultipleInfo_t> _sendMessageMultipleList;    ///< List of messages being sent multiple times
    static const int _sendMessageMultipleRetries = 5;
    static const int _sendMessageMultipleIntraMessageDelay = 500;
    QTimer  _sendMultipleTimer;
    int     _nextSendMessageMultipleIndex = 0;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    QTimer                          _flightTimeUpdater;
    TrajectoryPoints*               _trajectoryPoints = nullptr;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    QmlObjectListModel              _cameraTriggerPoints;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    //QMap<QString, ADSBVehicle*>     _trafficVehicleMap;
    // Toolbox references
    bool _allLinksRemovedSent = false; ///< true: allLinkRemoved signal already sent one time
Don Gagne's avatar
Don Gagne committed

    uint                _messagesReceived = 0;
    uint                _messagesSent = 0;
    uint                _messagesLost = 0;
    uint8_t             _messageSeq = 0;
    uint8_t             _compID = 0;
    bool                _heardFrom = false;
Gus Grubba's avatar
Gus Grubba committed
    float               _curGimbalRoll  = 0.0f;
    float               _curGimbalPitch = 0.0f;
    float               _curGinmbalYaw  = 0.0f;
    bool                _haveGimbalData = false;
    bool                _isROIEnabled   = false;
Gus Grubba's avatar
Gus Grubba committed
    Joystick*           _activeJoystick = nullptr;

DoinLakeFlyer's avatar
 
DoinLakeFlyer committed
    bool _checkLatestStableFWDone = false;
    int _firmwareMajorVersion = versionNotSetValue;
    int _firmwareMinorVersion = versionNotSetValue;
    int _firmwarePatchVersion = versionNotSetValue;
    int _firmwareCustomMajorVersion = versionNotSetValue;
    int _firmwareCustomMinorVersion = versionNotSetValue;
    int _firmwareCustomPatchVersion = versionNotSetValue;
    FIRMWARE_VERSION_TYPE _firmwareVersionType = FIRMWARE_VERSION_TYPE_OFFICIAL;
    QString _gitHash;
    uint64_t    _mavlinkSentCount       = 0;
    uint64_t    _mavlinkReceivedCount   = 0;
    uint64_t    _mavlinkLossCount       = 0;
    float       _mavlinkLossPercent     = 0.0f;

Don Gagne's avatar
 
Don Gagne committed
    QMap<QString, QTime> _noisySpokenPrearmMap; ///< Used to prevent PreArm messages from being spoken too often

Don Gagne's avatar
 
Don Gagne committed
    // Orbit status values
Don Gagne's avatar
 
Don Gagne committed
    QGCMapCircle    _orbitMapCircle;
    QTimer          _orbitTelemetryTimer;
    static const int _orbitTelemetryTimeoutMsecs = 3000; // No telemetry for this amount and orbit will go inactive

Don Gagne's avatar
 
Don Gagne committed
    // PID Tuning telemetry mode
    bool            _pidTuningTelemetryMode = false;
    bool            _pidTuningWaitingForRates = false;
Don Gagne's avatar
 
Don Gagne committed
    QList<int>      _pidTuningMessages;
    QMap<int, int>  _pidTuningMessageRatesUsecs;

DoinLakeFlyer's avatar
 
DoinLakeFlyer committed
    // Chunked status text support
    typedef struct {
        uint16_t    chunkId;
        uint8_t     severity;
        QStringList rgMessageChunks;
    } ChunkedStatusTextInfo_t;
    QMap<uint8_t /* compId */, ChunkedStatusTextInfo_t> _chunkedStatusTextInfoMap;
    QTimer _chunkedStatusTextTimer;

DonLakeFlyer's avatar
 
DonLakeFlyer committed
    /// Callback for waitForMavlinkMessage
    ///     @param resultHandleData     Opaque data passed in to waitForMavlinkMessage call
    ///     @param commandResult        Ack result for command send
    ///     @param noReponseFromVehicle true: The vehicle did not responsed to the COMMAND_LONG message
    typedef void (*WaitForMavlinkMessageResultHandler)(void* resultHandlerData, bool noResponsefromVehicle, const mavlink_message_t& message);
DonLakeFlyer's avatar
 
DonLakeFlyer committed

    /// Waits for the specified msecs for the message to be received. Calls timeoutHandler if not received.
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    void _waitForMavlinkMessage     (WaitForMavlinkMessageResultHandler resultHandler, void* resultHandlerData, int messageId, int timeoutMsecs);
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    void _waitForMavlinkMessageClear(void);

DonLakeFlyer's avatar
 
DonLakeFlyer committed
    int                                 _waitForMavlinkMessageId                = 0;
    bool                                _waitForMavlinkMessageTimeoutActive     = false;
    int                                 _waitForMavlinkMessageTimeoutMsecs      = 0;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    QElapsedTimer                       _waitForMavlinkMessageElapsed;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    WaitForMavlinkMessageResultHandler  _waitForMavlinkMessageResultHandler     = nullptr;
    void*                               _waitForMavlinkMessageResultHandlerData = nullptr;

    void _waitForMavlinkMessageMessageReceived(const mavlink_message_t& message);

    // requestMessage handling
    typedef struct {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
        bool                        commandAckReceived; // We keep track of the ack/message being received since the order in which this will come in is random
        bool                        messageReceived;    // We only delete the allocated RequestMessageInfo_t when both happen (or the message wait times out)
        int                         msgId;
        int                         compId;
        RequestMessageResultHandler resultHandler;
        void*                       resultHandlerData;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    } RequestMessageInfo_t;

    static void _requestMessageCmdResultHandler             (void* resultHandlerData, int compId, MAV_RESULT result, bool noResponsefromVehicle);
    static void _requestMessageWaitForMessageResultHandler  (void* resultHandlerData, bool noResponsefromVehicle, const mavlink_message_t& message);

    typedef struct {
        int                 compId;
        bool                commandInt;     // true: use COMMAND_INT, false: use COMMAND_LONG
        MAV_CMD             command;
        MAV_FRAME           frame;
        float               rgParam[7];
        bool                showError;
        bool                requestMessage; // true: this is from a requestMessage call
        MavCmdResultHandler resultHandler;
        void*               resultHandlerData;
    } MavCommandQueueEntry_t;

    QQueue<MavCommandQueueEntry_t>  _mavCommandQueue;
    QTimer                          _mavCommandAckTimer;
    int                             _mavCommandRetryCount;
    static const int                _mavCommandMaxRetryCount =              3;
    static const int                _mavCommandAckTimeoutMSecs =            3000;
    static const int                _mavCommandAckTimeoutMSecsHighLatency = 120000;

    void _sendMavCommandWorker(bool commandInt, bool requestMessage, bool showError, MavCmdResultHandler resultHandler, void* resultHandlerData, int compId, MAV_CMD command, MAV_FRAME frame, float param1, float param2, float param3, float param4, float param5, float param6, float param7);
DonLakeFlyer's avatar
 
DonLakeFlyer committed

DonLakeFlyer's avatar
 
DonLakeFlyer committed
    QMap<uint8_t /* batteryId */, uint8_t /* MAV_BATTERY_CHARGE_STATE_OK */> _lowestBatteryChargeStateAnnouncedMap;

Don Gagne's avatar
Don Gagne committed
    // FactGroup facts

    Fact _rollFact;
    Fact _pitchFact;
    Fact _headingFact;
DonLakeFlyer's avatar
DonLakeFlyer committed
    Fact _rollRateFact;
    Fact _pitchRateFact;
    Fact _yawRateFact;
Don Gagne's avatar
Don Gagne committed
    Fact _groundSpeedFact;
    Fact _airSpeedFact;
    Fact _climbRateFact;
    Fact _altitudeRelativeFact;
    Fact _altitudeAMSLFact;
    Fact _flightDistanceFact;
    Fact _flightTimeFact;
    Fact _distanceToHomeFact;
    Fact _headingToNextWPFact;
Don Gagne's avatar
 
Don Gagne committed
    Fact _headingToHomeFact;
Don Gagne's avatar
 
Don Gagne committed
    Fact _distanceToGCSFact;
    Fact _hobbsFact;
Don Gagne's avatar
 
Don Gagne committed
    Fact _throttlePctFact;
    VehicleGPSFactGroup             _gpsFactGroup;
    VehicleWindFactGroup            _windFactGroup;
    VehicleVibrationFactGroup       _vibrationFactGroup;
    VehicleTemperatureFactGroup     _temperatureFactGroup;
    VehicleClockFactGroup           _clockFactGroup;
    VehicleSetpointFactGroup        _setpointFactGroup;
    VehicleDistanceSensorFactGroup  _distanceSensorFactGroup;
    VehicleEscStatusFactGroup       _escStatusFactGroup;
    VehicleEstimatorStatusFactGroup _estimatorStatusFactGroup;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    TerrainFactGroup                _terrainFactGroup;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    QmlObjectListModel              _batteryFactGroupListModel;
DonLakeFlyer's avatar
 
DonLakeFlyer committed

    TerrainProtocolHandler* _terrainProtocolHandler = nullptr;
    MissionManager*                 _missionManager             = nullptr;
    GeoFenceManager*                _geoFenceManager            = nullptr;
    RallyPointManager*              _rallyPointManager          = nullptr;
    VehicleLinkManager*             _vehicleLinkManager         = nullptr;
    FTPManager*                     _ftpManager                 = nullptr;
    InitialConnectStateMachine*     _initialConnectStateMachine = nullptr;

Don Gagne's avatar
Don Gagne committed
    static const char* _rollFactName;
    static const char* _pitchFactName;
    static const char* _headingFactName;
DonLakeFlyer's avatar
DonLakeFlyer committed
    static const char* _rollRateFactName;
    static const char* _pitchRateFactName;
    static const char* _yawRateFactName;
Don Gagne's avatar
Don Gagne committed
    static const char* _groundSpeedFactName;
    static const char* _airSpeedFactName;
    static const char* _climbRateFactName;
    static const char* _altitudeRelativeFactName;
    static const char* _altitudeAMSLFactName;
    static const char* _flightDistanceFactName;
    static const char* _flightTimeFactName;
    static const char* _distanceToHomeFactName;
    static const char* _missionItemIndexFactName;
    static const char* _headingToNextWPFactName;
Don Gagne's avatar
 
Don Gagne committed
    static const char* _headingToHomeFactName;
Don Gagne's avatar
 
Don Gagne committed
    static const char* _distanceToGCSFactName;
    static const char* _hobbsFactName;
Don Gagne's avatar
 
Don Gagne committed
    static const char* _throttlePctFactName;
Don Gagne's avatar
Don Gagne committed
    static const char* _gpsFactGroupName;
Don Gagne's avatar
Don Gagne committed
    static const char* _windFactGroupName;
    static const char* _vibrationFactGroupName;
    static const char* _temperatureFactGroupName;
dheideman's avatar
dheideman committed
    static const char* _clockFactGroupName;
    static const char* _distanceSensorFactGroupName;
    static const char* _escStatusFactGroupName;
    static const char* _estimatorStatusFactGroupName;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    static const char* _terrainFactGroupName;
    static const int _vehicleUIUpdateRateMSecs      = 100;
    // Settings keys
    static const char* _settingsGroup;
    static const char* _joystickEnabledSettingsKey;
DonLakeFlyer's avatar
 
DonLakeFlyer committed

    friend class InitialConnectStateMachine;
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    friend class VehicleBatteryFactGroup;       // Allow VehicleBatteryFactGroup to call _addFactGroup