Commit bbb00c5b authored by Bryan Godbolt's avatar Bryan Godbolt

test setting aileron channel

parent fff49a5c
...@@ -23,7 +23,38 @@ ...@@ -23,7 +23,38 @@
<!-- Paremters for the Pilot Input/Raw RC block --> <!-- Paremters for the Pilot Input/Raw RC block -->
<Block name="ServoInputs"> <Block name="ServoInputs">
<!-- Settings for Aileron Servo -->
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/AileronInput/"
SimulinkParameterName="Setpoint0"
QGCParamID="AIL_RIGHT_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_LEFT_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/AileronInput/"
SimulinkParameterName="Setpoint1"
QGCParamID="ELE_CENTER_IN"
/>
<Parameter
SimulinkPath="avionics_src/sm_avionics/Pilot_Inputs/AileronInput/"
SimulinkParameterName="Setpoint2"
QGCParamID="ELE_UP_IN"
/>
</Block> </Block>
<!-- Parameters for the servo output block --> <!-- Parameters for the servo output block -->
......
...@@ -154,6 +154,13 @@ void OpalLink::writeBytes(const char *bytes, qint64 length) ...@@ -154,6 +154,13 @@ void OpalLink::writeBytes(const char *bytes, qint64 length)
qDebug() << "GYRO: " << radio.gyro[0] << " " << radio.gyro[1]; qDebug() << "GYRO: " << radio.gyro[0] << " " << radio.gyro[1];
qDebug() << "PITCH: " << radio.pitch[0] << radio.pitch[1] << radio.pitch[2] << radio.pitch[3] << radio.pitch[4]; qDebug() << "PITCH: " << radio.pitch[0] << radio.pitch[1] << radio.pitch[2] << radio.pitch[3] << radio.pitch[4];
qDebug() << "THROTTLE: " << radio.throttle[0] << radio.throttle[1] << radio.throttle[2] << radio.throttle[3] << radio.throttle[4]; qDebug() << "THROTTLE: " << radio.throttle[0] << radio.throttle[1] << radio.throttle[2] << radio.throttle[3] << radio.throttle[4];
if (params->contains(OpalRT::SERVO_INPUTS, "AIL_RIGHT_IN"))
params->getParameter(OpalRT::SERVO_INPUTS, "AIL_RIGHT_IN").setValue(radio.aileron[0]);
if (params->contains(OpalRT::SERVO_INPUTS, "AIL_CENTER_IN"))
params->getParameter(OpalRT::SERVO_INPUTS, "AIL_CENTER_IN").setValue(radio.aileron[1]);
if (params->contains(OpalRT::SERVO_INPUTS, "AIL_LEFT_IN"))
params->getParameter(OpalRT::SERVO_INPUTS, "AIL_LEFT_IN").setValue(radio.aileron[2]);
} }
break; break;
#endif #endif
......
...@@ -32,7 +32,8 @@ using namespace OpalRT; ...@@ -32,7 +32,8 @@ using namespace OpalRT;
ParameterList::ParameterList() ParameterList::ParameterList()
:params(new QMap<int, QMap<QGCParamID, Parameter> >), :params(new QMap<int, QMap<QGCParamID, Parameter> >),
paramList(new QList<QList<Parameter*> >()) paramList(new QList<QList<Parameter*> >()),
reqdServoParams(new QStringList())
{ {
QDir settingsDir = QDir(qApp->applicationDirPath()); QDir settingsDir = QDir(qApp->applicationDirPath());
...@@ -40,40 +41,17 @@ ParameterList::ParameterList() ...@@ -40,40 +41,17 @@ ParameterList::ParameterList()
settingsDir.cdUp(); settingsDir.cdUp();
settingsDir.cd("settings"); settingsDir.cd("settings");
// Enforce a list of parameters which are necessary for flight
reqdServoParams->append("AIL_RIGHT_IN");
reqdServoParams->append("AIL_CENTER_IN");
reqdServoParams->append("AIL_LEFT_IN");
reqdServoParams->append("ELE_DOWN_IN");
reqdServoParams->append("ELE_CENTER_IN");
reqdServoParams->append("ELE_UP_IN");
QString filename(settingsDir.path() + "/ParameterList.xml"); QString filename(settingsDir.path() + "/ParameterList.xml");
if ((QFile::exists(filename)) && open(filename)) if ((QFile::exists(filename)) && open(filename))
{ {
/* Populate the map with parameter names. There is no elegant way of doing this so all
parameter paths and names must be known at compile time and defined here.
Note: This function is written in a way that calls a lot of copy constructors and is
therefore not particularly efficient. However since it is only called once memory
and computation time are sacrificed for code clarity when adding and modifying
parameters.
When defining the path, the trailing slash is necessary
*/
// Parameter *p;
// /* Component: Navigation Filter */
// p = new Parameter("avionics_src/sm_ampro/NAV_FILT_INIT/",
// "Value",
// OpalRT::NAV_ID,
// QGCParamID("NAV_FILT_INIT"));
// (*params)[OpalRT::NAV_ID].insert(p->getParamID(), *p);
// delete p;
//
// p = new Parameter("avionics_src/sm_ampro/Gain/",
// "Gain",
// OpalRT::NAV_ID,
// QGCParamID("TEST_OUTP_GAIN"));
// (*params)[OpalRT::NAV_ID].insert(p->getParamID(), *p);
// delete p;
//
// /* Component: Log Facility */
// p = new Parameter("avionics_src/sm_ampro/LOG_FILE_ON/",
// "Value",
// OpalRT::LOG_ID,
// QGCParamID("LOG_FILE_ON"));
// (*params)[OpalRT::LOG_ID].insert(p->getParamID(), *p);
// delete p;
/* Get a list of the available parameters from opal-rt */ /* Get a list of the available parameters from opal-rt */
QMap<QString, unsigned short> *opalParams = new QMap<QString, unsigned short>; QMap<QString, unsigned short> *opalParams = new QMap<QString, unsigned short>;
...@@ -338,12 +316,26 @@ void ParameterList::parseBlock(const QDomElement &block) ...@@ -338,12 +316,26 @@ void ParameterList::parseBlock(const QDomElement &block)
static_cast<uint8_t>(id), static_cast<uint8_t>(id),
QGCParamID(e.attribute("QGCParamID"))); QGCParamID(e.attribute("QGCParamID")));
(*params)[id].insert(p->getParamID(), *p); (*params)[id].insert(p->getParamID(), *p);
if (reqdServoParams->contains((QString)p->getParamID()))
reqdServoParams->removeAt(reqdServoParams->indexOf((QString)p->getParamID()));
delete p; delete p;
}
}
else else
{ {
qDebug() << __FILE__ << ":" << __LINE__ << ": error in xml doc in block" << block.attribute("name"); qDebug() << __FILE__ << ":" << __LINE__ << ": error in xml doc in block" << block.attribute("name");
} }
} }
if (!reqdServoParams->empty())
{
qDebug() << __FILE__ << __LINE__ << "Missing the following required servo parameters";
foreach(QString s, *reqdServoParams)
{
qDebug() << s;
}
}
} }
...@@ -31,6 +31,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -31,6 +31,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDir> #include <QDir>
#include <QApplication> #include <QApplication>
#include <QtXml> #include <QtXml>
#include <QStringList>
#include "mavlink_types.h" #include "mavlink_types.h"
#include "QGCParamID.h" #include "QGCParamID.h"
...@@ -119,6 +120,10 @@ namespace OpalRT ...@@ -119,6 +120,10 @@ namespace OpalRT
are made through the map container. are made through the map container.
*/ */
QList<QList<Parameter*> > *paramList; 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. 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 \param[out] opalParams Map of parameter paths/names to ids which are valid in Opal-RT
......
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