1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

Merged in alessiomorale/librepilot/LP-366_wp_default_altitude_velocity (pull request #292)

LP-366 - Add configuration settings for default waypoint's velocity and altitude
This commit is contained in:
Lalanne Laurent 2016-08-06 00:50:18 +02:00
commit d6a00d25ff
9 changed files with 379 additions and 176 deletions

View File

@ -373,10 +373,10 @@ bool flightDataModel::insertRows(int row, int count, const QModelIndex & /*paren
data->lngPosition = 0;
data->disRelative = 0;
data->beaRelative = 0;
data->altitudeRelative = 0;
data->altitudeRelative = defaultWaypointAltitude();
data->isRelative = true;
data->altitude = 0;
data->velocity = 0;
data->velocity = defaultWaypointVelocity();
data->mode = 1;
data->mode_params[0] = 0;
data->mode_params[1] = 0;
@ -668,3 +668,23 @@ void flightDataModel::readFromFile(QString fileName)
node = node.nextSibling();
}
}
qreal flightDataModel::defaultWaypointAltitude() const
{
return m_defaultWaypointAltitude;
}
qreal flightDataModel::defaultWaypointVelocity() const
{
return m_defaultWaypointVelocity;
}
void flightDataModel::setDefaultWaypointAltitude(qreal default_altitude)
{
m_defaultWaypointAltitude = default_altitude;
}
void flightDataModel::setDefaultWaypointVelocity(qreal default_velocity)
{
m_defaultWaypointVelocity = default_velocity;
}

View File

@ -70,10 +70,17 @@ public:
bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
bool writeToFile(QString filename);
void readFromFile(QString fileName);
qreal defaultWaypointAltitude() const;
qreal defaultWaypointVelocity() const;
void setDefaultWaypointAltitude(qreal default_altitude);
void setDefaultWaypointVelocity(qreal default_velocity);
private:
QList<pathPlanData *> dataStorage;
QVariant getColumnByIndex(const pathPlanData *row, const int index) const;
bool setColumnByIndex(pathPlanData *row, const int index, const QVariant value);
qreal m_defaultWaypointAltitude;
qreal m_defaultWaypointVelocity;
};
#endif // FLIGHTDATAMODEL_H

View File

@ -69,4 +69,6 @@ void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
m_widget->setPosition(QPointF(m_config->longitude(), m_config->latitude()));
m_widget->setHomePosition(QPointF(m_config->longitude(), m_config->latitude()));
m_widget->setOverlayOpacity(m_config->opacity());
m_widget->setDefaultWaypointAltitude(m_config->defaultWaypointAltitude());
m_widget->setDefaultWaypointVelocity(m_config->defaultWaypointVelocity());
}

View File

@ -43,7 +43,9 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings *q
m_uavSymbol(QString::fromUtf8(":/uavs/images/mapquad.png")),
m_maxUpdateRate(2000), // ms
m_settings(qSettings),
m_opacity(1)
m_opacity(1),
m_defaultWaypointAltitude(15),
m_defaultWaypointVelocity(2)
{
// if a saved configuration exists load it
if (qSettings != 0) {
@ -58,7 +60,8 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings *q
QString cacheLocation = qSettings->value("cacheLocation").toString();
QString uavSymbol = qSettings->value("uavSymbol").toString();
int max_update_rate = qSettings->value("maxUpdateRate").toInt();
m_defaultWaypointAltitude = qSettings->value("defaultWaypointAltitude", 15).toReal();
m_defaultWaypointVelocity = qSettings->value("defaultWaypointVelocity", 2).toReal();
m_opacity = qSettings->value("overlayOpacity", 1).toReal();
if (!mapProvider.isEmpty()) {
@ -102,6 +105,8 @@ IUAVGadgetConfiguration *OPMapGadgetConfiguration::clone()
m->m_uavSymbol = m_uavSymbol;
m->m_maxUpdateRate = m_maxUpdateRate;
m->m_opacity = m_opacity;
m->m_defaultWaypointAltitude = m_defaultWaypointAltitude;
m->m_defaultWaypointVelocity = m_defaultWaypointVelocity;
return m;
}
@ -127,6 +132,9 @@ void OPMapGadgetConfiguration::saveConfig(QSettings *qSettings) const
qSettings->setValue("cacheLocation", Utils::RemoveStoragePath(m_cacheLocation));
qSettings->setValue("maxUpdateRate", m_maxUpdateRate);
qSettings->setValue("overlayOpacity", m_opacity);
qSettings->setValue("defaultWaypointAltitude", m_defaultWaypointAltitude);
qSettings->setValue("defaultWaypointVelocity", m_defaultWaypointVelocity);
}
void OPMapGadgetConfiguration::setCacheLocation(QString cacheLocation)
{

View File

@ -46,6 +46,8 @@ class OPMapGadgetConfiguration : public IUAVGadgetConfiguration {
Q_PROPERTY(QString uavSymbol READ uavSymbol WRITE setUavSymbol)
Q_PROPERTY(int maxUpdateRate READ maxUpdateRate WRITE setMaxUpdateRate)
Q_PROPERTY(qreal overlayOpacity READ opacity WRITE setOpacity)
Q_PROPERTY(qreal defaultWaypointAltitude READ defaultWaypointAltitude WRITE setDefaultWaypointAltitude)
Q_PROPERTY(qreal defaultWaypointVelocity READ defaultWaypointVelocity WRITE setDefaultWaypointVelocity)
public:
explicit OPMapGadgetConfiguration(QString classId, QSettings *qSettings = 0, QObject *parent = 0);
@ -101,6 +103,17 @@ public:
{
return m_opacity;
}
qreal defaultWaypointAltitude() const
{
return m_defaultWaypointAltitude;
}
qreal defaultWaypointVelocity() const
{
return m_defaultWaypointVelocity;
}
void save() const;
public slots:
void setMapProvider(QString provider)
@ -149,6 +162,16 @@ public slots:
m_maxUpdateRate = update_rate;
}
void setDefaultWaypointAltitude(qreal default_altitude)
{
m_defaultWaypointAltitude = default_altitude;
}
void setDefaultWaypointVelocity(qreal default_velocity)
{
m_defaultWaypointVelocity = default_velocity;
}
private:
QString m_mapProvider;
int m_defaultZoom;
@ -163,6 +186,8 @@ private:
int m_maxUpdateRate;
QSettings *m_settings;
qreal m_opacity;
qreal m_defaultWaypointAltitude;
qreal m_defaultWaypointVelocity;
};
#endif // OPMAP_GADGETCONFIGURATION_H

View File

@ -109,6 +109,8 @@ QWidget *OPMapGadgetOptionsPage::createPage(QWidget *parent)
}
}
m_page->defaultWaypointAltitude->setValue(m_config->defaultWaypointAltitude());
m_page->defaultWaypointVelocity->setValue(m_config->defaultWaypointVelocity());
connect(m_page->pushButtonCacheDefaults, SIGNAL(clicked()), this, SLOT(on_pushButtonCacheDefaults_clicked()));
return w;
@ -138,6 +140,8 @@ void OPMapGadgetOptionsPage::apply()
m_config->setCacheLocation(m_page->lineEditCacheLocation->path());
m_config->setUavSymbol(m_page->uavSymbolComboBox->itemData(m_page->uavSymbolComboBox->currentIndex()).toString());
m_config->setMaxUpdateRate(m_page->maxUpdateRateComboBox->itemData(m_page->maxUpdateRateComboBox->currentIndex()).toInt());
m_config->setDefaultWaypointAltitude(m_page->defaultWaypointAltitude->value());
m_config->setDefaultWaypointVelocity(m_page->defaultWaypointVelocity->value());
}
void OPMapGadgetOptionsPage::finish()

View File

@ -26,7 +26,16 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -45,8 +54,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>391</height>
<width>549</width>
<height>401</height>
</rect>
</property>
<property name="sizePolicy">
@ -56,178 +65,28 @@
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<item row="6" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>UAV Symbol</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="uavSymbolComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Waypoint Options</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cache location </string>
</property>
</widget>
</item>
<item>
<widget class="Utils::PathChooser" name="lineEditCacheLocation" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonCacheDefaults">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
<property name="toolTip">
<string>Restore default server and cache settings</string>
</property>
<property name="text">
<string> Default </string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Access mode </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="accessModeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>160</width>
<height>0</height>
</size>
</property>
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxUseMemoryCache">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Use Memory Cache</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0" rowminimumheight="22,22,22,0,22,0">
<item row="2" column="0">
@ -463,7 +322,248 @@
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,0,0,0,0">
<item>
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Default relative Altitude</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="defaultWaypointAltitude">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>-1000.000000000000000</double>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Default Velocity</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="defaultWaypointVelocity">
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>50.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="9" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>UAV Symbol</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="uavSymbolComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Access mode </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="accessModeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>160</width>
<height>0</height>
</size>
</property>
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxUseMemoryCache">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Use Memory Cache</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cache location </string>
</property>
</widget>
</item>
<item>
<widget class="Utils::PathChooser" name="lineEditCacheLocation" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonCacheDefaults">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
<property name="toolTip">
<string>Restore default server and cache settings</string>
</property>
<property name="text">
<string> Default </string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Server and Cache</string>
@ -473,7 +573,7 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="10" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -489,6 +589,20 @@
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@ -220,6 +220,8 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
}
#ifdef USE_PATHPLANNER
model = new flightDataModel(this);
model->setDefaultWaypointAltitude(m_defaultWaypointAltitude);
model->setDefaultWaypointVelocity(m_defaultWaypointVelocity);
table = new pathPlanner();
selectionModel = new QItemSelectionModel(model);
mapProxy = new modelMapProxy(this, m_map, model, selectionModel);
@ -2372,3 +2374,19 @@ void OPMapGadgetWidget::on_leFind_returnPressed()
{
on_tbFind_clicked();
}
void OPMapGadgetWidget::setDefaultWaypointAltitude(qreal default_altitude)
{
m_defaultWaypointAltitude = default_altitude;
if (model) {
model->setDefaultWaypointAltitude(default_altitude);
}
}
void OPMapGadgetWidget::setDefaultWaypointVelocity(qreal default_velocity)
{
m_defaultWaypointVelocity = default_velocity;
if (model) {
model->setDefaultWaypointVelocity(default_velocity);
}
}

View File

@ -113,6 +113,8 @@ public:
void setMaxUpdateRate(int update_rate);
void setHomePosition(QPointF pos);
void setOverlayOpacity(qreal value);
void setDefaultWaypointAltitude(qreal default_altitude);
void setDefaultWaypointVelocity(qreal default_velocity);
bool getGPSPositionSensor(double &latitude, double &longitude, double &altitude);
signals:
void defaultLocationAndZoomChanged(double lng, double lat, double zoom);
@ -212,6 +214,9 @@ private slots:
void on_leFind_returnPressed();
private:
qreal m_defaultWaypointAltitude;
qreal m_defaultWaypointVelocity;
int m_min_zoom;
int m_max_zoom;
double m_heading; // uav heading