Commit ea7dbf52 authored by pixhawk's avatar pixhawk

Working on parameter groups

parent 777a7031
...@@ -198,5 +198,6 @@ SOURCES += src/main.cc \ ...@@ -198,5 +198,6 @@ SOURCES += src/main.cc \
src/ui/watchdog/WatchdogProcessView.cc \ src/ui/watchdog/WatchdogProcessView.cc \
src/ui/watchdog/WatchdogView.cc \ src/ui/watchdog/WatchdogView.cc \
src/uas/UASWaypointManager.cc \ src/uas/UASWaypointManager.cc \
src/ui/HSIDisplay.cc src/ui/HSIDisplay.cc \
src/QGC.cc
RESOURCES = mavground.qrc RESOURCES = mavground.qrc
#include "QGC.h"
namespace QGC {
quint64 groundTimeUsecs()
{
QDateTime time = QDateTime::currentDateTime();
time = time.toUTC();
/* Return seconds and milliseconds, in milliseconds unit */
quint64 microseconds = time.toTime_t() * static_cast<quint64>(1000000);
return static_cast<quint64>(microseconds + (time.time().msec()*1000));
}
}
...@@ -8,14 +8,8 @@ namespace QGC ...@@ -8,14 +8,8 @@ namespace QGC
{ {
const QColor ColorCyan(55, 154, 195); const QColor ColorCyan(55, 154, 195);
static quint64 groundTimeUsecs() /** @brief Get the current ground time in microseconds */
{ quint64 groundTimeUsecs();
QDateTime time = QDateTime::currentDateTime();
time = time.toUTC();
/* Return seconds and milliseconds, in milliseconds unit */
quint64 microseconds = time.toTime_t() * static_cast<quint64>(1000000);
return static_cast<quint64>(microseconds + (time.time().msec()*1000));
}
} }
#endif // QGC_H #endif // QGC_H
...@@ -377,9 +377,20 @@ void MAVLinkSimulationLink::mainloop() ...@@ -377,9 +377,20 @@ void MAVLinkSimulationLink::mainloop()
rate10hzCounter = 1; rate10hzCounter = 1;
// Move X Position // Move X Position
x += sin(QGC::groundTimeUsecs()); x += sin(QGC::groundTimeUsecs()) * 0.1f;
y += sin(QGC::groundTimeUsecs()); y += sin(QGC::groundTimeUsecs()) * 0.1f;
z += sin(QGC::groundTimeUsecs()); z += sin(QGC::groundTimeUsecs()) * 0.1f;
x = (x > 1.0f) ? 1.0f : x;
y = (y > 1.0f) ? 1.0f : y;
z = (z > 1.0f) ? 1.0f : z;
// Send back new setpoint
mavlink_message_t ret;
mavlink_msg_local_position_setpoint_pack(systemId, componentId, &ret, spX, spY, spZ, spYaw);
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
} }
// 1 HZ TASKS // 1 HZ TASKS
......
...@@ -492,7 +492,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -492,7 +492,8 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
void UAS::setLocalPositionSetpoint(float x, float y, float z, float yaw) void UAS::setLocalPositionSetpoint(float x, float y, float z, float yaw)
{ {
mavlink_message_t msg; mavlink_message_t msg;
mavlink_msg_position_control_setpoint_set_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, uasId, 0, 0, x, y, z, yaw);
sendMessage(msg);
} }
quint64 UAS::getUnixTime(quint64 time) quint64 UAS::getUnixTime(quint64 time)
......
...@@ -205,6 +205,8 @@ public slots: ...@@ -205,6 +205,8 @@ public slots:
virtual void enableRawControllerDataTransmission(bool enabled) = 0; virtual void enableRawControllerDataTransmission(bool enabled) = 0;
virtual void enableRawSensorFusionTransmission(bool enabled) = 0; virtual void enableRawSensorFusionTransmission(bool enabled) = 0;
virtual void setLocalPositionSetpoint(float x, float y, float z, float yaw) = 0;
protected: protected:
QColor color; QColor color;
......
...@@ -210,6 +210,7 @@ void HDDisplay::setActiveUAS(UASInterface* uas) ...@@ -210,6 +210,7 @@ void HDDisplay::setActiveUAS(UASInterface* uas)
// Setup communication // Setup communication
connect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64))); connect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64)));
//} //}
this->uas = uas;
} }
/** /**
......
...@@ -392,7 +392,11 @@ void HSIDisplay::setBodySetpointCoordinateXY(double x, double y) ...@@ -392,7 +392,11 @@ void HSIDisplay::setBodySetpointCoordinateXY(double x, double y)
uiXSetCoordinate = sp.x(); uiXSetCoordinate = sp.x();
uiYSetCoordinate = sp.y(); uiYSetCoordinate = sp.y();
qDebug() << "Setting new setpoint at x: " << x << "metric y:" << y; if (uas)
{
uas->setLocalPositionSetpoint(uiXSetCoordinate, uiYSetCoordinate, uiZSetCoordinate, uiYawSet);
qDebug() << "Setting new setpoint at x: " << x << "metric y:" << y;
}
} }
void HSIDisplay::setBodySetpointCoordinateZ(double z) void HSIDisplay::setBodySetpointCoordinateZ(double z)
......
...@@ -44,7 +44,8 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) : ...@@ -44,7 +44,8 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
QWidget(parent), QWidget(parent),
mav(uas), mav(uas),
components(new QMap<int, QTreeWidgetItem*>()), components(new QMap<int, QTreeWidgetItem*>()),
changedValues()//QMap<int, QMap<QString, float>* >()) paramGroups(),
changedValues()
{ {
// Create tree widget // Create tree widget
tree = new QTreeWidget(this); tree = new QTreeWidget(this);
...@@ -107,15 +108,22 @@ UASInterface* QGCParamWidget::getUAS() ...@@ -107,15 +108,22 @@ UASInterface* QGCParamWidget::getUAS()
void QGCParamWidget::addComponent(int uas, int component, QString componentName) void QGCParamWidget::addComponent(int uas, int component, QString componentName)
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
QStringList list; if (components->contains(component))
list.append(componentName);
list.append(QString::number(component));
QTreeWidgetItem* comp = new QTreeWidgetItem(list);
bool updated = false;
if (components->contains(component)) updated = true;
components->insert(component, comp);
if (!updated)
{ {
// Update existing
components->value(component)->setData(0, Qt::DisplayRole, componentName);
components->value(component)->setData(1, Qt::DisplayRole, QString::number(component));
}
else
{
// Add new
QStringList list;
list.append(componentName);
list.append(QString::number(component));
QTreeWidgetItem* comp = new QTreeWidgetItem(list);
components->insert(component, comp);
// Create grouping and update maps
paramGroups.insert(component, new QMap<QString, QTreeWidgetItem*>());
tree->addTopLevelItem(comp); tree->addTopLevelItem(comp);
tree->update(); tree->update();
} }
...@@ -130,15 +138,6 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName, ...@@ -130,15 +138,6 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName,
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
// Insert parameter into map // Insert parameter into map
QString splitToken = "_";
// Check if auto-grouping can work
/*
if (parameterName.contains(splitToken))
{
QString parent = parameterName.section(splitToken, 0, 0, QString::SectionSkipEmpty);
QString children = parameterName.section(splitToken, 1, -1, QString::SectionSkipEmpty);
}*/
QStringList plist; QStringList plist;
plist.append(parameterName); plist.append(parameterName);
plist.append(QString::number(value)); plist.append(QString::number(value));
...@@ -150,27 +149,46 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName, ...@@ -150,27 +149,46 @@ void QGCParamWidget::addParameter(int uas, int component, QString parameterName,
addComponent(uas, component, "Component #" + QString::number(component)); addComponent(uas, component, "Component #" + QString::number(component));
} }
bool found = false; QString splitToken = "_";
QTreeWidgetItem* parent = components->value(component); // Check if auto-grouping can work
for (int i = 0; i < parent->childCount(); i++) if (parameterName.contains(splitToken))
{ {
QTreeWidgetItem* child = parent->child(i); QString parent = parameterName.section(splitToken, 0, 0, QString::SectionSkipEmpty);
QString key = child->data(0, Qt::DisplayRole).toString(); QMap<QString, QTreeWidgetItem*>* compParamGroups = paramGroups.value(component);
if (key == parameterName) if (!compParamGroups->contains(parent))
{ {
qDebug() << "UPDATED CHILD"; // Insert group item
child->setData(1, Qt::DisplayRole, value); QStringList glist;
found = true; glist.append(parent);
QTreeWidgetItem* item = new QTreeWidgetItem(glist);
compParamGroups->insert(parent, item);
components->value(component)->addChild(item);
} }
} }
else
if (!found)
{ {
components->value(component)->addChild(item); bool found = false;
item->setFlags(item->flags() | Qt::ItemIsEditable); QTreeWidgetItem* parent = components->value(component);
for (int i = 0; i < parent->childCount(); i++)
{
QTreeWidgetItem* child = parent->child(i);
QString key = child->data(0, Qt::DisplayRole).toString();
if (key == parameterName)
{
//qDebug() << "UPDATED CHILD";
child->setData(1, Qt::DisplayRole, value);
found = true;
}
}
if (!found)
{
components->value(component)->addChild(item);
item->setFlags(item->flags() | Qt::ItemIsEditable);
}
//connect(item, SIGNAL())
tree->expandAll();
} }
//connect(item, SIGNAL())
tree->expandAll();
tree->update(); tree->update();
} }
...@@ -213,6 +231,7 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column) ...@@ -213,6 +231,7 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column)
{ {
qDebug() << "PARAM CHANGED: COMP:" << key << "KEY:" << str << "VALUE:" << value; qDebug() << "PARAM CHANGED: COMP:" << key << "KEY:" << str << "VALUE:" << value;
map->insert(str, value); map->insert(str, value);
// FIXME CHANGE COLOR OF CHANGED PARAM
} }
} }
} }
......
...@@ -73,6 +73,7 @@ protected: ...@@ -73,6 +73,7 @@ protected:
UASInterface* mav; ///< The MAV this widget is controlling UASInterface* mav; ///< The MAV this widget is controlling
QTreeWidget* tree; ///< The parameter tree QTreeWidget* tree; ///< The parameter tree
QMap<int, QTreeWidgetItem*>* components; ///< The list of components QMap<int, QTreeWidgetItem*>* components; ///< The list of components
QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups
QMap<int, QMap<QString, float>* > changedValues; ///< Changed values QMap<int, QMap<QString, float>* > changedValues; ///< Changed values
}; };
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout" rowminimumheight="0,0,0,0,0,0,100">
<property name="leftMargin"> <property name="leftMargin">
<number>6</number> <number>6</number>
</property> </property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment