2020-03-07 14:46:50 +08:00
|
|
|
|
#ifndef MISSIONPROCESS_H
|
|
|
|
|
|
#define MISSIONPROCESS_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2020-03-12 20:38:52 +08:00
|
|
|
|
//#include "mavlinknode.h"
|
2020-03-07 14:46:50 +08:00
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
#include "opmapwidget.h"
|
|
|
|
|
|
#include "waypointitem.h"
|
|
|
|
|
|
#include "maptype.h"
|
|
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
#include "QDebug"
|
|
|
|
|
|
#include "QThread"
|
2020-03-10 15:30:38 +08:00
|
|
|
|
#include "mavlink.h"
|
2020-03-11 23:13:36 +08:00
|
|
|
|
#include "QTimer"
|
2020-03-13 17:37:48 +08:00
|
|
|
|
#include "QTime"
|
2020-03-07 14:46:50 +08:00
|
|
|
|
#ifdef QtMavlinkNode
|
|
|
|
|
|
#include <mavlinknodeglobal.h>
|
|
|
|
|
|
class MAVLINKNODESHARED_EXPORT MissionProcess : public QObject {
|
|
|
|
|
|
#else
|
|
|
|
|
|
class MissionProcess : public QObject
|
|
|
|
|
|
{
|
|
|
|
|
|
#endif
|
|
|
|
|
|
Q_OBJECT
|
2020-03-18 18:49:18 +08:00
|
|
|
|
|
2020-03-18 23:31:54 +08:00
|
|
|
|
enum _modetype {
|
2020-03-18 18:49:18 +08:00
|
|
|
|
Nop_Mode = 0,
|
|
|
|
|
|
RecieveMode,
|
|
|
|
|
|
TransmitMode
|
2020-03-18 23:31:54 +08:00
|
|
|
|
};
|
2020-03-18 18:49:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
bool isWaitingforCount;
|
|
|
|
|
|
bool isWaitingforItem;
|
|
|
|
|
|
}_recieve;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
uint32_t count;
|
|
|
|
|
|
bool isWaiteforRequest;
|
|
|
|
|
|
bool isWaiteforACK;
|
2020-06-09 18:11:28 +08:00
|
|
|
|
|
|
|
|
|
|
int seq;
|
|
|
|
|
|
uint8_t type;
|
|
|
|
|
|
|
2020-03-18 18:49:18 +08:00
|
|
|
|
}_transmit;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
|
{
|
|
|
|
|
|
_recieve recieve;
|
|
|
|
|
|
_transmit transmit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_modetype m_Mode;
|
|
|
|
|
|
|
|
|
|
|
|
}_mission_;
|
|
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
public:
|
|
|
|
|
|
explicit MissionProcess(QObject *parent = nullptr);
|
|
|
|
|
|
|
2020-03-18 18:49:18 +08:00
|
|
|
|
_mission_ mission_status;
|
2020-03-07 14:46:50 +08:00
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
|
2020-08-04 23:18:58 +08:00
|
|
|
|
void setGCSID(int m_sysid, int m_compid)
|
|
|
|
|
|
{
|
|
|
|
|
|
Current_sysID = m_sysid;
|
|
|
|
|
|
Current_CompID = m_compid;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
public slots:
|
2020-06-02 18:39:43 +08:00
|
|
|
|
|
|
|
|
|
|
void setID(int m_sysid, int m_compid);
|
|
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
//线程对外接口
|
|
|
|
|
|
void setRunFrq(uint32_t frq);
|
|
|
|
|
|
void start();
|
|
|
|
|
|
void stop();
|
2020-08-12 22:12:44 +08:00
|
|
|
|
bool isActive(void)
|
|
|
|
|
|
{
|
|
|
|
|
|
return running_flag;
|
|
|
|
|
|
}
|
2020-03-07 14:46:50 +08:00
|
|
|
|
|
2020-03-10 15:30:38 +08:00
|
|
|
|
|
2020-04-03 09:39:31 +08:00
|
|
|
|
void Parse(mavlink_message_t msg);
|
2020-03-10 15:30:38 +08:00
|
|
|
|
|
2020-03-12 16:00:08 +08:00
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
//读取航线的指令
|
|
|
|
|
|
void ReadCmd(uint8_t m_sysid, uint8_t m_compid);
|
|
|
|
|
|
void WriteCmd(uint8_t m_sysid, uint8_t m_compid ,uint32_t count );
|
2020-03-12 16:00:08 +08:00
|
|
|
|
|
2020-06-09 18:11:28 +08:00
|
|
|
|
|
|
|
|
|
|
void SetCurrentPoint(int seq);
|
|
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
void transmitPoint(float param1,float param2,float param3,float param4,
|
|
|
|
|
|
int32_t x,int32_t y,float z,
|
|
|
|
|
|
uint16_t seq,
|
|
|
|
|
|
uint16_t group,
|
|
|
|
|
|
uint16_t command,
|
|
|
|
|
|
uint8_t target_system,
|
|
|
|
|
|
uint8_t target_component,
|
|
|
|
|
|
uint8_t frame,
|
|
|
|
|
|
uint8_t current,
|
|
|
|
|
|
uint8_t autocontinue,
|
|
|
|
|
|
uint8_t mission_type);
|
2020-03-12 16:00:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
private slots:
|
|
|
|
|
|
//线程私有接口
|
2020-03-12 16:00:08 +08:00
|
|
|
|
void SendMessage(mavlink_message_t msg);
|
2020-03-07 14:46:50 +08:00
|
|
|
|
|
2020-03-12 16:00:08 +08:00
|
|
|
|
void process();
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
2020-03-12 16:00:08 +08:00
|
|
|
|
//定时器
|
2020-03-13 17:37:48 +08:00
|
|
|
|
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
2020-03-12 20:38:52 +08:00
|
|
|
|
//状态机
|
|
|
|
|
|
void ReadStateMachine(void);
|
|
|
|
|
|
void WriteStateMachine(void);
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
2020-03-20 18:03:25 +08:00
|
|
|
|
//所有的相关函数
|
2020-03-12 20:38:52 +08:00
|
|
|
|
void request_list(void);
|
2020-03-11 23:13:36 +08:00
|
|
|
|
void count(uint16_t count);
|
|
|
|
|
|
void request_int(uint16_t seq);
|
|
|
|
|
|
void request(uint16_t seq);
|
2020-09-04 17:57:53 +08:00
|
|
|
|
void item_int(float param1, float param2, float param3, float param4,
|
|
|
|
|
|
int32_t x, int32_t y, float z,
|
|
|
|
|
|
uint16_t seq, uint16_t command,
|
|
|
|
|
|
uint8_t frame, uint8_t current,
|
|
|
|
|
|
uint8_t autocontinue, uint8_t mission_type);
|
2020-03-11 23:13:36 +08:00
|
|
|
|
void item(float param1,float param2,float param3,float param4,
|
|
|
|
|
|
float x,float y,float z,
|
|
|
|
|
|
uint16_t seq,uint16_t command,
|
|
|
|
|
|
uint8_t frame,uint8_t current,
|
|
|
|
|
|
uint8_t autocontinue,uint8_t mission_type);
|
2020-03-12 20:38:52 +08:00
|
|
|
|
void ack(void);
|
2020-03-11 23:13:36 +08:00
|
|
|
|
void current(void);
|
2020-06-09 18:11:28 +08:00
|
|
|
|
void setcurrent(uint16_t seq);
|
2020-03-11 23:13:36 +08:00
|
|
|
|
void clear_all(void);
|
|
|
|
|
|
|
2020-03-12 20:38:52 +08:00
|
|
|
|
void item_reached(void);
|
|
|
|
|
|
void request_partial_list(void);
|
|
|
|
|
|
void write_partial_list(void);
|
2020-03-11 23:13:36 +08:00
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
signals:
|
2020-08-20 17:48:09 +08:00
|
|
|
|
|
2020-08-22 23:05:13 +08:00
|
|
|
|
void clearWaypoint(void);
|
|
|
|
|
|
|
2020-08-20 17:48:09 +08:00
|
|
|
|
void readReady();
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-01 18:22:49 +08:00
|
|
|
|
void showMessage(const QString &message,int TimeOut = 0);
|
|
|
|
|
|
|
2020-03-12 20:38:52 +08:00
|
|
|
|
void readError();
|
2020-03-07 14:46:50 +08:00
|
|
|
|
|
2020-03-18 00:17:40 +08:00
|
|
|
|
void SendMessageTo(quint8 ch, quint8 *data,quint16 len);
|
2020-03-13 17:37:48 +08:00
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
|
2020-06-04 18:20:13 +08:00
|
|
|
|
void sendItemOK(uint16_t seq,bool flag);
|
|
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
void receivedPoint(float param1,float param2,float param3,float param4,
|
|
|
|
|
|
int32_t x,int32_t y,float z,
|
|
|
|
|
|
uint16_t seq,
|
|
|
|
|
|
uint16_t group,
|
|
|
|
|
|
uint16_t command,
|
|
|
|
|
|
uint8_t target_system,
|
|
|
|
|
|
uint8_t target_component,
|
|
|
|
|
|
uint8_t frame,
|
|
|
|
|
|
uint8_t current,
|
|
|
|
|
|
uint8_t autocontinue,
|
|
|
|
|
|
uint8_t mission_type);
|
|
|
|
|
|
|
2020-06-09 18:11:28 +08:00
|
|
|
|
void currentPoint(int seq);
|
2020-05-20 18:05:16 +08:00
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
private:
|
|
|
|
|
|
|
2020-03-11 17:23:43 +08:00
|
|
|
|
uint8_t sysid;
|
|
|
|
|
|
uint8_t compid;
|
|
|
|
|
|
|
2020-03-13 17:37:48 +08:00
|
|
|
|
mavlink_mission_request_list_t mission_request_list;
|
|
|
|
|
|
mavlink_mission_count_t mission_count;
|
|
|
|
|
|
mavlink_mission_request_int_t mission_request_int;
|
|
|
|
|
|
mavlink_mission_request_t mission_request;
|
|
|
|
|
|
mavlink_mission_item_int_t mission_item_int;
|
|
|
|
|
|
mavlink_mission_item_t mission_item;
|
|
|
|
|
|
mavlink_mission_ack_t mission_ack;
|
|
|
|
|
|
mavlink_mission_current_t mission_current;
|
|
|
|
|
|
mavlink_mission_set_current_t mission_set_current;
|
|
|
|
|
|
mavlink_mission_clear_all_t mission_clear_all;
|
|
|
|
|
|
mavlink_mission_item_reached_t mission_item_reached;
|
|
|
|
|
|
mavlink_mission_request_partial_list_t mission_request_partial_list;
|
|
|
|
|
|
mavlink_mission_write_partial_list_t mission_write_partial_list;
|
2020-03-10 15:30:38 +08:00
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
bool running_flag = false;
|
|
|
|
|
|
quint32 running_frq = 200;//200Hz
|
2020-08-20 17:48:09 +08:00
|
|
|
|
QThread *thread = nullptr;
|
2020-03-07 14:46:50 +08:00
|
|
|
|
|
2020-08-04 23:18:58 +08:00
|
|
|
|
//本机的id
|
|
|
|
|
|
int Current_sysID = 0xF1;
|
|
|
|
|
|
int Current_CompID = 0xF1;
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
2020-08-08 21:07:33 +08:00
|
|
|
|
|
|
|
|
|
|
//超时时间(ms)
|
|
|
|
|
|
int readTimeout = 3000;
|
|
|
|
|
|
int sendTimeout = 3000;
|
|
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
QList<mapcontrol::WayPointItem *> wplist;
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
2020-03-18 18:49:18 +08:00
|
|
|
|
|
|
|
|
|
|
//bool isReadMission = false;
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
2020-03-11 23:13:36 +08:00
|
|
|
|
|
2020-03-18 18:49:18 +08:00
|
|
|
|
//bool isWriteMission = false;
|
2020-03-12 20:38:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
2020-05-20 18:05:16 +08:00
|
|
|
|
QMap<int,mapcontrol::WayPointItem::_property> items;
|
2020-03-13 17:37:48 +08:00
|
|
|
|
|
2020-03-18 18:49:18 +08:00
|
|
|
|
//bool ismTimerTimeOut = false;
|
2020-03-11 23:13:36 +08:00
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
2020-03-17 22:08:29 +08:00
|
|
|
|
|
2020-03-12 20:38:52 +08:00
|
|
|
|
|
2020-03-11 17:23:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-03-07 14:46:50 +08:00
|
|
|
|
#endif // MISSIONPROCESS_H
|