1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-38 Config gadget: you can now test your servo outputs by checking the "Test Outputs" checkbox and moving the sliders. You will need up to date

flight firmware for this to work.


git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1335 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-08-19 11:48:16 +00:00 committed by edouard
parent 3c4def13cc
commit dc2928ae99
5 changed files with 205 additions and 139 deletions

View File

@ -38,8 +38,7 @@
</rect>
</property>
<property name="toolTip">
<string>Be sure to set the Neutral position on all sliders before sending!
Applies and Saves all settings to SD</string>
<string>Applies and Saves all settings to SD</string>
</property>
<property name="text">
<string>Save to SD</string>
@ -55,8 +54,7 @@ Applies and Saves all settings to SD</string>
</rect>
</property>
<property name="toolTip">
<string>Send to OpenPilot but don't write in SD.
Be sure to set the Neutral position on all sliders before sending!</string>
<string>Send to OpenPilot but don't write in SD.</string>
</property>
<property name="text">
<string>Save to RAM</string>
@ -82,14 +80,14 @@ Be sure to set the Neutral position on all sliders before sending!</string>
<property name="geometry">
<rect>
<x>110</x>
<y>20</y>
<y>10</y>
<width>121</width>
<height>21</height>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<pointsize>10</pointsize>
</font>
</property>
<property name="toolTip">

View File

