Commit 4406f5c5 authored by lm's avatar lm

Updated sensor read pool

parent 1c1f5379
...@@ -62,7 +62,9 @@ UAS::UAS(int id=0) : ...@@ -62,7 +62,9 @@ UAS::UAS(int id=0) :
manualRollAngle(0), manualRollAngle(0),
manualPitchAngle(0), manualPitchAngle(0),
manualYawAngle(0), manualYawAngle(0),
manualThrust(0) manualThrust(0),
receiveDropRate(0),
sendDropRate(0)
{ {
uasId = id; uasId = id;
setBattery(LIPOLY, 3); setBattery(LIPOLY, 3);
...@@ -173,7 +175,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -173,7 +175,10 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit batteryChanged(this, filterVoltage(), getChargeLevel(), timeRemaining); emit batteryChanged(this, filterVoltage(), getChargeLevel(), timeRemaining);
emit voltageChanged(message.sysid, state.vbat/1000.0f); emit voltageChanged(message.sysid, state.vbat/1000.0f);
// Output audio // COMMUNICATIONS DROP RATE
emit dropRateChanged(this->getUASID(), this->receiveDropRate, this->sendDropRate);
// AUDIO
if (modechanged && statechanged) if (modechanged && statechanged)
{ {
// Output both messages // Output both messages
...@@ -195,6 +200,14 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -195,6 +200,14 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
} }
} }
break; break;
case MAVLINK_MSG_ID_AUX_STATUS:
{
aux_status_t status;
message_aux_status_decode(&message, &status);
emit loadChanged(this, status.load/100.0f);
emit valueChanged(this, "Load", status.load/1000.0f, MG::TIME::getGroundTimeNow());
}
break;
case MAVLINK_MSG_ID_RAW_IMU: case MAVLINK_MSG_ID_RAW_IMU:
{ {
raw_imu_t raw; raw_imu_t raw;
...@@ -224,10 +237,43 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -224,10 +237,43 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit valueChanged(uasId, "Mag. Z", raw.zmag, time); emit valueChanged(uasId, "Mag. Z", raw.zmag, time);
} }
break; break;
case MAVLINK_MSG_ID_RAW_SENSOR:
{
raw_sensor_t raw;
message_raw_imu_decode(&message, &raw);
quint64 time = raw.msec;
if (time == 0)
{
time = MG::TIME::getGroundTimeNow();
}
else
{
if (onboardTimeOffset == 0)
{
onboardTimeOffset = MG::TIME::getGroundTimeNow() - time;
}
time += onboardTimeOffset;
}
emit valueChanged(uasId, "Accel. X", raw.xacc, time);
emit valueChanged(uasId, "Accel. Y", raw.yacc, time);
emit valueChanged(uasId, "Accel. Z", raw.zacc, time);
emit valueChanged(uasId, "Gyro Phi", raw.xgyro, time);
emit valueChanged(uasId, "Gyro Theta", raw.ygyro, time);
emit valueChanged(uasId, "Gyro Psi", raw.zgyro, time);
emit valueChanged(uasId, "Mag. X", raw.xmag, time);
emit valueChanged(uasId, "Mag. Y", raw.ymag, time);
emit valueChanged(uasId, "Mag. Z", raw.zmag, time);
emit valueChanged(uasId, "Pressure", raw.baro, time);
emit valueChanged(uasId, "Temperature", raw.baro, time);
}
break;
case MAVLINK_MSG_ID_ATTITUDE: case MAVLINK_MSG_ID_ATTITUDE:
//std::cerr << std::endl; //std::cerr << std::endl;
//std::cerr << "Decoded attitude message:" << " roll: " << std::dec << message_attitude_get_roll(message.payload) << " pitch: " << message_attitude_get_pitch(message.payload) << " yaw: " << message_attitude_get_yaw(message.payload) << std::endl; //std::cerr << "Decoded attitude message:" << " roll: " << std::dec << message_attitude_get_roll(message.payload) << " pitch: " << message_attitude_get_pitch(message.payload) << " yaw: " << message_attitude_get_yaw(message.payload) << std::endl;
{ {
attitude_t attitude;
message_attitude_decode(&message, &attitude);
quint64 time = message_attitude_get_msec(&message); quint64 time = message_attitude_get_msec(&message);
if (time == 0) if (time == 0)
{ {
...@@ -247,6 +293,9 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -247,6 +293,9 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit valueChanged(this, "roll IMU", message_attitude_get_roll(&message), time); emit valueChanged(this, "roll IMU", message_attitude_get_roll(&message), time);
emit valueChanged(this, "pitch IMU", message_attitude_get_pitch(&message), time); emit valueChanged(this, "pitch IMU", message_attitude_get_pitch(&message), time);
emit valueChanged(this, "yaw IMU", message_attitude_get_yaw(&message), time); emit valueChanged(this, "yaw IMU", message_attitude_get_yaw(&message), time);
emit valueChanged(uasId, "rollspeed IMU", attitude.rollspeed, time);
emit valueChanged(uasId, "pitchspeed IMU", attitude.pitchspeed, time);
emit valueChanged(uasId, "yawspeed IMU", attitude.yawspeed, time);
emit attitudeChanged(this, message_attitude_get_roll(&message), message_attitude_get_pitch(&message), message_attitude_get_yaw(&message), time); emit attitudeChanged(this, message_attitude_get_roll(&message), message_attitude_get_pitch(&message), message_attitude_get_yaw(&message), time);
} }
break; break;
......
...@@ -118,6 +118,8 @@ protected: ...@@ -118,6 +118,8 @@ protected:
double manualPitchAngle; ///< Pitch angle set by human pilot (radians) double manualPitchAngle; ///< Pitch angle set by human pilot (radians)
double manualYawAngle; ///< Yaw angle set by human pilot (radians) double manualYawAngle; ///< Yaw angle set by human pilot (radians)
double manualThrust; ///< Thrust set by human pilot (radians) double manualThrust; ///< Thrust set by human pilot (radians)
float receiveDropRate; ///< Percentage of packets that were dropped on the MAV's receiving link (from GCS and other MAVs)
float sendDropRate; ///< Percentage of packets that were not received from the MAV by the GCS
/** @brief Set the current battery type */ /** @brief Set the current battery type */
void setBattery(BatteryType type, int cells); void setBattery(BatteryType type, int cells);
......
...@@ -47,7 +47,8 @@ This file is part of the PIXHAWK project ...@@ -47,7 +47,8 @@ This file is part of the PIXHAWK project
* This interface is abstract and thus cannot be instantiated. It serves only as type definition. * This interface is abstract and thus cannot be instantiated. It serves only as type definition.
* It represents an unmanned aerial vehicle, e.g. a micro air vehicle. * It represents an unmanned aerial vehicle, e.g. a micro air vehicle.
**/ **/
class UASInterface : public QObject { class UASInterface : public QObject
{
Q_OBJECT Q_OBJECT
public: public:
UASInterface() : UASInterface() :
...@@ -207,6 +208,14 @@ signals: ...@@ -207,6 +208,14 @@ signals:
* @param description longer textual description. Should be however limited to a short text, e.g. 200 chars. * @param description longer textual description. Should be however limited to a short text, e.g. 200 chars.
*/ */
void statusChanged(UASInterface* uas, QString status, QString description); void statusChanged(UASInterface* uas, QString status, QString description);
/**
* @brief Drop rate of communication link updated
*
* @param systemId id of the air system
* @param receiveDrop drop rate of packets this MAV receives (send from GCS or other MAVs)
* @param sendDrop drop rate of packets this MAV sends (received on GCS)
*/
void dropRateChanged(int systemId, float receiveDrop, float sendDrop);
/** @brief Robot mode has changed */ /** @brief Robot mode has changed */
void modeChanged(int sysId, QString status, QString description); void modeChanged(int sysId, QString status, QString description);
/** @brief A command has been issued **/ /** @brief A command has been issued **/
......
...@@ -91,7 +91,7 @@ UASInterface* UASManager::getActiveUAS() ...@@ -91,7 +91,7 @@ UASInterface* UASManager::getActiveUAS()
if(!activeUAS) if(!activeUAS)
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("No Unmanned System loaded. Please add one first.")); msgBox.setText(tr("No Micro Air Vehicle connected. Please connect one first."));
msgBox.exec(); msgBox.exec();
} }
return activeUAS; ///< Return zero pointer if no UAS has been loaded return activeUAS; ///< Return zero pointer if no UAS has been loaded
......
...@@ -313,7 +313,7 @@ void MainWindow::addLink() ...@@ -313,7 +313,7 @@ void MainWindow::addLink()
void MainWindow::UASCreated(UASInterface* uas) void MainWindow::UASCreated(UASInterface* uas)
{ {
// Connect the UAS to the full user interface // Connect the UAS to the full user interface
ui.menuConnected_Systems->addAction(QIcon(":/images/mavs/generic.svg"), tr("View ") + uas->getUASName(), uas, SLOT(setSelected())); //ui.menuConnected_Systems->addAction(QIcon(":/images/mavs/generic.svg"), tr("View ") + uas->getUASName(), uas, SLOT(setSelected()));
// Line chart // Line chart
// FIXME DO THIS ONLY FOR THE FIRST CONNECTED SYSTEM // FIXME DO THIS ONLY FOR THE FIRST CONNECTED SYSTEM
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1000</width> <width>1000</width>
<height>22</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuMGround"> <widget class="QMenu" name="menuMGround">
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionJoystickSettings"/> <addaction name="actionJoystickSettings"/>
<addaction name="actionSettings"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
...@@ -65,11 +64,6 @@ ...@@ -65,11 +64,6 @@
<addaction name="actionAdd_Link"/> <addaction name="actionAdd_Link"/>
<addaction name="separator"/> <addaction name="separator"/>
</widget> </widget>
<widget class="QMenu" name="menuConnected_Systems">
<property name="title">
<string>Systems</string>
</property>
</widget>
<widget class="QMenu" name="menuWindow"> <widget class="QMenu" name="menuWindow">
<property name="title"> <property name="title">
<string>Window</string> <string>Window</string>
...@@ -84,7 +78,6 @@ ...@@ -84,7 +78,6 @@
<addaction name="menuMGround"/> <addaction name="menuMGround"/>
<addaction name="menuNetwork"/> <addaction name="menuNetwork"/>
<addaction name="menuUnmanned_System"/> <addaction name="menuUnmanned_System"/>
<addaction name="menuConnected_Systems"/>
<addaction name="menuWindow"/> <addaction name="menuWindow"/>
</widget> </widget>
<widget class="QToolBar" name="mainToolBar"> <widget class="QToolBar" name="mainToolBar">
......
This diff is collapsed.
/*===================================================================== /*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009 PIXHAWK PROJECT <http://pixhawk.ethz.ch> (c) 2009 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project This file is part of the PIXHAWK project
PIXHAWK is free software: you can redistribute it and/or modify PIXHAWK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
PIXHAWK is distributed in the hope that it will be useful, PIXHAWK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>. along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
/** /**
* @file * @file
* @brief Brief Description * @brief Brief Description
...@@ -83,14 +83,14 @@ void UASInfoWidget::addUAS(UASInterface* uas) ...@@ -83,14 +83,14 @@ void UASInfoWidget::addUAS(UASInterface* uas)
{ {
if (uas != NULL) if (uas != NULL)
{ {
// connect(uas, SIGNAL(voltageChanged(int, double)), this, SLOT(setVoltage(int, double))); // connect(uas, SIGNAL(voltageChanged(int, double)), this, SLOT(setVoltage(int, double)));
connect(uas, SIGNAL(batteryChanged(UASInterface*,double,double,int)), this, SLOT(updateBattery(UASInterface*,double,double,int))); connect(uas, SIGNAL(batteryChanged(UASInterface*,double,double,int)), this, SLOT(updateBattery(UASInterface*,double,double,int)));
connect(uas, SIGNAL(valueChanged(int,QString,double,quint64)), this, SLOT(valueChanged(int,QString,double,quint64))); connect(uas, SIGNAL(valueChanged(int,QString,double,quint64)), this, SLOT(valueChanged(int,QString,double,quint64)));
connect(uas, SIGNAL(actuatorChanged(UASInterface*,int,double)), this, SLOT(actuatorChanged(UASInterface*,int,double))); connect(uas, SIGNAL(actuatorChanged(UASInterface*,int,double)), this, SLOT(actuatorChanged(UASInterface*,int,double)));
connect(uas, SIGNAL(loadChanged(UASInterface*, double)), this, SLOT(updateCPULoad(UASInterface*,double))); connect(uas, SIGNAL(loadChanged(UASInterface*, double)), this, SLOT(updateCPULoad(UASInterface*,double)));
// Set this UAS as active if it is the first one // Set this UAS as active if it is the first one
if (activeUAS == 0) activeUAS = uas; if (activeUAS == 0) activeUAS = uas;
} }
} }
...@@ -99,16 +99,7 @@ void UASInfoWidget::setActiveUAS(UASInterface* uas) ...@@ -99,16 +99,7 @@ void UASInfoWidget::setActiveUAS(UASInterface* uas)
activeUAS = uas; activeUAS = uas;
} }
void UASInfoWidget::addInstrument(QString key, double min, double max, double initial, QString unit) /*
{
}
void UASInfoWidget::valueChanged(int uasid, QString key, double value,quint64 time)
{
}
void UASInfoWidget::actuatorChanged(UASInterface* uas, int actId, double value) void UASInfoWidget::actuatorChanged(UASInterface* uas, int actId, double value)
{ {
if (activeUAS == uas) if (activeUAS == uas)
...@@ -133,7 +124,7 @@ void UASInfoWidget::actuatorChanged(UASInterface* uas, int actId, double value) ...@@ -133,7 +124,7 @@ void UASInfoWidget::actuatorChanged(UASInterface* uas, int actId, double value)
break; break;
} }
} }
} }*/
void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double percent, int seconds) void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double percent, int seconds)
{ {
...@@ -142,14 +133,23 @@ void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double perc ...@@ -142,14 +133,23 @@ void UASInfoWidget::updateBattery(UASInterface* uas, double voltage, double perc
setTimeRemaining(uas, seconds); setTimeRemaining(uas, seconds);
} }
/**
*
*/
void UASInfoWidget::updateCPULoad(UASInterface* uas, double load) void UASInfoWidget::updateCPULoad(UASInterface* uas, double load)
{ {
if (activeUAS == uas) if (activeUAS == uas)
{ {
this->load = load; this->load = load*100.0f;
} }
} }
void UASInfoWidget::updateDropRate(int sysId, float receiveDrop, float sendDrop)
{
ui.receiveLossBar->setValue(receiveDrop * 100.0f);
ui.sendLossBar->setValue(sendDrop * 100.0f);
}
//void UASInfoWidget::setBattery(int uasid, BatteryType type, int cells) //void UASInfoWidget::setBattery(int uasid, BatteryType type, int cells)
//{ //{
// this->batteryType = type; // this->batteryType = type;
...@@ -230,19 +230,19 @@ void UASInfoWidget::refresh() ...@@ -230,19 +230,19 @@ void UASInfoWidget::refresh()
ui.loadLabel->setText(QString::number(this->load, 'f', loadDecimals)); ui.loadLabel->setText(QString::number(this->load, 'f', loadDecimals));
ui.loadBar->setValue(static_cast<int>(this->load)); ui.loadBar->setValue(static_cast<int>(this->load));
// if(this->timeRemaining > 1 && this->timeRemaining < MG::MAX_FLIGHT_TIME) // if(this->timeRemaining > 1 && this->timeRemaining < MG::MAX_FLIGHT_TIME)
// { // {
// // Filter output to get a higher stability // // Filter output to get a higher stability
// static int filterTime = static_cast<int>(this->timeRemaining); // static int filterTime = static_cast<int>(this->timeRemaining);
// //filterTime = 0.8 * filterTime + 0.2 * static_cast<int>(this->timeRemaining); // //filterTime = 0.8 * filterTime + 0.2 * static_cast<int>(this->timeRemaining);
// //
// int hours = filterTime % (60 * 60); // int hours = filterTime % (60 * 60);
// int min = (filterTime - hours * 60) % 60; // int min = (filterTime - hours * 60) % 60;
// int sec = (filterTime - hours * 60 - min * 60); // int sec = (filterTime - hours * 60 - min * 60);
// QString timeText; // QString timeText;
// timeText = timeText.sprintf("%02d:%02d:%02d", hours, min, sec); // timeText = timeText.sprintf("%02d:%02d:%02d", hours, min, sec);
// ui.voltageTimeEstimateLabel->setText(timeText); // ui.voltageTimeEstimateLabel->setText(timeText);
// } else { // } else {
// ui.voltageTimeEstimateLabel->setText(tr("Calculating")); // ui.voltageTimeEstimateLabel->setText(tr("Calculating"));
// } // }
} }
...@@ -49,15 +49,6 @@ public: ...@@ -49,15 +49,6 @@ public:
UASInfoWidget(QWidget *parent = 0, QString name = ""); UASInfoWidget(QWidget *parent = 0, QString name = "");
~UASInfoWidget(); ~UASInfoWidget();
// enum BatteryType {
// NICD = 0,
// NIMH = 1,
// LIION = 2,
// LIPOLY = 3,
// LIFE = 4,
// AGZN = 5
// };
public slots: public slots:
void addUAS(UASInterface* uas); void addUAS(UASInterface* uas);
...@@ -65,16 +56,15 @@ public slots: ...@@ -65,16 +56,15 @@ public slots:
void updateBattery(UASInterface* uas, double voltage, double percent, int seconds); void updateBattery(UASInterface* uas, double voltage, double percent, int seconds);
void updateCPULoad(UASInterface* uas, double load); void updateCPULoad(UASInterface* uas, double load);
void updateDropRate(int sysId, float receiveDrop, float sendDrop);
void setVoltage(UASInterface* uas, double voltage); void setVoltage(UASInterface* uas, double voltage);
void setChargeLevel(UASInterface* uas, double chargeLevel); void setChargeLevel(UASInterface* uas, double chargeLevel);
void setTimeRemaining(UASInterface* uas, double seconds); void setTimeRemaining(UASInterface* uas, double seconds);
// void setBattery(int uasid, BatteryType type, int cells); // void setBattery(int uasid, BatteryType type, int cells);
void addInstrument(QString key, double min, double max, double initial, QString unit=""); // void valueChanged(int uasid, QString key, double value,quint64 time);
void valueChanged(int uasid, QString key, double value,quint64 time); // void actuatorChanged(UASInterface* uas, int actId, double value);
void actuatorChanged(UASInterface* uas, int actId, double value);
// double calculateTimeRemaining();
void refresh(); void refresh();
protected: protected:
......
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