Commit a72573de authored by Bryant's avatar Bryant

Remove last remnants of OpalRT support.

parent 5ceb7b27
<ParameterList version="0.1">
<!-- Parameters in the top level block -->
<Block name="TopLevel">
</Block>
<!--Parameters related to the navigation block -->
<Block name="Navigation">
<Parameter
SimulinkPath="avionics_src/sm_avionics/Navigation_Filter/NAV_FILT_INIT/"
SimulinkParameterName="Value"
QGCParamID="NAV_FILT_INIT"
/>
</Block>
<!--Parameters related to the controller block -->
<Block name="Controller">
<!-- Aileron Control Parameters -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_AIL/kp/"
SimulinkParameterName="Gain"
QGCParamID="AIL_KP"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_AIL/ki/"
SimulinkParameterName="Gain"
QGCParamID="AIL_KI"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_AIL/kd/"
SimulinkParameterName="Gain"
QGCParamID="AIL_KD"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_AIL/Angle_Norm/Max_Min_Angle/"
SimulinkParameterName="Value"
QGCParamID="ANG_AIL_MAX"
/>
<!-- Elevator Control Parameters -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_ELE/kp/"
SimulinkParameterName="Gain"
QGCParamID="ELE_KP"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_ELE/ki/"
SimulinkParameterName="Gain"
QGCParamID="ELE_KI"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_ELE/kd/"
SimulinkParameterName="Gain"
QGCParamID="ELE_KD"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Attitude_Controller/PID_ELE/Angle_Norm/Max_Min_Angle/"
SimulinkParameterName="Value"
QGCParamID="ANG_ELE_MAX"
/>
</Block>
<!-- Paremters for the Pilot Input/Raw RC block -->
<Block name="ServoInputs">
<!-- Settings for Aileron Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/AileronInput/"
SimulinkParameterName="Setpoint0"
QGCParamID="AIL_LEFT_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/AileronInput/"
SimulinkParameterName="Setpoint1"
QGCParamID="AIL_CENTER_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/AileronInput/"
SimulinkParameterName="Setpoint2"
QGCParamID="AIL_RIGHT_IN"
/>
<!-- Settings for Elevator Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ElevatorInput/"
SimulinkParameterName="Setpoint0"
QGCParamID="ELE_DOWN_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ElevatorInput/"
SimulinkParameterName="Setpoint1"
QGCParamID="ELE_CENTER_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ElevatorInput/"
SimulinkParameterName="Setpoint2"
QGCParamID="ELE_UP_IN"
/>
<!-- Settings for Throttle Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ThrottleInput/"
SimulinkParameterName="Setpoint0"
QGCParamID="THR_SET0_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ThrottleInput/"
SimulinkParameterName="Setpoint1"
QGCParamID="THR_SET1_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ThrottleInput/"
SimulinkParameterName="Setpoint2"
QGCParamID="THR_SET2_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ThrottleInput/"
SimulinkParameterName="Setpoint3"
QGCParamID="THR_SET3_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/ThrottleInput/"
SimulinkParameterName="Setpoint4"
QGCParamID="THR_SET4_IN"
/>
<!-- Settings for Rudder Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/RudderInput/"
SimulinkParameterName="Setpoint0"
QGCParamID="RUD_LEFT_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/RudderInput/"
SimulinkParameterName="Setpoint1"
QGCParamID="RUD_CENTER_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/RudderInput/"
SimulinkParameterName="Setpoint2"
QGCParamID="RUD_RIGHT_IN"
/>
<!-- Settings for Gyro Mode/Gain Switch -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/GyroInput/"
SimulinkParameterName="Setpoint0"
QGCParamID="GYRO_DEF_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/GyroInput/"
SimulinkParameterName="Setpoint1"
QGCParamID="GYRO_TOG_IN"
/>
<!-- Settings for Pitch Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/PitchInput/"
SimulinkParameterName="Setpoint0"
QGCParamID="PIT_SET0_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/PitchInput/"
SimulinkParameterName="Setpoint1"
QGCParamID="PIT_SET1_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/PitchInput/"
SimulinkParameterName="Setpoint2"
QGCParamID="PIT_SET2_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/PitchInput/"
SimulinkParameterName="Setpoint3"
QGCParamID="PIT_SET3_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/PitchInput/"
SimulinkParameterName="Setpoint4"
QGCParamID="PIT_SET4_IN"
/>
</Block>
<!-- Parameters for the servo output block -->
<Block name="ServoOutputs">
<!-- Settings for Aileron Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/AileronOutput/"
SimulinkParameterName="Setpoint0"
QGCParamID="AIL_LEFT_OUT"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/AileronOutput/"
SimulinkParameterName="Setpoint1"
QGCParamID="AIL_CENTER_OUT"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/AileronOutput/"
SimulinkParameterName="Setpoint2"
QGCParamID="AIL_RIGHT_OUT"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/AileronMix/Controller_Mix/"
SimulinkParameterName="Value"
QGCParamID="MIX_AIL"
/>
<!-- Settings for Elevator Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/ElevatorOutput/"
SimulinkParameterName="Setpoint0"
QGCParamID="ELE_DOWN_OUT"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/ElevatorOutput/"
SimulinkParameterName="Setpoint1"
QGCParamID="ELE_CENTER_OUT"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/ElevatorOutput/"
SimulinkParameterName="Setpoint2"
QGCParamID="ELE_UP_OUT"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Servo_Outputs/ElevatorMix/Controller_Mix/"
SimulinkParameterName="Value"
QGCParamID="MIX_ELE"
/>
</Block>
</ParameterList>
/*=====================================================================
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 Implementation of class OpalRT::Parameter
* @author Bryan Godbolt <godbolt@ualberta.ca>
*/
#include "Parameter.h"
using namespace OpalRT;
//Parameter::Parameter(char *simulinkPath, char *simulinkName, uint8_t componentID,
// QGCParamID paramID, unsigned short opalID)
// : simulinkPath(new QString(simulinkPath)),
// simulinkName(new QString(simulinkName)),
// componentID(componentID),
// paramID(new QGCParamID(paramID)),
// opalID(opalID)
//
//{
//}
Parameter::Parameter(QString simulinkPath, QString simulinkName, uint8_t componentID,
QGCParamID paramID, unsigned short opalID)
: simulinkPath(new QString(simulinkPath)),
simulinkName(new QString(simulinkName)),
componentID(componentID),
paramID(new QGCParamID(paramID)),
opalID(opalID)
{
}
Parameter::Parameter(const Parameter &other)
: componentID(other.componentID),
opalID(other.opalID)
{
simulinkPath = new QString(*other.simulinkPath);
simulinkName = new QString(*other.simulinkName);
paramID = new QGCParamID(*other.paramID);
}
Parameter::~Parameter()
{
delete simulinkPath;
delete simulinkName;
delete paramID;
}
bool Parameter::operator ==(const Parameter& other) const
{
return
(*simulinkPath) == *(other.simulinkPath)
&& *simulinkName == *(other.simulinkName)
&& componentID == other.componentID
&& *paramID == *(other.paramID)
&& opalID == other.opalID;
}
float Parameter::getValue()
{
unsigned short allocatedParams = 1;
unsigned short numParams;
unsigned short numValues = 1;
unsigned short returnedNumValues;
double value;
int returnVal = OpalGetParameters(allocatedParams, &numParams, &opalID,
numValues, &returnedNumValues, &value);
if (returnVal != EOK) {
OpalRT::OpalErrorMsg::displayLastErrorMsg();
return FLT_MAX;
}
return static_cast<float>(value);
}
void Parameter::setValue(float val)
{
unsigned short allocatedParams = 1;
unsigned short numParams;
unsigned short numValues = 1;
unsigned short returnedNumValues;
double value = static_cast<double>(val);
int returnVal = OpalSetParameters(allocatedParams, &numParams, &opalID,
numValues, &returnedNumValues, &value);
if (returnVal != EOK) {
//qDebug() << __FILE__ << ":" << __LINE__ << ": Error numer: " << QString::number(returnVal);
OpalErrorMsg::displayLastErrorMsg();
}
}
Parameter::operator QString() const
{
return *simulinkPath + *simulinkName + " " + QString::number(componentID)
+ " " + *paramID + " " + QString::number(opalID);
}
/*=====================================================================
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 Parameter Object used to intefrace with an OpalRT Simulink Parameter
\see OpalLink
\see OpalRT::ParameterList
* @author Bryan Godbolt <godbolt@ualberta.ca>
*/
#ifndef PARAMETER_H
#define PARAMETER_H
#include <QString>
#include <QDebug>
#include "mavlink_types.h"
#include "QGCParamID.h"
#include "OpalApi.h"
#include "OpalRT.h"
#include <cfloat>
namespace OpalRT
{
class Parameter
{
public:
// Parameter(char *simulinkPath = "",
// char *simulinkName = "",
// uint8_t componentID = 0,
// QGCParamID paramID = QGCParamID(),
// unsigned short opalID = 0);
Parameter(QString simulinkPath = QString(),
QString simulinkName = QString(),
uint8_t componentID = 0,
QGCParamID paramID = QGCParamID(),
unsigned short opalID = 0);
Parameter(const Parameter& other);
~Parameter();
const QGCParamID& getParamID() const {
return *paramID;
}
void setOpalID(unsigned short opalID) {
this->opalID = opalID;
}
const QString& getSimulinkPath() const {
return *simulinkPath;
}
const QString& getSimulinkName() const {
return *simulinkName;
}
uint8_t getComponentID() const {
return componentID;
}
float getValue();
void setValue(float value);
bool operator==(const Parameter& other) const;
operator QString() const;
protected:
QString *simulinkPath;
QString *simulinkName;
uint8_t componentID;
QGCParamID *paramID;
unsigned short opalID;
};
}
#endif // PARAMETER_H
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/>.
======================================================================*/
#ifndef PARAMETERLIST_H
#define PARAMETERLIST_H
#include <QMap>
#include <QVector>
#include <QIODevice>
#include <QFile>
#include <QDir>
#include <QApplication>
#include <QtXml>
#include <QStringList>
#include "mavlink_types.h"
#include "QGCParamID.h"
#include "Parameter.h"
#include "OpalRT.h"
namespace OpalRT
{
class ParameterList
{
public:
class const_iterator
{
friend class ParameterList;
public:
inline const_iterator() {}
const_iterator(const const_iterator& other);
const_iterator& operator+=(int i) {
index += i;
return *this;
}
bool operator<(const const_iterator& other) const {
return (this->paramList == other.paramList)
&&(this->index<other.index);
}
bool operator==(const const_iterator& other) const {
return (this->paramList == other.paramList)
&&(this->index==other.index);
}
bool operator!=(const const_iterator& other) const {
return !((*this) == other);
}
const Parameter& operator*() const {
return paramList[index];
}
const Parameter* operator->() const {
return &paramList[index];
}
const_iterator& operator++() {
++index;
return *this;
}
private:
const_iterator(QList<Parameter>);
QList<Parameter> paramList;
int index;
};
ParameterList();
~ParameterList();
/** Count the number of parameters in the list.
\return Total number of parameters
*/
int count();
/** Find p in the list and return its index.
\note In order to use this index to look up p, the component is also needed.
\return the index of p or -1 if p is not found
\example
\code
int compid = OpalRT::CONTROLLER_ID;
Parameter p("simulinkpath", "simulinkparamname", compid, QGCParamID("PID_GAIN"));
ParameterList pList;
if ((int index=pList.indexOf(p)) != -1)
qDebug() << "PID_GAIN is at index " << index;
\endcode
*/
int indexOf(const Parameter& p);
bool contains(int compid, QGCParamID paramid) const {
return (*params)[compid].contains(paramid);
}
/// Get a parameter from the list
const Parameter getParameter(int compid, QGCParamID paramid) const {
return (*params)[compid][paramid];
}
Parameter& getParameter(int compid, QGCParamID paramid) {
return (*params)[compid][paramid];
}
const Parameter getParameter(int compid, int index) const {
return *((*paramList)[compid][index]);
}
/** Convenient syntax for calling OpalRT::Parameter::getParameter() */
Parameter& operator()(int compid, QGCParamID paramid) {
return getParameter(compid, paramid);
}
Parameter& operator()(uint8_t compid, QGCParamID paramid) {
return getParameter(static_cast<int>(compid), paramid);
}
const_iterator begin() const;
const_iterator end() const;
protected:
/** Store the parameters mapped by componentid, and paramid.
\code
// Look up a parameter
int compid = 1;
QGCParamID paramid("PID_GAIN");
Parameter p = params[compid][paramid];
\endcode
*/
QMap<int, QMap<QGCParamID, Parameter> > *params;
/**
Store pointers to the parameters to allow fast lookup by index.
This variable may be changed to const pointers to ensure all changes
are made through the map container.
*/
QList<QList<Parameter*> > *paramList;
/**
List of parameters which are necessary to control the servos.
*/
QStringList *reqdServoParams;
/**
Get the list of available parameters from Opal-RT.
\param[out] opalParams Map of parameter paths/names to ids which are valid in Opal-RT
*/
void getParameterList(QMap<QString, unsigned short>* opalParams);
/**
Open a file for reading in the xml config data
*/
bool open(QString filename=QString());
/**
Attempt to read XML configuration data from device
\param[in] the device to read the xml data from
\return true if the configuration was read successfully, false otherwise
*/
bool read(QIODevice *device);
void parseBlock(const QDomElement &block);
};
}
#endif // PARAMETERLIST_H
/*=====================================================================
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 Implementation of class OpalRT::QGCParamID
* @author Bryan Godbolt <godbolt@ualberta.ca>
*/
#include "QGCParamID.h"
using namespace OpalRT;
QGCParamID::QGCParamID(const char paramid[]):data(paramid)
{
}
QGCParamID::QGCParamID(const QString s):data(s)
{
}
QGCParamID::QGCParamID(const QGCParamID &other):data(other.data)
{
}
//
//QDataStream& operator<<(QDataStream& stream, const QGCParamID& paramid)
//{
// return stream << paramid.data;
//}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 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 Stores the paramid used for mavlink
* @author Bryan Godbolt <godbolt@ualberta.ca>
*/
#ifndef QGCPARAMID_H
#define QGCPARAMID_H
#include <QString>
#include "mavlink_types.h"
//namespace OpalRT
//{
// class QGCParamID;
//}
//
//QDataStream& operator<<(QDataStream&, const OpalRT::QGCParamID&);
namespace OpalRT
{
/** Stores a param_id for the mavlink parameter packets. This class adds the convenience
of storing the id as a string (e.g., easy comparison).
\todo Fix: warning: deprecated conversion from string constant to 'char*'
*/
class QGCParamID
{
// friend QDataStream& operator<<(QDataStream& stream, const QGCParamID& paramid);
public:
QGCParamID(const char[]);
QGCParamID(const QString);
QGCParamID() {}
QGCParamID(const QGCParamID& other);
bool operator<(const QGCParamID& other) const {
return data<other.data;
}
bool operator==(const QGCParamID& other) const {
return data == other.data;
}
operator QString() const {
return data;
}
const QString getParamString() const {
return static_cast<const QString>(data);
}
int8_t* toInt8_t() const {
return (int8_t*)data.toLatin1().data();
}
protected:
QString data;
};
}
#endif // QGCPARAMID_H
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