171 lines
6.1 KiB
C
171 lines
6.1 KiB
C
|
|
#ifndef GDUDRONEMANAGER_H
|
|||
|
|
#define GDUDRONEMANAGER_H
|
|||
|
|
#include <QObject>
|
|||
|
|
#include <QJSValue>
|
|||
|
|
#include "QGCToolbox.h"
|
|||
|
|
#include "GDUDroneCmdRolver.h"
|
|||
|
|
#include "GduCmdGenerator.h"
|
|||
|
|
#include "FlyControlInfo.h"
|
|||
|
|
#include "GDUFlightInfo.h"
|
|||
|
|
#include "protocol/CmdResponse.h"
|
|||
|
|
#include "protocol/zxcanceloperation.h"
|
|||
|
|
#include "./tools/gduRouteFileHelper.h"
|
|||
|
|
#include "./tools/gdujoystickhelper.h"
|
|||
|
|
#include "Camera.h"
|
|||
|
|
#include "GDUHolderManager.h"
|
|||
|
|
#include "Generalsetting.h"
|
|||
|
|
#include "Controlsetting.h"
|
|||
|
|
#include "DroneCheckConnRun.h"
|
|||
|
|
#include "RCFlyControlRun.h"
|
|||
|
|
#include "BatteryInfo.h"
|
|||
|
|
#include "taskstatusinfo.h"
|
|||
|
|
#include "VideoTransmissionManager.h"
|
|||
|
|
#include "GDUMachineNestManager.h"
|
|||
|
|
|
|||
|
|
typedef struct {
|
|||
|
|
cmdComplete_t completeCallBack;
|
|||
|
|
zxCancelOperation *operation;
|
|||
|
|
} CmdResult_t;
|
|||
|
|
|
|||
|
|
class GDUDroneManager : public QGCTool
|
|||
|
|
{
|
|||
|
|
Q_OBJECT
|
|||
|
|
public:
|
|||
|
|
GDUDroneManager(QGCApplication *app, QGCToolbox *toolbox);
|
|||
|
|
void setToolbox(QGCToolbox* toolbox);
|
|||
|
|
|
|||
|
|
// 飞机连接状态
|
|||
|
|
Q_PROPERTY(bool droneConnStatus READ getDroneConnStatus CONSTANT NOTIFY droneConnStatusChanged)
|
|||
|
|
// 飞控状态信息
|
|||
|
|
Q_PROPERTY(FlyControlInfo* fcInfo READ fcInfo CONSTANT)
|
|||
|
|
// 航迹文件辅助类
|
|||
|
|
Q_PROPERTY(GduRouteFileHelper* routeHelper READ routeHelper CONSTANT)
|
|||
|
|
//无人机姿态机飞行速度信息
|
|||
|
|
Q_PROPERTY(GDUFlightInfo* gduFlightInfo READ gduFlightInfo CONSTANT)
|
|||
|
|
//无人机电池信息
|
|||
|
|
Q_PROPERTY(BatteryInfo* batteryInfo READ batteryInfo CONSTANT)
|
|||
|
|
//
|
|||
|
|
Q_PROPERTY(TaskStatusInfo* taskStatusInfo READ taskStatusInfo CONSTANT)
|
|||
|
|
//无人机图传组件
|
|||
|
|
Q_PROPERTY(VideoTransmissionManager* videoTransmission READ videoTransmission CONSTANT)
|
|||
|
|
|
|||
|
|
|
|||
|
|
bool getDroneConnStatus() { return _droneConnStatus; }
|
|||
|
|
void setDroneConnStatus(bool status);
|
|||
|
|
FlyControlInfo* fcInfo () { return _fcInfo; }
|
|||
|
|
GduRouteFileHelper* routeHelper () { return _routeHelper; }
|
|||
|
|
|
|||
|
|
GDUFlightInfo* gduFlightInfo () { return _gduFlightInfo; } //获取无人机姿态信息和速度的对象
|
|||
|
|
BatteryInfo* batteryInfo() { return _batteryInfo; }
|
|||
|
|
TaskStatusInfo* taskStatusInfo() { return _taskStatusInfo; } //获取任务状态上报信息
|
|||
|
|
VideoTransmissionManager* videoTransmission() { return _videoTransmission;}
|
|||
|
|
GDUDroneCmdRolver *droneCmdRelover = nullptr;
|
|||
|
|
GDUCmdGenerator *cmdGenerator = nullptr;
|
|||
|
|
|
|||
|
|
void sendMessage(QByteArray frameBytes,cmdComplete_t block,uint64_t msgFullID,bool shouldResend=true);
|
|||
|
|
|
|||
|
|
QMap<uint64_t,CmdResult_t> cmdAckMap;
|
|||
|
|
|
|||
|
|
//相机相关操作
|
|||
|
|
Q_PROPERTY(Camera *camera READ camera CONSTANT)
|
|||
|
|
Camera *camera(){return _camera;}
|
|||
|
|
|
|||
|
|
//云台控制操作
|
|||
|
|
Q_PROPERTY(GDUHolderManager *gduHolderManager READ gduHolderManager CONSTANT)
|
|||
|
|
GDUHolderManager *gduHolderManager(){return _gduHolderManager;}
|
|||
|
|
|
|||
|
|
//通用设置类
|
|||
|
|
Q_PROPERTY(GeneralSetting *generalSetting READ generalSetting CONSTANT)
|
|||
|
|
GeneralSetting *generalSetting(){
|
|||
|
|
return _generalSetting;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//控制设置界面(控制手)
|
|||
|
|
Q_PROPERTY(ControlSetting *controlSetting READ controlSetting CONSTANT)
|
|||
|
|
ControlSetting *controlSetting(){
|
|||
|
|
return _controlSetting;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// provide the methods to qml
|
|||
|
|
Q_INVOKABLE void sendTakeOff(int height,int speed,cmdComplete_t block);
|
|||
|
|
Q_INVOKABLE void sendLanding(int speed,int option,cmdComplete_t block);
|
|||
|
|
Q_INVOKABLE void sendReturnHome(int height,int speed,cmdComplete_t block);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief sendMissionControl
|
|||
|
|
* 任务控制指令
|
|||
|
|
* @param name 任务名,例:20211221140000
|
|||
|
|
* @param action 0x00(保留,不使用)、0x01开始、0x02、暂停、0x03继续、0x04结束、0x05清理(删除任务编号目录)。0x06请求当前任务状态。0x07替换
|
|||
|
|
*/
|
|||
|
|
Q_INVOKABLE void sendMissionControl(QString name, uchar action, QJSValue onFinished);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief sendRCFlyControl
|
|||
|
|
Byte0-1 左摇杆--X轴,无符号整型,1100-1900,1500中值
|
|||
|
|
Byte2-3 左摇杆--Y轴,无符号整型,1100-1900,1500中值,无符号整型,1100-1900,1500中值
|
|||
|
|
Byte4-5 右摇杆--X轴,无符号整型,1100-1900,1500中值,无符号整型,1100-1900,1500中值
|
|||
|
|
Byte6-7 右摇杆--Y轴,无符号整型,1100-1900,1500中值
|
|||
|
|
Byte8 模式开关状态:0 普通 ,1 运动,02 姿态
|
|||
|
|
* @param left_x
|
|||
|
|
* @param left_y
|
|||
|
|
* @param right_x
|
|||
|
|
* @param right_y
|
|||
|
|
* @param mode
|
|||
|
|
*/
|
|||
|
|
void sendRCFlyControl(int left_x,int left_y,int right_x,int right_y,int mode);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief sendSubcribeFlyControlInfo
|
|||
|
|
* 订阅飞控状态消息
|
|||
|
|
* @param msg_id
|
|||
|
|
*/
|
|||
|
|
void sendSubcribeFlyControlInfo(int msg_id);
|
|||
|
|
signals:
|
|||
|
|
void droneConnStatusChanged();
|
|||
|
|
void sendDataLinkCmd(QByteArray cmd);
|
|||
|
|
public slots:
|
|||
|
|
void joystickDataEventHandler(int type, int index, int value);
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
bool _droneConnStatus = false; // true: Drone online, false: Drone offline
|
|||
|
|
FlyControlInfo* _fcInfo = nullptr;
|
|||
|
|
GduRouteFileHelper* _routeHelper = nullptr;
|
|||
|
|
QGCToolbox *_toolBox = nullptr;
|
|||
|
|
//遥感数据获取 Add by Tzq. 2021.12.18
|
|||
|
|
GduJoystickHelper * _joystickHelper = nullptr;
|
|||
|
|
|
|||
|
|
// 相机
|
|||
|
|
Camera *_camera = nullptr;
|
|||
|
|
//云台控制
|
|||
|
|
GDUHolderManager *_gduHolderManager = nullptr;
|
|||
|
|
//无人机姿态及速度信息
|
|||
|
|
GDUFlightInfo *_gduFlightInfo = nullptr;
|
|||
|
|
//通用设置
|
|||
|
|
GeneralSetting *_generalSetting = nullptr;
|
|||
|
|
//控制设置
|
|||
|
|
ControlSetting *_controlSetting = nullptr;
|
|||
|
|
|
|||
|
|
//飞机连接状态检擦 发送连接命令
|
|||
|
|
DroneCheckConnRun *_droneCheckRun = nullptr;
|
|||
|
|
|
|||
|
|
//遥控控制信息发送
|
|||
|
|
RCFlyControlRun *_rcFlyControlRun = nullptr;
|
|||
|
|
|
|||
|
|
//电量信息
|
|||
|
|
BatteryInfo *_batteryInfo = nullptr;
|
|||
|
|
|
|||
|
|
//任务状态上报信息
|
|||
|
|
TaskStatusInfo * _taskStatusInfo = nullptr;
|
|||
|
|
|
|||
|
|
//图传组件
|
|||
|
|
VideoTransmissionManager *_videoTransmission = nullptr;
|
|||
|
|
|
|||
|
|
//机巢管理类
|
|||
|
|
GDUMachineNestManager *_gduMachineNestManager = nullptr;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
#endif // GDUDRONEMANAGER_H
|