You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
257 lines
7.3 KiB
257 lines
7.3 KiB
15 years ago
|
/*=====================================================================
|
||
10 years ago
|
|
||
|
QGroundControl Open Source Ground Control Station
|
||
|
|
||
|
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||
|
|
||
|
This file is part of the QGROUNDCONTROL project
|
||
|
|
||
|
QGROUNDCONTROL is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
QGROUNDCONTROL is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
======================================================================*/
|
||
15 years ago
|
|
||
10 years ago
|
#ifndef MissionItem_H
|
||
|
#define MissionItem_H
|
||
15 years ago
|
|
||
|
#include <QObject>
|
||
|
#include <QString>
|
||
10 years ago
|
#include <QtQml>
|
||
15 years ago
|
#include <QTextStream>
|
||
10 years ago
|
#include <QGeoCoordinate>
|
||
|
|
||
14 years ago
|
#include "QGCMAVLink.h"
|
||
14 years ago
|
#include "QGC.h"
|
||
10 years ago
|
#include "MavlinkQmlSingleton.h"
|
||
15 years ago
|
|
||
10 years ago
|
class MissionItem : public QObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
10 years ago
|
MissionItem(
|
||
10 years ago
|
QObject *parent = 0,
|
||
10 years ago
|
quint16 id = 0,
|
||
|
double x = 0.0,
|
||
|
double y = 0.0,
|
||
|
double z = 0.0,
|
||
|
double param1 = 0.0,
|
||
|
double param2 = 0.0,
|
||
|
double param3 = 0.0,
|
||
|
double param4 = 0.0,
|
||
|
bool autocontinue = true,
|
||
|
bool current = false,
|
||
|
int frame = MAV_FRAME_GLOBAL,
|
||
|
int action = MAV_CMD_NAV_WAYPOINT,
|
||
|
const QString& description=QString(""));
|
||
|
|
||
10 years ago
|
MissionItem(const MissionItem& other);
|
||
|
~MissionItem();
|
||
15 years ago
|
|
||
10 years ago
|
const MissionItem& operator=(const MissionItem& other);
|
||
10 years ago
|
|
||
10 years ago
|
Q_PROPERTY(bool hasCoordinate READ hasCoordinate NOTIFY hasCoordinateChanged)
|
||
10 years ago
|
Q_PROPERTY(QGeoCoordinate coordinate READ coordinate NOTIFY coordinateChanged)
|
||
10 years ago
|
|
||
|
Q_PROPERTY(QString commandName READ commandName NOTIFY commandNameChanged)
|
||
|
Q_PROPERTY(MavlinkQmlSingleton::Qml_MAV_CMD command READ command WRITE setCommand NOTIFY commandChanged)
|
||
10 years ago
|
|
||
10 years ago
|
Q_PROPERTY(double longitude READ longitude NOTIFY longitudeChanged)
|
||
|
Q_PROPERTY(double latitude READ latitude NOTIFY latitudeChanged)
|
||
|
Q_PROPERTY(double altitude READ altitude NOTIFY altitudeChanged)
|
||
|
Q_PROPERTY(quint16 id READ id CONSTANT)
|
||
10 years ago
|
|
||
|
Q_PROPERTY(QStringList valueLabels READ valueLabels NOTIFY commandChanged)
|
||
|
Q_PROPERTY(QStringList valueStrings READ valueStrings NOTIFY valueStringsChanged)
|
||
10 years ago
|
|
||
|
double latitude() { return _x; }
|
||
|
double longitude() { return _y; }
|
||
|
double altitude() { return _z; }
|
||
|
quint16 id() { return _id; }
|
||
|
|
||
14 years ago
|
quint16 getId() const {
|
||
10 years ago
|
return _id;
|
||
14 years ago
|
}
|
||
|
double getX() const {
|
||
10 years ago
|
return _x;
|
||
14 years ago
|
}
|
||
|
double getY() const {
|
||
10 years ago
|
return _y;
|
||
14 years ago
|
}
|
||
|
double getZ() const {
|
||
10 years ago
|
return _z;
|
||
14 years ago
|
}
|
||
|
double getLatitude() const {
|
||
10 years ago
|
return _x;
|
||
14 years ago
|
}
|
||
|
double getLongitude() const {
|
||
10 years ago
|
return _y;
|
||
14 years ago
|
}
|
||
|
double getAltitude() const {
|
||
10 years ago
|
return _z;
|
||
14 years ago
|
}
|
||
|
double getYaw() const {
|
||
10 years ago
|
return _yaw;
|
||
14 years ago
|
}
|
||
|
bool getAutoContinue() const {
|
||
10 years ago
|
return _autocontinue;
|
||
14 years ago
|
}
|
||
|
bool getCurrent() const {
|
||
10 years ago
|
return _current;
|
||
14 years ago
|
}
|
||
|
double getLoiterOrbit() const {
|
||
10 years ago
|
return _orbit;
|
||
14 years ago
|
}
|
||
|
double getAcceptanceRadius() const {
|
||
10 years ago
|
return _param2;
|
||
14 years ago
|
}
|
||
|
double getHoldTime() const {
|
||
10 years ago
|
return _param1;
|
||
14 years ago
|
}
|
||
|
double getParam1() const {
|
||
10 years ago
|
return _param1;
|
||
14 years ago
|
}
|
||
|
double getParam2() const {
|
||
10 years ago
|
return _param2;
|
||
14 years ago
|
}
|
||
|
double getParam3() const {
|
||
10 years ago
|
return _orbit;
|
||
14 years ago
|
}
|
||
|
double getParam4() const {
|
||
10 years ago
|
return _yaw;
|
||
14 years ago
|
}
|
||
|
double getParam5() const {
|
||
10 years ago
|
return _x;
|
||
14 years ago
|
}
|
||
|
double getParam6() const {
|
||
10 years ago
|
return _y;
|
||
14 years ago
|
}
|
||
|
double getParam7() const {
|
||
10 years ago
|
return _z;
|
||
14 years ago
|
}
|
||
|
int getTurns() const {
|
||
10 years ago
|
return _param1;
|
||
14 years ago
|
}
|
||
10 years ago
|
// MAV_FRAME
|
||
|
int getFrame() const {
|
||
|
return _frame;
|
||
14 years ago
|
}
|
||
10 years ago
|
// MAV_CMD
|
||
|
int getAction() const {
|
||
|
return _action;
|
||
14 years ago
|
}
|
||
|
const QString& getName() const {
|
||
10 years ago
|
return _name;
|
||
14 years ago
|
}
|
||
14 years ago
|
const QString& getDescription() const {
|
||
10 years ago
|
return _description;
|
||
14 years ago
|
}
|
||
11 years ago
|
|
||
14 years ago
|
/** @brief Returns true if x, y, z contain reasonable navigation data */
|
||
|
bool isNavigationType();
|
||
15 years ago
|
|
||
10 years ago
|
/** @brief Get the time this waypoint was reached */
|
||
|
quint64 getReachedTime() const { return _reachedTime; }
|
||
|
|
||
15 years ago
|
void save(QTextStream &saveStream);
|
||
|
bool load(QTextStream &loadStream);
|
||
10 years ago
|
|
||
10 years ago
|
bool hasCoordinate(void);
|
||
10 years ago
|
QGeoCoordinate coordinate(void);
|
||
10 years ago
|
|
||
|
QString commandName(void);
|
||
15 years ago
|
|
||
10 years ago
|
MavlinkQmlSingleton::Qml_MAV_CMD command(void) { return (MavlinkQmlSingleton::Qml_MAV_CMD)getAction(); };
|
||
|
void setCommand(MavlinkQmlSingleton::Qml_MAV_CMD command) { setAction(command); }
|
||
|
|
||
|
QStringList valueLabels(void);
|
||
|
QStringList valueStrings(void);
|
||
|
|
||
15 years ago
|
protected:
|
||
10 years ago
|
quint16 _id;
|
||
|
double _x;
|
||
|
double _y;
|
||
|
double _z;
|
||
|
double _yaw;
|
||
|
int _frame;
|
||
|
int _action;
|
||
|
bool _autocontinue;
|
||
|
bool _current;
|
||
|
double _orbit;
|
||
|
double _param1;
|
||
|
double _param2;
|
||
|
int _turns;
|
||
|
QString _name;
|
||
|
QString _description;
|
||
|
quint64 _reachedTime;
|
||
|
|
||
|
public:
|
||
|
void setId (quint16 _id);
|
||
|
void setX (double _x);
|
||
|
void setY (double _y);
|
||
|
void setZ (double _z);
|
||
|
void setLatitude (double lat);
|
||
|
void setLongitude (double lon);
|
||
|
void setAltitude (double alt);
|
||
14 years ago
|
/** @brief Yaw angle in COMPASS DEGREES: 0-360 */
|
||
10 years ago
|
void setYaw (int _yaw);
|
||
14 years ago
|
/** @brief Yaw angle in COMPASS DEGREES: 0-360 */
|
||
10 years ago
|
void setYaw (double _yaw);
|
||
14 years ago
|
/** @brief Set the waypoint action */
|
||
10 years ago
|
void setAction (int _action);
|
||
|
void setFrame (int _frame);
|
||
15 years ago
|
void setAutocontinue(bool autoContinue);
|
||
10 years ago
|
void setCurrent (bool _current);
|
||
|
void setLoiterOrbit (double _orbit);
|
||
|
void setParam1 (double _param1);
|
||
|
void setParam2 (double _param2);
|
||
|
void setParam3 (double param3);
|
||
|
void setParam4 (double param4);
|
||
|
void setParam5 (double param5);
|
||
|
void setParam6 (double param6);
|
||
|
void setParam7 (double param7);
|
||
14 years ago
|
void setAcceptanceRadius(double radius);
|
||
10 years ago
|
void setHoldTime (int holdTime);
|
||
|
void setHoldTime (double holdTime);
|
||
14 years ago
|
/** @brief Number of turns for loiter waypoints */
|
||
10 years ago
|
void setTurns (int _turns);
|
||
14 years ago
|
/** @brief Set waypoint as reached */
|
||
10 years ago
|
void setReached () { _reachedTime = QGC::groundTimeMilliseconds(); }
|
||
14 years ago
|
/** @brief Wether this waypoint has been reached yet */
|
||
10 years ago
|
bool isReached () { return (_reachedTime > 0); }
|
||
|
|
||
11 years ago
|
void setChanged() {
|
||
|
emit changed(this);
|
||
|
}
|
||
14 years ago
|
|
||
|
signals:
|
||
|
/** @brief Announces a change to the waypoint data */
|
||
10 years ago
|
void changed(MissionItem* wp);
|
||
10 years ago
|
|
||
|
void latitudeChanged ();
|
||
|
void longitudeChanged ();
|
||
|
void altitudeChanged ();
|
||
10 years ago
|
void hasCoordinateChanged(bool hasCoordinate);
|
||
10 years ago
|
void coordinateChanged(void);
|
||
10 years ago
|
void commandNameChanged(QString type);
|
||
|
void commandChanged(MavlinkQmlSingleton::Qml_MAV_CMD command);
|
||
|
void valueLabelsChanged(QStringList valueLabels);
|
||
|
void valueStringsChanged(QStringList valueStrings);
|
||
|
|
||
|
private:
|
||
|
QString _oneDecimalString(double value);
|
||
15 years ago
|
};
|
||
|
|
||
10 years ago
|
QML_DECLARE_TYPE(MissionItem)
|
||
10 years ago
|
|
||
10 years ago
|
#endif
|