Commit 88450aa6 authored by Don Gagne's avatar Don Gagne

Merge pull request #1322 from DonLakeFlyer/UnusedCode

Remove unused code
parents 4e74c374 379d3819
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 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/>.
======================================================================*/
/**
* @file
* @brief Connection to OpalRT
* @author Bryan Godbolt <godbolt@ualberta.ca>
*/
#ifndef OPALLINK_H
#define OPALLINK_H
#include <QMutex>
#include <QDebug>
#include <QTextStreamManipulator>
#include <QTimer>
#include <QQueue>
#include <QByteArray>
#include <QObject>
#include <stdlib.h>
#include "LinkInterface.h"
#include "LinkManager.h"
#include "MG.h"
#include "QGCMAVLink.h"
#include "QGCConfig.h"
#include "OpalRT.h"
#include "ParameterList.h"
#include "Parameter.h"
#include "QGCParamID.h"
#include "OpalApi.h"
#include "errno.h"
#include "string.h"
/**
* @brief Interface to OpalRT targets
*
* This is an interface to the OpalRT hardware-in-the-loop (HIL) simulator.
* This class receives MAVLink packets as if it is a true link, but it
* interprets the packets internally, and calls the appropriate api functions.
*
* @author Bryan Godbolt <godbolt@ualberta.ca>
* @ref http://www.opal-rt.com/
*/
class OpalLink : public LinkInterface
{
Q_OBJECT
public:
OpalLink();
/* Connection management */
int getId() const;
QString getName() const;
bool isConnected() const;
qint64 getConnectionSpeed() const;
qint64 getCurrentInDataRate() const;
qint64 getCurrentOutDataRate() const;
void run();
int getOpalInstID() {
return static_cast<int>(opalInstID);
}
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void);
bool disconnect(void);
public slots:
void writeBytes(const char *bytes, qint64 length);
void readBytes();
void heartbeat();
void getSignals();
void setOpalInstID(int instID) {
opalInstID = static_cast<unsigned short>(instID);
}
protected slots:
void receiveMessage(mavlink_message_t message);
void setSignals(double *values);
protected:
QString name;
int id;
bool connectState;
quint64 connectionStartTime;
QMutex receiveDataMutex;
void setName(QString name);
QTimer* heartbeatTimer; ///< Timer to emit heartbeats
int heartbeatRate; ///< Heartbeat rate, controls the timer interval
bool m_heartbeatsEnabled; ///< Enabled/disable heartbeat emission
QTimer* getSignalsTimer;
int getSignalsPeriod;
QQueue<QByteArray>* receiveBuffer;
QByteArray* sendBuffer;
const int systemID;
const int componentID;
void getParameterList();
OpalRT::ParameterList *params;
unsigned short opalInstID;
uint16_t duty2PulseMicros(double duty);
uint8_t rescaleNorm(double norm, int ch);
int8_t rescaleControllerOutput(double raw);
bool sendRCValues;
bool sendRawController;
bool sendPosition;
private:
// From LinkInterface
virtual bool _connect(void);
virtual bool _disconnect(void);
};
#endif // OPALLINK_H
#include "OpalRT.h"
#include "QGCMessageBox.h"
namespace OpalRT
{
// lastErrorMsg = QString();
void OpalErrorMsg::displayLastErrorMsg()
{
static QString lastErrorMsg;
setLastErrorMsg();
QGCMessageBox::critical(QString(), lastErrorMsg);
}
void OpalErrorMsg::setLastErrorMsg()
{
char* buf = new char[512];
unsigned short len;
static QString lastErrorMsg;
OpalGetLastErrMsg(buf, sizeof(buf), &len);
lastErrorMsg.clear();
lastErrorMsg.append(buf);
delete buf;
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 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/>.
======================================================================*/
/**
* @file
* @brief Types used for Opal-RT interface configuration
* @author Bryan Godbolt <godbolt@ualberta.ca>
*/
#ifndef OPALRT_H
#define OPALRT_H
#include <QString>
#include "OpalApi.h"
namespace OpalRT
{
/**
Configuration info for the model
*/
const unsigned short NUM_OUTPUT_SIGNALS=48;
/* ------------------------------ Outputs ------------------------------
*
* Port 1: Navigation state estimates
* 1 t [s] time elapsed since INS mode started
* 2-4 p^n [m] navigation frame position (N,E,D)
* 5-7 v^n [m/s] navigation frame velocity (N,E,D)
* 8-10 Euler angles [rad] (roll, pitch, yaw)
* 11-13 Angular rates
* 14-16 b_f [m/s^2] accelerometer biases
* 17-19 b_w [rad/s] gyro biases
*
* Port 2: Navigation system status
* 1 mode (0: initialization, 1: INS)
* 2 t_GPS time elapsed since last valid GPS measurement
* 3 solution status (0: SOL_COMPUTED, 1: INSUFFICIENT_OBS)
* 4 position solution type ( 0: NONE, 34: NARROW_FLOAT,
* 49: WIDE_INT, 50: NARROW_INT)
* 5 # obs (number of visible satellites)
*
* Port 3: Covariance matrix diagonal
* 1-15 diagonal elements of estimation error covariance matrix P
*/
enum SignalPort {
T_ELAPSED,
X_POS,
Y_POS,
Z_POS,
X_VEL,
Y_VEL,
Z_VEL,
ROLL,
PITCH,
YAW,
ROLL_SPEED,
PITCH_SPEED,
YAW_SPEED,
B_F_0,
B_F_1,
B_F_2,
B_W_0,
B_W_1,
B_W_2,
RAW_CHANNEL_1 = 24,
RAW_CHANNEL_2,
RAW_CHANNEL_3,
RAW_CHANNEL_4,
RAW_CHANNEL_5,
RAW_CHANNEL_6,
RAW_CHANNEL_7,
RAW_CHANNEL_8,
NORM_CHANNEL_1,
NORM_CHANNEL_2,
NORM_CHANNEL_3,
NORM_CHANNEL_4,
NORM_CHANNEL_5,
NORM_CHANNEL_6,
NORM_CHANNEL_7,
NORM_CHANNEL_8,
CONTROLLER_AILERON,
CONTROLLER_ELEVATOR,
AIL_POUT,
AIL_IOUT,
AIL_DOUT,
ELE_POUT,
ELE_IOUT,
ELE_DOUT
};
/** Component IDs of the parameters. Currently they are all 1 becuase there is no advantage
to dividing them between component ids. However this syntax is used so that this can
easily be changed in the future.
*/
enum SubsystemIds {
NAV = 1,
LOG,
CONTROLLER,
SERVO_OUTPUTS,
SERVO_INPUTS
};
class OpalErrorMsg
{
static QString lastErrorMsg;
public:
static void displayLastErrorMsg();
static void setLastErrorMsg();
};
}
#endif // OPALRT_H
#include "OpalLinkConfigurationWindow.h"
OpalLinkConfigurationWindow::OpalLinkConfigurationWindow(OpalLink* link,
QWidget *parent,
Qt::WindowFlags flags) :
QWidget(parent, flags),
link(link)
{
ui.setupUi(this);
ui.opalInstIDSpinBox->setValue(this->link->getOpalInstID());
connect(ui.opalInstIDSpinBox, SIGNAL(valueChanged(int)), link, SLOT(setOpalInstID(int)));
connect(link, &LinkInterface::connected, this, OpalLinkConfigurationWindow::_linkConnected);
connect(link, &LinkInterface::disconnected, this, OpalLinkConfigurationWindow::_linkDisconnected);
this->show();
}
void OpalLinkConfigurationWindow::_linkConnected(void)
{
_allowSettingsAccess(true);
}
void OpalLinkConfigurationWindow::_linkConnected(void)
{
_allowSettingsAccess(false);
}
void OpalLinkConfigurationWindow::_allowSettingsAccess(bool enabled)
{
ui.paramFileButton->setEnabled(enabled);
ui.servoConfigFileButton->setEnabled(enabled);
}
#ifndef OPALLINKCONFIGURATIONWINDOW_H
#define OPALLINKCONFIGURATIONWINDOW_H
#include <QWidget>
#include <QDebug>
#include "LinkInterface.h"
#include "ui_OpalLinkSettings.h"
#include "OpalLink.h"
class OpalLinkConfigurationWindow : public QWidget
{
Q_OBJECT
public:
explicit OpalLinkConfigurationWindow(OpalLink* link, QWidget *parent = 0, Qt::WindowFlags flags = Qt::Sheet);
signals:
private slots:
void _linkConnected(void);
void _linkDisconnected(void);
private:
void _allowSettingsAccess(bool enabled);
Ui::OpalLinkSettings ui;
OpalLink* link;
};
#endif // OPALLINKCONFIGURATIONWINDOW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpalLinkSettings</class>
<widget class="QWidget" name="OpalLinkSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<height>250</height>
</rect>
</property>
<property name="windowTitle">
<string>OpalLink Configuration</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="portlabel">
<property name="text">
<string>Model Instance ID</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="portlabel_2">
<property name="text">
<string>Opal-RT Parameter File</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="portlabel_3">
<property name="text">
<string>Servo Configuration File</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>431</width>
<height>47</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="paramFileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Change</string>
</property>
<property name="icon">
<iconset resource="../../qgroundcontrol.qrc">
<normaloff>:/files/images/status/folder-open.svg</normaloff>:/files/images/status/folder-open.svg</iconset>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="servoConfigFileButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Change</string>
</property>
<property name="icon">
<iconset resource="../../qgroundcontrol.qrc">
<normaloff>:/files/images/status/folder-open.svg</normaloff>:/files/images/status/folder-open.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
<item>
<widget class="QSpinBox" name="opalInstIDSpinBox">
<property name="minimum">
<number>101</number>
</property>
<property name="maximum">
<number>200</number>
</property>
<property name="value">
<number>101</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<action name="actionDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="toolTip">
<string>Delete this link</string>
</property>
</action>
<action name="actionConnect">
<property name="text">
<string>Connect</string>
</property>
<property name="toolTip">
<string>Connect this link</string>
</property>
</action>
<action name="actionClose">
<property name="text">
<string>Close</string>
</property>
<property name="toolTip">
<string>Close the configuration window</string>
</property>
</action>
</widget>
<resources>
<include location="../../qgroundcontrol.qrc"/>
</resources>
<connections>
<connection>
<sender>actionClose</sender>
<signal>triggered()</signal>
<receiver>OpalLinkSettings</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>224</x>
<y>195</y>
</hint>
</hints>
</connection>
</connections>
</ui>
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