mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
Merge branch 'rel-14.10' of ssh://git.openpilot.org/OpenPilot into rel-14.10
This commit is contained in:
commit
247f08239c
@ -36,7 +36,7 @@ bool OutputCalibrationUtil::c_prepared = false;
|
|||||||
ActuatorCommand::Metadata OutputCalibrationUtil::c_savedActuatorCommandMetaData;
|
ActuatorCommand::Metadata OutputCalibrationUtil::c_savedActuatorCommandMetaData;
|
||||||
|
|
||||||
OutputCalibrationUtil::OutputCalibrationUtil(QObject *parent) :
|
OutputCalibrationUtil::OutputCalibrationUtil(QObject *parent) :
|
||||||
QObject(parent), m_outputChannel(-1), m_safeValue(1000)
|
QObject(parent), m_safeValue(1000)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
OutputCalibrationUtil::~OutputCalibrationUtil()
|
OutputCalibrationUtil::~OutputCalibrationUtil()
|
||||||
@ -93,15 +93,17 @@ void OutputCalibrationUtil::stopOutputCalibration()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputCalibrationUtil::startChannelOutput(quint16 channel, quint16 safeValue)
|
void OutputCalibrationUtil::startChannelOutput(quint16 channel, quint16 safeValue) {
|
||||||
|
QList<quint16> channels;
|
||||||
|
channels.append(channel);
|
||||||
|
startChannelOutput(channels, safeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputCalibrationUtil::startChannelOutput(QList<quint16> channels, quint16 safeValue)
|
||||||
{
|
{
|
||||||
if (c_prepared) {
|
if (c_prepared) {
|
||||||
if (m_outputChannel < 0 && channel < ActuatorCommand::CHANNEL_NUMELEM) {
|
m_outputChannels = channels;
|
||||||
// Start output...
|
m_safeValue = safeValue;
|
||||||
m_outputChannel = channel;
|
|
||||||
m_safeValue = safeValue;
|
|
||||||
qDebug() << "Output for channel " << m_outputChannel + 1 << " started.";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "OutputCalibrationUtil not started.";
|
qDebug() << "OutputCalibrationUtil not started.";
|
||||||
}
|
}
|
||||||
@ -110,15 +112,9 @@ void OutputCalibrationUtil::startChannelOutput(quint16 channel, quint16 safeValu
|
|||||||
void OutputCalibrationUtil::stopChannelOutput()
|
void OutputCalibrationUtil::stopChannelOutput()
|
||||||
{
|
{
|
||||||
if (c_prepared) {
|
if (c_prepared) {
|
||||||
if (m_outputChannel >= 0) {
|
setChannelOutputValue(m_safeValue);
|
||||||
qDebug() << "Stopping output for channel " << m_outputChannel + 1 << "...";
|
m_outputChannels.clear();
|
||||||
// Stop output...
|
qDebug() << "OutputCalibrationUtil output stopped.";
|
||||||
setChannelOutputValue(m_safeValue);
|
|
||||||
qDebug() << "Settings output for channel " << m_outputChannel + 1 << " to " << m_safeValue;
|
|
||||||
qDebug() << "Output for channel " << m_outputChannel + 1 << " stopped.";
|
|
||||||
|
|
||||||
m_outputChannel = -1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "OutputCalibrationUtil not started.";
|
qDebug() << "OutputCalibrationUtil not started.";
|
||||||
}
|
}
|
||||||
@ -127,15 +123,20 @@ void OutputCalibrationUtil::stopChannelOutput()
|
|||||||
void OutputCalibrationUtil::setChannelOutputValue(quint16 value)
|
void OutputCalibrationUtil::setChannelOutputValue(quint16 value)
|
||||||
{
|
{
|
||||||
if (c_prepared) {
|
if (c_prepared) {
|
||||||
if (m_outputChannel >= 0) {
|
ActuatorCommand *actuatorCommand = getActuatorCommandObject();
|
||||||
|
ActuatorCommand::DataFields data = actuatorCommand->getData();
|
||||||
|
foreach (quint32 channel, m_outputChannels) {
|
||||||
// Set output value
|
// Set output value
|
||||||
qDebug() << "Setting output value for channel " << m_outputChannel << " to " << value << ".";
|
if (channel <= ActuatorCommand::CHANNEL_NUMELEM){
|
||||||
ActuatorCommand *actuatorCommand = getActuatorCommandObject();
|
qDebug() << "OutputCalibrationUtil setting output value for channel " << channel << " to " << value << ".";
|
||||||
ActuatorCommand::DataFields data = actuatorCommand->getData();
|
data.Channel[channel] = value;
|
||||||
data.Channel[m_outputChannel] = value;
|
} else {
|
||||||
actuatorCommand->setData(data);
|
qDebug() << "OutputCalibrationUtil could not set output value for channel " << channel
|
||||||
} else {
|
<< " to " << value << "." << "Channel out of bounds" << channel << ".";
|
||||||
qDebug() << "OutputCalibrationUtil not started.";
|
}
|
||||||
}
|
}
|
||||||
|
actuatorCommand->setData(data);
|
||||||
|
} else {
|
||||||
|
qDebug() << "OutputCalibrationUtil not started.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,14 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void startChannelOutput(quint16 channel, quint16 safeValue);
|
void startChannelOutput(quint16 channel, quint16 safeValue);
|
||||||
|
void startChannelOutput(QList<quint16> channels, quint16 safeValue);
|
||||||
void stopChannelOutput();
|
void stopChannelOutput();
|
||||||
void setChannelOutputValue(quint16 value);
|
void setChannelOutputValue(quint16 value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool c_prepared;
|
static bool c_prepared;
|
||||||
static ActuatorCommand::Metadata c_savedActuatorCommandMetaData;
|
static ActuatorCommand::Metadata c_savedActuatorCommandMetaData;
|
||||||
qint16 m_outputChannel;
|
QList<quint16> m_outputChannels;
|
||||||
quint16 m_safeValue;
|
quint16 m_safeValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,17 +102,19 @@ void EscCalibrationPage::startButtonClicked()
|
|||||||
MixerSettings *mSettings = MixerSettings::GetInstance(uavoManager);
|
MixerSettings *mSettings = MixerSettings::GetInstance(uavoManager);
|
||||||
Q_ASSERT(mSettings);
|
Q_ASSERT(mSettings);
|
||||||
QString mixerTypePattern = "Mixer%1Type";
|
QString mixerTypePattern = "Mixer%1Type";
|
||||||
|
|
||||||
OutputCalibrationUtil::startOutputCalibration();
|
OutputCalibrationUtil::startOutputCalibration();
|
||||||
for (quint32 i = 0; i < ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
|
for (quint32 i = 0; i < ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
|
||||||
UAVObjectField *field = mSettings->getField(mixerTypePattern.arg(i + 1));
|
UAVObjectField *field = mSettings->getField(mixerTypePattern.arg(i + 1));
|
||||||
Q_ASSERT(field);
|
Q_ASSERT(field);
|
||||||
if (field->getValue().toString() == field->getOptions().at(VehicleConfigurationHelper::MIXER_TYPE_MOTOR)) {
|
if (field->getValue().toString() == field->getOptions().at(VehicleConfigurationHelper::MIXER_TYPE_MOTOR)) {
|
||||||
OutputCalibrationUtil *output = new OutputCalibrationUtil();
|
m_outputChannels << i;
|
||||||
output->startChannelOutput(i, OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
|
||||||
output->setChannelOutputValue(HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
|
||||||
m_outputs << output;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_outputUtil.startChannelOutput(m_outputChannels, OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
||||||
|
QThread::msleep(100);
|
||||||
|
m_outputUtil.setChannelOutputValue(HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
||||||
|
|
||||||
ui->stopButton->setEnabled(true);
|
ui->stopButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,35 +126,29 @@ void EscCalibrationPage::stopButtonClicked()
|
|||||||
ui->outputHigh->setEnabled(false);
|
ui->outputHigh->setEnabled(false);
|
||||||
|
|
||||||
// Set to low pwm out
|
// Set to low pwm out
|
||||||
foreach(OutputCalibrationUtil * output, m_outputs) {
|
m_outputUtil.setChannelOutputValue(LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
||||||
output->setChannelOutputValue(LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
|
||||||
}
|
|
||||||
ui->outputLevel->setText(QString(tr("%1 µs")).arg(LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS));
|
ui->outputLevel->setText(QString(tr("%1 µs")).arg(LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS));
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
QThread::msleep(2000);
|
QThread::msleep(2000);
|
||||||
|
|
||||||
// Ramp down to off pwm out
|
// Ramp down to off pwm out
|
||||||
for (int i = LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS; i >= OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS; i -= 10) {
|
for (int i = LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS; i >= OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS; i -= 10) {
|
||||||
foreach(OutputCalibrationUtil * output, m_outputs) {
|
m_outputUtil.setChannelOutputValue(i);
|
||||||
output->setChannelOutputValue(i);
|
|
||||||
}
|
|
||||||
ui->outputLevel->setText(QString(tr("%1 µs")).arg(i));
|
ui->outputLevel->setText(QString(tr("%1 µs")).arg(i));
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
QThread::msleep(200);
|
QThread::msleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop output
|
// Stop output
|
||||||
foreach(OutputCalibrationUtil * output, m_outputs) {
|
m_outputUtil.stopChannelOutput();
|
||||||
output->stopChannelOutput();
|
|
||||||
delete output;
|
|
||||||
}
|
|
||||||
OutputCalibrationUtil::stopOutputCalibration();
|
OutputCalibrationUtil::stopOutputCalibration();
|
||||||
|
|
||||||
ui->outputLevel->setText(QString(tr("%1 µs")).arg(OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS));
|
ui->outputLevel->setText(QString(tr("%1 µs")).arg(OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS));
|
||||||
ui->outputHigh->setEnabled(false);
|
ui->outputHigh->setEnabled(false);
|
||||||
ui->outputLow->setEnabled(true);
|
ui->outputLow->setEnabled(true);
|
||||||
ui->nonconnectedLabel->setEnabled(true);
|
ui->nonconnectedLabel->setEnabled(true);
|
||||||
ui->connectedLabel->setEnabled(false);
|
ui->connectedLabel->setEnabled(false);
|
||||||
m_outputs.clear();
|
m_outputChannels.clear();
|
||||||
m_isCalibrating = false;
|
m_isCalibrating = false;
|
||||||
resetAllSecurityCheckboxes();
|
resetAllSecurityCheckboxes();
|
||||||
enableButtons(true);
|
enableButtons(true);
|
||||||
|
@ -58,8 +58,8 @@ private:
|
|||||||
static const int HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 1900;
|
static const int HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 1900;
|
||||||
Ui::EscCalibrationPage *ui;
|
Ui::EscCalibrationPage *ui;
|
||||||
bool m_isCalibrating;
|
bool m_isCalibrating;
|
||||||
|
OutputCalibrationUtil m_outputUtil;
|
||||||
QList<OutputCalibrationUtil *> m_outputs;
|
QList<quint16> m_outputChannels;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ESCCALIBRATIONPAGE_H
|
#endif // ESCCALIBRATIONPAGE_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user