@ -139,6 +139,7 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
connect(m_config->ch6OutMax, SIGNAL(editingFinished()), this, SLOT(setch6OutRange()));
connect(m_config->ch7OutMax, SIGNAL(editingFinished()), this, SLOT(setch7OutRange()));
connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool)));
requestRCInputUpdate();
requestRCOutputUpdate();
@ -161,6 +162,8 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
connect(m_telemetry->saveTelemetryToRAM, SIGNAL(clicked()), this, SLOT(sendTelemetryUpdate()));
connect(m_telemetry->getTelemetryCurrent, SIGNAL(clicked()), this, SLOT(requestTelemetryUpdate()));
// Now connect the channel out sliders to our signal to send updates in test mode
connect(m_config->ch0OutSlider, SIGNAL(valueChanged(int)), this, SLOT(sendChannelTest(int)));
firstUpdate = true;
@ -177,6 +180,59 @@ void ConfigGadgetWidget::resizeEvent(QResizeEvent *event)
QWidget::resizeEvent(event);
}
/**
Sends the channel value to the UAV to move the servo.
Returns immediately if we are not in testing mode
*/
void ConfigGadgetWidget::sendChannelTest(int value)
{
if (!m_config->channelOutTest->isChecked())
return;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorCommand")));
QObject *ob = QObject::sender();
QStringList channelsList;
channelsList << "ch0OutSlider" << "ch1OutSlider" << "ch2OutSlider" << "ch3OutSlider" << "ch4OutSlider"
<< "ch5OutSlider" << "ch6OutSlider" << "ch7OutSlider";
int idx = channelsList.indexOf(QRegExp(ob->objectName()));
UAVObjectField * channel = obj->getField("Channel");
channel->setValue(value,idx);
obj->updated();
}
/**
Toggles the channel testing mode by making the GCS take over
the ActuatorCommand objects
*/
void ConfigGadgetWidget::runChannelTests(bool state)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorCommand")));
UAVObject::Metadata mdata = obj->getMetadata();
if (state)
{
accInitialData = mdata;
mdata.flightAccess = UAVObject::ACCESS_READONLY;
mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
mdata.gcsTelemetryAcked = false;
mdata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
mdata.gcsTelemetryUpdatePeriod = 100;
}
else
{
mdata = accInitialData; // Restore metadata
}
obj->setMetadata(mdata);
}
/**************************
* Aircraft settings
**************************/
@ -483,57 +539,119 @@ void ConfigGadgetWidget::saveRCOutputObject()
Q_ASSERT(obj);
updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj);
/*
UAVDataObject* obj2 = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("SystemSettings")));
Q_ASSERT(obj2);
updateObjectPersistance(ObjectPersistence::OPERATION_SAVE, obj2);
*/
}
/**
Sets the minimum/maximem value of the channel 0 output slider.
Have to do it here because setMinimum is not a slot
Sets the minimum/maximem value of the channel 0 to seven output sliders.
Have to do it here because setMinimum is not a slot.
One added trik: if the slider is at either its max or its min when the value
is changed, then keep it on the max/min.
*/
void ConfigGadgetWidget::setch0OutRange()
{
m_config->ch0OutSlider->setRange(m_config->ch0OutMin->value(),
QSlider *slider = m_config->ch0OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch0OutMin->value(),
m_config->ch0OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
void ConfigGadgetWidget::setch1OutRange()
{
m_config->ch1OutSlider->setRange(m_config->ch1OutMin->value(),
QSlider *slider = m_config->ch1OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch1OutMin->value(),
m_config->ch1OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
void ConfigGadgetWidget::setch2OutRange()
{
m_config->ch2OutSlider->setRange(m_config->ch2OutMin->value(),
QSlider *slider = m_config->ch2OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch2OutMin->value(),
m_config->ch2OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
void ConfigGadgetWidget::setch3OutRange()
{
m_config->ch3OutSlider->setRange(m_config->ch3OutMin->value(),
QSlider *slider = m_config->ch3OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch3OutMin->value(),
m_config->ch3OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
void ConfigGadgetWidget::setch4OutRange()
{
m_config->ch4OutSlider->setRange(m_config->ch4OutMin->value(),
QSlider *slider = m_config->ch4OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch4OutMin->value(),
m_config->ch4OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
void ConfigGadgetWidget::setch5OutRange()
{
m_config->ch5OutSlider->setRange(m_config->ch5OutMin->value(),
QSlider *slider = m_config->ch5OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch5OutMin->value(),
m_config->ch5OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
void ConfigGadgetWidget::setch6OutRange()
{
m_config->ch6OutSlider->setRange(m_config->ch6OutMin->value(),
QSlider *slider = m_config->ch6OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch6OutMin->value(),
m_config->ch6OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
void ConfigGadgetWidget::setch7OutRange()
{
m_config->ch7OutSlider->setRange(m_config->ch7OutMin->value(),
QSlider *slider = m_config->ch7OutSlider;
int oldMini = slider->minimum();
int oldMaxi = slider->maximum();
slider->setRange(m_config->ch7OutMin->value(),
m_config->ch7OutMax->value());
if (slider->value()==oldMini)
slider->setValue(slider->minimum());
if (slider->value()==oldMaxi)
slider->setValue(slider->maximum());
}
@ -851,6 +969,15 @@ void ConfigGadgetWidget::updateChannels(UAVObject* controlCommand)
m_config->RCInputConnected->setText("RC Receiver Not Connected");
}
if (m_config->doRCInputCalibration->isChecked()) {
if (firstUpdate) {
// Increase the data rate from the board so that the sliders
// move faster
UAVObject::Metadata mdata = controlCommand->getMetadata();
mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
mccDataRate = mdata.flightTelemetryUpdatePeriod;
mdata.flightTelemetryUpdatePeriod = 150;
controlCommand->setMetadata(mdata);
}
fieldName = QString("Channel");
field = controlCommand->getField(fieldName);
// Hey: if you find a nicer way of doing this, be my guest!
@ -888,6 +1015,13 @@ void ConfigGadgetWidget::updateChannels(UAVObject* controlCommand)
&*m_config->ch7Rev,field->getValue(7).toInt());
firstUpdate = false;
} else {
if (!firstUpdate) {
// Restore original data rate from the board:
UAVObject::Metadata mdata = controlCommand->getMetadata();
mdata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
mdata.flightTelemetryUpdatePeriod = mccDataRate;
controlCommand->setMetadata(mdata);
}
firstUpdate = true;
}
}

View File

@ -59,6 +59,8 @@ private:
void updateObjectPersistance(ObjectPersistence::OperationOptions op, UAVObject *obj);
void assignChannel(UAVDataObject *obj, UAVObjectField *field, QString str);
void assignOutputChannel(UAVDataObject *obj, UAVObjectField *field, QString str);
int mccDataRate;
UAVObject::Metadata accInitialData;
bool firstUpdate;
@ -76,6 +78,8 @@ private:
void requestTelemetryUpdate();
void sendTelemetryUpdate();
void saveTelemetryUpdate();
void runChannelTests(bool state);
void sendChannelTest(int value);
void setch0OutRange();
void setch1OutRange();

View File

@ -18,12 +18,12 @@
<rect>
<x>10</x>
<y>10</y>
<width>641</width>
<width>601</width>
<height>381</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -250,7 +250,7 @@ p, li { white-space: pre-wrap; }
<widget class="QPushButton" name="getRCInputCurrent">
<property name="geometry">
<rect>
<x>310</x>
<x>270</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -413,7 +413,7 @@ p, li { white-space: pre-wrap; }
<widget class="QPushButton" name="saveRCInputToSD">
<property name="geometry">
<rect>
<x>530</x>
<x>490</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -487,7 +487,7 @@ Applies and Saves all settings to SD</string>
<widget class="QPushButton" name="saveRCInputToRAM">
<property name="geometry">
<rect>
<x>420</x>
<x>380</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -1124,7 +1124,7 @@ Uncheck/Check to restart calibration.</string>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<y>10</y>
<width>221</width>
<height>17</height>
</rect>
@ -1247,6 +1247,13 @@ Uncheck/Check to restart calibration.</string>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Select the kind of actuator (servo) connected to this output channel.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QSpinBox" name="ch0OutMin">
<property name="enabled">
@ -1265,6 +1272,13 @@ Uncheck/Check to restart calibration.</string>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Minimum PWM value, beware of not overdriving your servo.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
@ -1286,24 +1300,34 @@ Uncheck/Check to restart calibration.</string>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Maximum PWM value, beware of not overdriving your servo.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
<widget class="QCheckBox" name="ch0OutTest">
<widget class="QCheckBox" name="channelOutTest">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>580</x>
<y>70</y>
<width>61</width>
<x>10</x>
<y>40</y>
<width>151</width>
<height>22</height>
</rect>
</property>
<property name="toolTip">
<string>If checked, moving the sliders below with also move the servos directly. Take extra care if the output is connected to an motor controller!</string>
</property>
<property name="text">
<string>Test</string>
<string>Test outputs</string>
</property>
</widget>
<widget class="QLabel" name="actuator6Label">
@ -1411,22 +1435,6 @@ Uncheck/Check to restart calibration.</string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="ch1OutTest">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>580</x>
<y>100</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
<widget class="QComboBox" name="ch2Output">
<property name="enabled">
<bool>true</bool>
@ -1506,22 +1514,6 @@ Uncheck/Check to restart calibration.</string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="ch2OutTest">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>580</x>
<y>130</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
<widget class="QComboBox" name="ch3Output">
<property name="enabled">
<bool>true</bool>
@ -1601,22 +1593,6 @@ Uncheck/Check to restart calibration.</string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="ch3OutTest">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>580</x>
<y>160</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
<widget class="QComboBox" name="ch4Output">
<property name="geometry">
<rect>
@ -1684,19 +1660,6 @@ Uncheck/Check to restart calibration.</string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="ch4OutTest">
<property name="geometry">
<rect>
<x>580</x>
<y>190</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
<widget class="QComboBox" name="ch5Output">
<property name="geometry">
<rect>
@ -1764,19 +1727,6 @@ Uncheck/Check to restart calibration.</string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="ch5OutTest">
<property name="geometry">
<rect>
<x>580</x>
<y>220</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
<widget class="QComboBox" name="ch6Output">
<property name="geometry">
<rect>
@ -1844,19 +1794,6 @@ Uncheck/Check to restart calibration.</string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="ch6OutTest">
<property name="geometry">
<rect>
<x>580</x>
<y>250</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
<widget class="QComboBox" name="ch7Output">
<property name="geometry">
<rect>
@ -1924,23 +1861,10 @@ Uncheck/Check to restart calibration.</string>
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QCheckBox" name="ch7OutTest">
<property name="geometry">
<rect>
<x>580</x>
<y>280</y>
<width>61</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Test</string>
</property>
</widget>
<widget class="QPushButton" name="saveRCOutputToSD">
<property name="geometry">
<rect>
<x>530</x>
<x>480</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -1957,7 +1881,7 @@ Applies and Saves all settings to SD</string>
<widget class="QPushButton" name="getRCOutputCurrent">
<property name="geometry">
<rect>
<x>310</x>
<x>260</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -1973,7 +1897,7 @@ Applies and Saves all settings to SD</string>
<widget class="QPushButton" name="saveRCOutputToRAM">
<property name="geometry">
<rect>
<x>420</x>
<x>370</x>
<y>310</y>
<width>93</width>
<height>27</height>
@ -2077,6 +2001,9 @@ Be sure to set the Neutral position on all sliders before sending!</string>
<height>17</height>
</rect>
</property>
<property name="toolTip">
<string>Current value of slider.</string>
</property>
<property name="text">
<string>0000</string>
</property>

View File

@ -69,6 +69,9 @@ p, li { white-space: pre-wrap; }
<height>31</height>
</rect>
</property>
<property name="toolTip">
<string>Select the speed here.</string>
</property>
</widget>
<widget class="QPushButton" name="saveTelemetryToRAM">
<property name="geometry">
@ -81,7 +84,7 @@ p, li { white-space: pre-wrap; }
</property>
<property name="toolTip">
<string>Send to OpenPilot but don't write in SD.
Be sure to set the Neutral position on all sliders before sending!</string>
Beware of not locking yourself out!</string>
</property>
<property name="text">
<string>Save to RAM</string>
@ -113,8 +116,8 @@ Be sure to set the Neutral position on all sliders before sending!</string>
</rect>
</property>
<property name="toolTip">
<string>Be sure to set the Neutral position on all sliders before sending!
Applies and Saves all settings to SD</string>
<string>Applies and Saves all settings to SD.
Beware of not locking yourself out!</string>
</property>
<property name="text">
<string>Save to SD</string>