修正姿态显示和指令发送
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
{
|
||||
"comment": "Any Firmware, Any Vehicle",
|
||||
|
||||
"comment": "Custom",
|
||||
"version": 1,
|
||||
"spacing" : 10,
|
||||
|
||||
"Width": 80,
|
||||
"Height": 60,
|
||||
|
||||
"CommandButton": [
|
||||
{
|
||||
"Name" : "关机",
|
||||
"Text" : "关机",
|
||||
"row": 0,
|
||||
"column": 0,
|
||||
"command": 400,
|
||||
"confirm": 0,
|
||||
"param1": 1,
|
||||
"param2": 2,
|
||||
"param3": 3,
|
||||
@@ -17,9 +22,25 @@
|
||||
"param7": 7
|
||||
},
|
||||
{
|
||||
"Name" : "起飞",
|
||||
"Text" : "降落",
|
||||
"row": 0,
|
||||
"column": 1,
|
||||
"command": 900,
|
||||
"confirm": 0,
|
||||
"param1": 7,
|
||||
"param2": 6,
|
||||
"param3": 5,
|
||||
"param4": 4,
|
||||
"param5": 3,
|
||||
"param6": 2,
|
||||
"param7": 1
|
||||
},
|
||||
{
|
||||
"Text" : "起飞",
|
||||
"row": 1,
|
||||
"column": 1,
|
||||
"command": 900,
|
||||
"confirm": 0,
|
||||
"param1": 7,
|
||||
"param2": 6,
|
||||
"param3": 5,
|
||||
|
||||
+22
-16
@@ -6,10 +6,14 @@ const char* CommandUI::_versionJsonKey = "version";
|
||||
const char* CommandUI::_commentJsonKey = "comment";
|
||||
const char* CommandUI::_CommandButtonJsonKey = "CommandButton";
|
||||
|
||||
const char* CommandUI::_NameJsonKey = "Name";
|
||||
const char* CommandUI::_WidthJsonKey = "Width";
|
||||
const char* CommandUI::_HeightJsonKey = "Height";
|
||||
|
||||
const char* CommandUI::_TextJsonKey = "Text";
|
||||
const char* CommandUI::_rowJsonKey = "row";
|
||||
const char* CommandUI::_columnJsonKey = "column";
|
||||
|
||||
|
||||
const char* CommandUI::_param1JsonKey = "param1";
|
||||
const char* CommandUI::_param2JsonKey = "param2";
|
||||
const char* CommandUI::_param3JsonKey = "param3";
|
||||
@@ -17,8 +21,8 @@ const char* CommandUI::_param4JsonKey = "param4";
|
||||
const char* CommandUI::_param5JsonKey = "param5";
|
||||
const char* CommandUI::_param6JsonKey = "param6";
|
||||
const char* CommandUI::_param7JsonKey = "param7";
|
||||
|
||||
|
||||
const char* CommandUI::_commandJsonKey = "command";
|
||||
const char* CommandUI::_confirmJsonKey = "confirm";
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +45,8 @@ CommandUI::CommandUI(QWidget *parent) :
|
||||
//载入json
|
||||
loadCommandJson(":/json/Command.json");
|
||||
|
||||
ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
|
||||
|
||||
for(QJsonValue info: CMD_infoArray) {
|
||||
if (!info.isObject()) {
|
||||
return;
|
||||
@@ -48,15 +54,9 @@ CommandUI::CommandUI(QWidget *parent) :
|
||||
|
||||
QPushButton *btn = new QPushButton(ui->groupBox_Command);
|
||||
|
||||
btn->setText(info.toObject().find(_NameJsonKey).value().toString());
|
||||
btn->setText(info.toObject().find(_TextJsonKey).value().toString());
|
||||
|
||||
btn->setFixedSize(60,60);
|
||||
|
||||
/*
|
||||
btn->setGeometry(10 + info.toObject().find(_rowJsonKey).value().toInt() * 70,
|
||||
10 + info.toObject().find(_columnJsonKey).value().toInt() * 70,
|
||||
60,60);
|
||||
*/
|
||||
btn->setFixedSize(CMDwidth,CMDheight);
|
||||
|
||||
ui->gridLayout_Command->addWidget(btn,
|
||||
info.toObject().find(_rowJsonKey).value().toInt(),
|
||||
@@ -104,8 +104,8 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
}
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
int version = json.value(_versionJsonKey).toInt();
|
||||
qDebug() << "command version :" << version;
|
||||
CMD_version = json.value(_versionJsonKey).toInt();
|
||||
qDebug() << "command version :" << CMD_version;
|
||||
|
||||
/*
|
||||
if (version != 1) {
|
||||
@@ -114,6 +114,8 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
}
|
||||
*/
|
||||
|
||||
CMDwidth = json.value(_WidthJsonKey).toInt();
|
||||
CMDheight = json.value(_HeightJsonKey).toInt();
|
||||
|
||||
|
||||
QJsonValue jsonValue = json.value(_CommandButtonJsonKey);
|
||||
@@ -148,7 +150,7 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
|
||||
//找到id或者名字一样的按键,找到参数,发出去
|
||||
|
||||
QString _name = info.toObject().find(_NameJsonKey).value().toString();
|
||||
QString _name = info.toObject().find(_TextJsonKey).value().toString();
|
||||
QString _text = btn->text();
|
||||
|
||||
if(_name == _text)
|
||||
@@ -160,9 +162,11 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
float param5 = info.toObject().find(_param5JsonKey).value().toDouble();
|
||||
float param6 = info.toObject().find(_param6JsonKey).value().toDouble();
|
||||
float param7 = info.toObject().find(_param7JsonKey).value().toDouble();
|
||||
uint16_t command = info.toObject().find(_commandJsonKey).value().toInt();
|
||||
uint8_t confirm = info.toObject().find(_confirmJsonKey).value().toInt();
|
||||
|
||||
|
||||
emit cmd_long(param1,param2, param3,param4,param5,param6,param7);
|
||||
emit cmd_long(param1,param2, param3,param4,param5,param6,param7,command,confirm);
|
||||
|
||||
qDebug() << tr("clicked") << btn->text()
|
||||
<< param1
|
||||
@@ -171,7 +175,9 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
<< param4
|
||||
<< param5
|
||||
<< param6
|
||||
<< param7;
|
||||
<< param7
|
||||
<< command
|
||||
<< confirm;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
signals:
|
||||
|
||||
void cmd_int(float param1, float param2, float param3, float param4, int x, int y, float z);
|
||||
void cmd_long(float param1, float param2, float param3, float param4, float param5, float param6, float param7);
|
||||
void cmd_long( float param1,float param2,float param3,float param4,float param5,float param6,float param7,uint16_t command,uint8_t confirmation);
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -47,10 +47,14 @@ private:
|
||||
static const char* _commentJsonKey;
|
||||
static const char* _CommandButtonJsonKey;
|
||||
|
||||
static const char* _NameJsonKey;
|
||||
static const char* _WidthJsonKey;
|
||||
static const char* _HeightJsonKey;
|
||||
|
||||
static const char* _TextJsonKey;
|
||||
static const char* _rowJsonKey;
|
||||
static const char* _columnJsonKey;
|
||||
|
||||
|
||||
static const char* _param1JsonKey;
|
||||
static const char* _param2JsonKey;
|
||||
static const char* _param3JsonKey;
|
||||
@@ -58,13 +62,15 @@ private:
|
||||
static const char* _param5JsonKey;
|
||||
static const char* _param6JsonKey;
|
||||
static const char* _param7JsonKey;
|
||||
|
||||
static const char* _commandJsonKey;
|
||||
static const char* _confirmJsonKey;
|
||||
|
||||
QJsonArray CMD_infoArray;
|
||||
|
||||
int CMDwidth = 60;
|
||||
int CMDheight = 60;
|
||||
|
||||
|
||||
|
||||
int CMD_version;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,12 +12,10 @@ FORMS += \
|
||||
$$PWD/CommandUI.ui \
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/CommandUI.h \
|
||||
$$PWD/commandmsg.h
|
||||
$$PWD/CommandUI.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/CommandUI.cpp \
|
||||
$$PWD/commandmsg.cpp
|
||||
$$PWD/CommandUI.cpp
|
||||
|
||||
RESOURCES += \
|
||||
$$PWD/CommandUIres.qrc
|
||||
|
||||
+4
-6
@@ -21,8 +21,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
|
||||
|
||||
|
||||
//ui initial
|
||||
|
||||
//menubar
|
||||
@@ -107,8 +105,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
|
||||
//command ----- dlink
|
||||
connect(commandUI,SIGNAL(cmd_long(float,float,float,float,float,float,float)),
|
||||
dlink->mavlinknode->Commander,SLOT(WriteCmd_long(float,float,float,float,float,float,float)));
|
||||
connect(commandUI,SIGNAL(cmd_long(float,float,float,float,float,float,float,uint16_t,uint8_t)),
|
||||
dlink->mavlinknode->Commander,SLOT(WriteCmd_long(float,float,float,float,float,float,float,uint16_t,uint8_t)),Qt::DirectConnection);
|
||||
|
||||
//setting ----- dlink
|
||||
|
||||
@@ -552,8 +550,8 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
||||
dlink->mavlinknode->vehicle.attitude.roll * 57.3,
|
||||
dlink->mavlinknode->vehicle.attitude.yaw * 57.3);
|
||||
|
||||
copk->setAltitude(dlink->mavlinknode->vehicle.gps_raw_int.alt * 10e-4 );
|
||||
copk->setAirSpeed(dlink->mavlinknode->vehicle.airspeed_autocal.vx);
|
||||
//copk->setAltitude(dlink->mavlinknode->vehicle.gps_raw_int.alt * 10e-4 );
|
||||
//copk->setAirSpeed(dlink->mavlinknode->vehicle.airspeed_autocal.vx);
|
||||
|
||||
|
||||
internals::PointLatLng LatLng;
|
||||
|
||||
+164
-34
@@ -9,10 +9,6 @@
|
||||
|
||||
Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
||||
{
|
||||
// setMouseTracking(true);
|
||||
//leftladder = new LeftLadder(this);
|
||||
|
||||
|
||||
//颜色初始化
|
||||
m_Color.NormalColor = QColor("#00FF00");
|
||||
m_Color.NoticeColor = QColor("#FF8C00");
|
||||
@@ -47,25 +43,26 @@ Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
||||
|
||||
m_State.AOA = 0;
|
||||
|
||||
m_State.altitude = 0;
|
||||
m_State.height = 0;
|
||||
|
||||
m_State.airspeed = 0;//空速
|
||||
m_State.AirspeedFlag = 2;//i c t
|
||||
m_State.horizontalspeed = 0;//侧滑速度
|
||||
m_State.verticalspeed = 0;//爬升速度
|
||||
|
||||
|
||||
m_Target.airspeed_maximun = 25;
|
||||
m_Target.airspeed_minimun = 15;
|
||||
|
||||
m_SPD_HOLD = "MCP SPD";
|
||||
m_HDG_HOLD = "HDG SEL";
|
||||
m_ALT_HOLD = "ALT HOLD";
|
||||
m_State.GPS = "GPS";
|
||||
m_State.MODE = "MODE";
|
||||
m_State.STATE = "ARM";
|
||||
|
||||
|
||||
//初始化完成后打开定时器开始计数刷新
|
||||
UpdateTimer = new QTimer;
|
||||
|
||||
connect(UpdateTimer,SIGNAL(timeout()),
|
||||
this,SLOT(UpdateTimeout()));
|
||||
|
||||
UpdateTimer->start(50);//50Hz
|
||||
|
||||
}
|
||||
@@ -118,12 +115,8 @@ void Cockpit::wheelEvent(QWheelEvent *e)
|
||||
|
||||
void Cockpit::setPitch(double Pitch)
|
||||
{
|
||||
|
||||
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
|
||||
#else
|
||||
if(isnan(Pitch))
|
||||
{
|
||||
@@ -131,6 +124,8 @@ void Cockpit::setPitch(double Pitch)
|
||||
}
|
||||
#endif
|
||||
|
||||
if(Pitch > 360) Pitch = 360;
|
||||
else if(Pitch < -360) Pitch = -360;
|
||||
|
||||
int n = Pitch/360;
|
||||
Pitch = Pitch - n*360;
|
||||
@@ -146,6 +141,35 @@ void Cockpit::setPitch(double Pitch)
|
||||
m_State.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setPitchTarget(double Pitch)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
|
||||
#else
|
||||
if(isnan(Pitch))
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(Pitch > 360) Pitch = 360;
|
||||
else if(Pitch < -360) Pitch = -360;
|
||||
|
||||
int n = Pitch/360;
|
||||
Pitch = Pitch - n*360;
|
||||
m_Target.pitch = Pitch;
|
||||
if(m_Target.pitch < -90)
|
||||
{
|
||||
m_Target.pitch += 180;
|
||||
}
|
||||
else if(m_Target.pitch > 90)
|
||||
{
|
||||
m_Target.pitch -= 180;
|
||||
}
|
||||
m_Target.isUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
void Cockpit::setRoll(double Roll)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
@@ -157,6 +181,9 @@ void Cockpit::setRoll(double Roll)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if(Roll > 360) Roll = 360;
|
||||
else if(Roll < -360) Roll = -360;
|
||||
|
||||
int n = Roll/360;
|
||||
Roll = Roll - n*360;
|
||||
m_State.roll = Roll;
|
||||
@@ -171,6 +198,35 @@ void Cockpit::setRoll(double Roll)
|
||||
m_State.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setRollTarget(double Roll)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
|
||||
|
||||
#else
|
||||
if(isnan(Roll))
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if(Roll > 360) Roll = 360;
|
||||
else if(Roll < -360) Roll = -360;
|
||||
|
||||
int n = Roll/360;
|
||||
Roll = Roll - n*360;
|
||||
m_Target.roll = Roll;
|
||||
if(m_Target.roll < -180)
|
||||
{
|
||||
m_Target.roll += 360;
|
||||
}
|
||||
else if(m_Target.roll > 180)
|
||||
{
|
||||
m_Target.roll -= 360;
|
||||
}
|
||||
m_Target.isUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
void Cockpit::setYaw(double Yaw)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
@@ -192,6 +248,28 @@ void Cockpit::setYaw(double Yaw)
|
||||
m_State.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setYawTarget(double Yaw)
|
||||
{
|
||||
#ifdef __MINGW32__
|
||||
|
||||
|
||||
#else
|
||||
if(isnan(Yaw))
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
int n = Yaw/360;
|
||||
Yaw = Yaw - n*360;
|
||||
m_Target.yaw = Yaw;
|
||||
if(m_Target.yaw < 0)
|
||||
{
|
||||
m_Target.yaw += 360;
|
||||
}
|
||||
m_Target.isUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Cockpit::setAttitude(double Pitch,double Roll,double Yaw)
|
||||
{
|
||||
@@ -200,28 +278,93 @@ void Cockpit::setAttitude(double Pitch,double Roll,double Yaw)
|
||||
setYaw(Yaw);
|
||||
}
|
||||
|
||||
void Cockpit::setAttitudeTarget(double Pitch,double Roll,double Yaw)
|
||||
{
|
||||
setPitchTarget(Pitch);
|
||||
setRollTarget(Roll);
|
||||
setYawTarget(Yaw);
|
||||
}
|
||||
|
||||
void Cockpit::setAttitudeSpeed(double PitchSpeed,double RollSpeed,double YawSpeed)
|
||||
{
|
||||
m_State.gy = PitchSpeed;
|
||||
m_State.gx = RollSpeed;
|
||||
m_State.gz = YawSpeed;
|
||||
m_State.isUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Cockpit::setAltitude(double Altitude)
|
||||
{
|
||||
if(Altitude > 99999) Altitude = 99999;
|
||||
else if(Altitude < (-9999)) Altitude = -9999;
|
||||
|
||||
m_State.altitude = Altitude;
|
||||
m_State.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setAltitudeTarget(double Altitude)
|
||||
{
|
||||
if(Altitude > 99999) Altitude = 99999;
|
||||
else if(Altitude < (-9999)) Altitude = -9999;
|
||||
|
||||
m_Target.altitude = Altitude;
|
||||
m_Target.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setAirSpeed(double speed)
|
||||
{
|
||||
if(speed < 0) speed = 0;
|
||||
|
||||
m_State.airspeed = speed;
|
||||
m_State.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setAirSpeedTarget(double speed)
|
||||
{
|
||||
if(speed < 0) speed = 0;
|
||||
|
||||
m_Target.airspeed = speed;
|
||||
m_Target.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setVerticalSpeed(double speed)
|
||||
{
|
||||
m_State.verticalspeed = speed;
|
||||
m_State.isUpdate = true;
|
||||
}
|
||||
|
||||
void Cockpit::setVerticalSpeedTarget(double speed)
|
||||
{
|
||||
m_Target.verticalspeed = speed;
|
||||
m_Target.isUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Cockpit::setGPS(QString str)
|
||||
{
|
||||
m_State.GPS = str;
|
||||
}
|
||||
|
||||
void Cockpit::setMode(QString str)
|
||||
{
|
||||
m_State.MODE = str;
|
||||
}
|
||||
|
||||
void Cockpit::setState(QString str)
|
||||
{
|
||||
m_State.STATE = str;
|
||||
}
|
||||
|
||||
void Cockpit::setAOA(qreal Value)
|
||||
{
|
||||
m_State.AOA = Value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Cockpit::setLed(QColor LED)
|
||||
{
|
||||
m_Color.LedColor = LED;
|
||||
@@ -367,7 +510,7 @@ void Cockpit::drawPitch(QPainter *painter)
|
||||
|
||||
//qDebug() << "tar_y" << tar_y;
|
||||
|
||||
tar_y = (tar_y > 475)?(475):((tar_y<-525)?(-525):(tar_y));
|
||||
tar_y = (tar_y > 475)?(475):((tar_y<-475)?(-475):(tar_y));
|
||||
|
||||
painter->translate(0,tar_y);
|
||||
|
||||
@@ -1629,29 +1772,16 @@ void Cockpit::drawTopStatuts(QPainter *painter)
|
||||
|
||||
//画大字
|
||||
ePen.setColor(m_Color.StatusColor);
|
||||
ePen.setWidth(10);
|
||||
font.setPointSize(50);
|
||||
ePen.setWidth(12);
|
||||
font.setPointSize(60);
|
||||
font.setFamily("Arial");//非衬线
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
|
||||
painter->drawText(QRect(-530,10,320,80),Qt::AlignCenter,m_SPD_HOLD);
|
||||
painter->drawText(QRect(-160,10,320,80),Qt::AlignCenter,m_HDG_HOLD);
|
||||
painter->drawText(QRect( 210,10,320,80),Qt::AlignCenter,m_ALT_HOLD);
|
||||
|
||||
//画小字
|
||||
ePen.setColor(m_Color.CentreLineColor);
|
||||
ePen.setWidth(5);
|
||||
font.setPointSize(30);
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
|
||||
painter->drawText(QRect(-530,100,320,50),Qt::AlignCenter,m_SPD_HOLD);
|
||||
painter->drawText(QRect(-160,100,320,50),Qt::AlignCenter,m_HDG_HOLD);
|
||||
painter->drawText(QRect( 210,100,320,50),Qt::AlignCenter,m_ALT_HOLD);
|
||||
|
||||
painter->drawText(QRect(-530,0,320,150),Qt::AlignCenter,m_State.GPS);
|
||||
painter->drawText(QRect(-160,0,320,150),Qt::AlignCenter,m_State.MODE);
|
||||
painter->drawText(QRect( 210,0,320,150),Qt::AlignCenter,m_State.STATE);
|
||||
|
||||
painter->restore();//画状态结束
|
||||
|
||||
|
||||
+27
-15
@@ -4,8 +4,6 @@
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "leftladder.h"
|
||||
|
||||
#include "QTimer"
|
||||
|
||||
|
||||
@@ -48,6 +46,12 @@ typedef struct {
|
||||
}_color;
|
||||
|
||||
typedef struct {
|
||||
|
||||
QString GPS;
|
||||
QString MODE;
|
||||
QString STATE;
|
||||
|
||||
|
||||
qreal ax;
|
||||
qreal ay;
|
||||
qreal az;
|
||||
@@ -87,6 +91,7 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct{
|
||||
|
||||
qreal pitch;
|
||||
qreal roll;
|
||||
qreal yaw;
|
||||
@@ -103,6 +108,8 @@ typedef struct{
|
||||
|
||||
qreal verticalspeed;//纵向速度
|
||||
|
||||
bool isUpdate;
|
||||
|
||||
}_target;
|
||||
|
||||
|
||||
@@ -120,12 +127,26 @@ public Q_SLOTS:
|
||||
void setAttitude(qreal Pitch,qreal Roll,qreal Yaw);
|
||||
void setAttitudeSpeed(qreal PitchSpeed,qreal RollSpeed,qreal YawSpeed);
|
||||
|
||||
void setPitchTarget(qreal Pitch);
|
||||
void setRollTarget(qreal Roll);
|
||||
void setYawTarget(qreal Yaw);
|
||||
void setAttitudeTarget(qreal Pitch,qreal Roll,qreal Yaw);
|
||||
|
||||
void setAltitude(qreal Altitude);
|
||||
void setAltitudeTarget(double Altitude);
|
||||
|
||||
void setAirSpeed(qreal speed);
|
||||
void setAirSpeedTarget(double speed);
|
||||
|
||||
void setVerticalSpeed(double speed);
|
||||
void setVerticalSpeedTarget(double speed);
|
||||
|
||||
void setLed(QColor LED);
|
||||
|
||||
|
||||
void setGPS(QString str);
|
||||
void setMode(QString str);
|
||||
void setState(QString str);
|
||||
void setAOA(qreal Value);
|
||||
protected:
|
||||
|
||||
|
||||
@@ -164,9 +185,9 @@ private:
|
||||
|
||||
QString m_mode;//显示模式
|
||||
|
||||
QString m_SPD_HOLD;
|
||||
QString m_HDG_HOLD;
|
||||
QString m_ALT_HOLD;
|
||||
QString m_GPS;
|
||||
QString m_MODE;
|
||||
QString m_STATE;
|
||||
|
||||
double m_PitchValue;
|
||||
double m_RollValue;
|
||||
@@ -248,15 +269,6 @@ private:
|
||||
QPoint m_c;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LeftLadder *leftladder;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
+2
-4
@@ -46,12 +46,10 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/Cockpit.h \
|
||||
cockpitglobal.h \
|
||||
leftladder.h
|
||||
cockpitglobal.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/Cockpit.cpp \
|
||||
leftladder.cpp
|
||||
$$PWD/Cockpit.cpp
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@ TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered
|
||||
|
||||
|
||||
|
||||
#SUBDIRS += SerialPortDialog
|
||||
#SUBDIRS += ClientLinkDialog
|
||||
SUBDIRS += Skin
|
||||
SUBDIRS += opmap
|
||||
SUBDIRS += qNavigationWidget
|
||||
|
||||
@@ -93,7 +93,7 @@ void commandprocess::SendMessage(mavlink_message_t msg)
|
||||
}
|
||||
|
||||
//发送函数
|
||||
void commandprocess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,
|
||||
void commandprocess::WriteCmd_int(uint8_t m_sysid, uint8_t m_compid ,
|
||||
float param1,
|
||||
float param2,
|
||||
float param3,
|
||||
@@ -102,9 +102,6 @@ void commandprocess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,
|
||||
int32_t y,
|
||||
float z, uint16_t command, uint8_t frame, uint8_t current, uint8_t autocontinue)
|
||||
{
|
||||
//sysid = m_sysid;
|
||||
//compid = m_compid;
|
||||
|
||||
//给指令赋值
|
||||
cmd_int.param1 = param1;
|
||||
cmd_int.param2 = param2;
|
||||
@@ -122,24 +119,31 @@ void commandprocess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,
|
||||
//开启线程开始传输
|
||||
|
||||
status.m_Mode = TransmitMode;//发送模式
|
||||
|
||||
status.transmit.type = 0;
|
||||
start();//开启线程
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void commandprocess::WriteCmd_long(float param1, float param2, float param3, float param4, float param5, float param6, float param7)
|
||||
void commandprocess::WriteCmd_long(float param1, float param2, float param3, float param4, float param5, float param6, float param7, uint16_t command, uint8_t confirmation)
|
||||
{
|
||||
WriteCmd(0,0,
|
||||
param1,
|
||||
param2,
|
||||
param3,
|
||||
param4,
|
||||
param5,
|
||||
param6,
|
||||
param7,
|
||||
0,0,0,0);
|
||||
//给指令赋值
|
||||
cmd_long.param1 = param1;
|
||||
cmd_long.param2 = param2;
|
||||
cmd_long.param3 = param3;
|
||||
cmd_long.param4 = param4;
|
||||
cmd_long.param5 = param5;
|
||||
cmd_long.param6 = param6;
|
||||
cmd_long.param7 = param7;
|
||||
|
||||
cmd_long.command = command;
|
||||
cmd_long.confirmation = confirmation;
|
||||
|
||||
//开启线程开始传输
|
||||
status.m_Mode = TransmitMode;//发送模式
|
||||
status.transmit.type = 1;
|
||||
start();//开启线程
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +171,7 @@ void commandprocess::Parse(mavlink_message_t msg)
|
||||
{
|
||||
status.transmit.isWaitingforACK = false;
|
||||
|
||||
emit commandAccepted(command_ack.command);//广播指令已经接受的反馈
|
||||
emit commandAccepted(true,command_ack.command);//广播指令已经接受的反馈
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -181,17 +185,13 @@ void commandprocess::Parse(mavlink_message_t msg)
|
||||
void commandprocess::ReadStateMachine(void)//没有读指令这个说法
|
||||
{
|
||||
static uint8_t step = 0;
|
||||
//static uint8_t timeout_count = 0;
|
||||
static int time = 0;
|
||||
|
||||
|
||||
if(step == 0)
|
||||
{
|
||||
qDebug() << "start reading parameter";
|
||||
status.recieve.isWaitingforValue = true;
|
||||
|
||||
//request_list();
|
||||
|
||||
step++;
|
||||
time = QTime::currentTime().msecsSinceStartOfDay();
|
||||
}
|
||||
@@ -209,9 +209,21 @@ void commandprocess::WriteStateMachine(void)
|
||||
{
|
||||
status.transmit.isWaitingforACK = true;
|
||||
|
||||
_int(cmd_int.param1,cmd_int.param2,cmd_int.param3,cmd_int.param4,
|
||||
cmd_int.x,cmd_int.y,cmd_int.z,
|
||||
cmd_int.command,cmd_int.frame,cmd_int.current,cmd_int.autocontinue);//发送一个指令
|
||||
if(status.transmit.type == 0)
|
||||
{
|
||||
qDebug() << "send cmd int" << cmd_int.command;
|
||||
_int(cmd_int.param1,cmd_int.param2,cmd_int.param3,cmd_int.param4,
|
||||
cmd_int.x,cmd_int.y,cmd_int.z,
|
||||
cmd_int.command,cmd_int.frame,cmd_int.current,cmd_int.autocontinue);//发送一个指令
|
||||
}
|
||||
else if(status.transmit.type == 1)
|
||||
{
|
||||
qDebug() << "send cmd long" << cmd_long.command;
|
||||
_long(cmd_long.param1,cmd_long.param2,cmd_long.param3,cmd_long.param4,
|
||||
cmd_long.param5,cmd_long.param6,cmd_long.param7,
|
||||
cmd_long.command,cmd_long.confirmation);//发送一个指令
|
||||
}
|
||||
|
||||
time = QTime::currentTime().msecsSinceStartOfDay();
|
||||
step++;//下一个阶段
|
||||
}
|
||||
@@ -230,17 +242,36 @@ void commandprocess::WriteStateMachine(void)
|
||||
timeout_count = 0;
|
||||
|
||||
//清除指令
|
||||
cmd_int.param1 = 0;
|
||||
cmd_int.param2 = 0;
|
||||
cmd_int.param3 = 0;
|
||||
cmd_int.param4 = 0;
|
||||
cmd_int.x = 0;
|
||||
cmd_int.y = 0;
|
||||
cmd_int.z = 0;
|
||||
cmd_int.command = 0;
|
||||
cmd_int.frame = 0;
|
||||
cmd_int.current = 0;
|
||||
cmd_int.autocontinue = 0;
|
||||
if(status.transmit.type == 0)
|
||||
{
|
||||
emit commandAccepted(false,cmd_int.command);
|
||||
|
||||
cmd_int.param1 = 0;
|
||||
cmd_int.param2 = 0;
|
||||
cmd_int.param3 = 0;
|
||||
cmd_int.param4 = 0;
|
||||
cmd_int.x = 0;
|
||||
cmd_int.y = 0;
|
||||
cmd_int.z = 0;
|
||||
cmd_int.command = 0;
|
||||
cmd_int.frame = 0;
|
||||
cmd_int.current = 0;
|
||||
cmd_int.autocontinue = 0;
|
||||
}
|
||||
else if(status.transmit.type == 1)
|
||||
{
|
||||
emit commandAccepted(false,cmd_long.command);
|
||||
|
||||
cmd_long.param1 = 0;
|
||||
cmd_long.param2 = 0;
|
||||
cmd_long.param3 = 0;
|
||||
cmd_long.param4 = 0;
|
||||
cmd_long.param5 = 0;
|
||||
cmd_long.param6 = 0;
|
||||
cmd_long.param7 = 0;
|
||||
cmd_long.command = 0;
|
||||
cmd_long.confirmation = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -256,17 +287,32 @@ void commandprocess::WriteStateMachine(void)
|
||||
timeout_count = 0;
|
||||
|
||||
//清除指令
|
||||
cmd_int.param1 = 0;
|
||||
cmd_int.param2 = 0;
|
||||
cmd_int.param3 = 0;
|
||||
cmd_int.param4 = 0;
|
||||
cmd_int.x = 0;
|
||||
cmd_int.y = 0;
|
||||
cmd_int.z = 0;
|
||||
cmd_int.command = 0;
|
||||
cmd_int.frame = 0;
|
||||
cmd_int.current = 0;
|
||||
cmd_int.autocontinue = 0;
|
||||
if(status.transmit.type == 0)
|
||||
{
|
||||
cmd_int.param1 = 0;
|
||||
cmd_int.param2 = 0;
|
||||
cmd_int.param3 = 0;
|
||||
cmd_int.param4 = 0;
|
||||
cmd_int.x = 0;
|
||||
cmd_int.y = 0;
|
||||
cmd_int.z = 0;
|
||||
cmd_int.command = 0;
|
||||
cmd_int.frame = 0;
|
||||
cmd_int.current = 0;
|
||||
cmd_int.autocontinue = 0;
|
||||
}
|
||||
else if(status.transmit.type == 1)
|
||||
{
|
||||
cmd_long.param1 = 0;
|
||||
cmd_long.param2 = 0;
|
||||
cmd_long.param3 = 0;
|
||||
cmd_long.param4 = 0;
|
||||
cmd_long.param5 = 0;
|
||||
cmd_long.param6 = 0;
|
||||
cmd_long.param7 = 0;
|
||||
cmd_long.command = 0;
|
||||
cmd_long.confirmation = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ class commandprocess : public QObject
|
||||
|
||||
typedef struct {
|
||||
bool isWaitingforACK;
|
||||
uint8_t type;
|
||||
}_transmit;
|
||||
|
||||
typedef struct
|
||||
@@ -59,11 +60,11 @@ public slots:
|
||||
|
||||
void setID(int m_sysid, int m_compid);
|
||||
|
||||
void WriteCmd_long(float param1, float param2, float param3, float param4, float param5, float param6, float param7);
|
||||
void WriteCmd_long( float param1,float param2,float param3,float param4,float param5,float param6,float param7,uint16_t command,uint8_t confirmation);
|
||||
|
||||
//读取和写入指令
|
||||
//void ReadCmd(uint8_t m_sysid, uint8_t m_compid, uint8_t type);
|
||||
void WriteCmd(uint8_t m_sysid, uint8_t m_compid ,
|
||||
void WriteCmd_int(uint8_t m_sysid, uint8_t m_compid ,
|
||||
float param1,
|
||||
float param2,
|
||||
float param3,
|
||||
@@ -120,7 +121,7 @@ signals:
|
||||
|
||||
|
||||
|
||||
void commandAccepted(uint16_t);
|
||||
void commandAccepted(bool flag,uint16_t id);
|
||||
|
||||
private:
|
||||
bool running_flag = false;
|
||||
|
||||
@@ -78,9 +78,11 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
|
||||
|
||||
|
||||
|
||||
/*
|
||||
altitudeitem = new AltitudeItem(map,Qt::red);
|
||||
altitudeitem->setParentItem(map);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user