mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
OP-1723 Ground wizard, reversable motor support - Fixes default outputs levels issue (OP-1718)
This commit is contained in:
parent
f1f8e285e9
commit
c645738bc5
@ -54,6 +54,8 @@ OutputCalibrationPage::~OutputCalibrationPage()
|
||||
delete m_calibrationUtil;
|
||||
m_calibrationUtil = 0;
|
||||
}
|
||||
|
||||
OutputCalibrationUtil::stopOutputCalibration();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -70,24 +72,39 @@ void OutputCalibrationPage::setupActuatorMinMaxAndNeutral(int motorChannelStart,
|
||||
// servos since a value out of range can actually destroy the
|
||||
// vehicle if unlucky.
|
||||
// Motors are not that important. REMOVE propellers always!!
|
||||
OutputCalibrationUtil::startOutputCalibration();
|
||||
|
||||
for (int servoid = 0; servoid < 12; servoid++) {
|
||||
if (servoid >= motorChannelStart && servoid <= motorChannelEnd) {
|
||||
// Set to motor safe values
|
||||
m_actuatorSettings[servoid].channelMin = 1000;
|
||||
m_actuatorSettings[servoid].channelNeutral = 1000;
|
||||
m_actuatorSettings[servoid].channelMax = 1900;
|
||||
m_actuatorSettings[servoid].channelMin = 1000;
|
||||
m_actuatorSettings[servoid].channelNeutral = 1000;
|
||||
m_actuatorSettings[servoid].channelMax = 1900;
|
||||
m_actuatorSettings[servoid].isReversableMotor = false;
|
||||
// Car and Tank should use reversable Esc/motors
|
||||
if ((getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_CAR)
|
||||
|| (getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_DIFFERENTIAL)) {
|
||||
m_actuatorSettings[servoid].channelNeutral = 1500;
|
||||
m_actuatorSettings[servoid].isReversableMotor = true;
|
||||
// Set initial output value
|
||||
m_calibrationUtil->startChannelOutput(servoid, 1500);
|
||||
m_calibrationUtil->stopChannelOutput();
|
||||
}
|
||||
} else if (servoid < totalUsedChannels) {
|
||||
// Set to servo safe values
|
||||
m_actuatorSettings[servoid].channelMin = 1500;
|
||||
m_actuatorSettings[servoid].channelNeutral = 1500;
|
||||
m_actuatorSettings[servoid].channelMax = 1500;
|
||||
// Set initial servo output value
|
||||
m_calibrationUtil->startChannelOutput(servoid, 1500);
|
||||
m_calibrationUtil->stopChannelOutput();
|
||||
} else {
|
||||
// "Disable" these channels
|
||||
m_actuatorSettings[servoid].channelMin = 1000;
|
||||
m_actuatorSettings[servoid].channelNeutral = 1000;
|
||||
m_actuatorSettings[servoid].channelMax = 1000;
|
||||
}
|
||||
qDebug() << "**** " << servoid << " ***** " << m_actuatorSettings[servoid].channelMin << " " << m_actuatorSettings[servoid].channelNeutral << " " << m_actuatorSettings[servoid].channelMax;
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,6 +118,12 @@ void OutputCalibrationPage::setupVehicle()
|
||||
m_currentWizardIndex = 0;
|
||||
m_vehicleScene->clear();
|
||||
|
||||
if (m_calibrationUtil) {
|
||||
delete m_calibrationUtil;
|
||||
m_calibrationUtil = 0;
|
||||
}
|
||||
m_calibrationUtil = new OutputCalibrationUtil();
|
||||
|
||||
switch (getWizard()->getVehicleSubType()) {
|
||||
case SetupWizard::MULTI_ROTOR_TRI_Y:
|
||||
// Loads the SVG file resourse and sets the scene
|
||||
@ -120,7 +143,7 @@ void OutputCalibrationPage::setupVehicle()
|
||||
// The channel number to configure for each step.
|
||||
m_channelIndex << 0 << 0 << 1 << 2 << 3;
|
||||
|
||||
setupActuatorMinMaxAndNeutral(0, 2, 3);
|
||||
setupActuatorMinMaxAndNeutral(0, 2, 4);
|
||||
|
||||
getWizard()->setActuatorSettings(m_actuatorSettings);
|
||||
break;
|
||||
@ -213,7 +236,7 @@ void OutputCalibrationPage::setupVehicle()
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5;
|
||||
m_channelIndex << 0 << 2 << 0 << 5 << 3 << 1;
|
||||
|
||||
setupActuatorMinMaxAndNeutral(2, 2, 5);
|
||||
setupActuatorMinMaxAndNeutral(2, 2, 6); // should be 5 instead 6 but output 5 is not used
|
||||
|
||||
getWizard()->setActuatorSettings(m_actuatorSettings);
|
||||
break;
|
||||
@ -226,7 +249,7 @@ void OutputCalibrationPage::setupVehicle()
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 2;
|
||||
m_channelIndex << 0 << 1 << 0;
|
||||
|
||||
setupActuatorMinMaxAndNeutral(0, 1, 2);
|
||||
setupActuatorMinMaxAndNeutral(1, 1, 2);
|
||||
|
||||
getWizard()->setActuatorSettings(m_actuatorSettings);
|
||||
break;
|
||||
@ -248,7 +271,7 @@ void OutputCalibrationPage::setupVehicle()
|
||||
m_vehicleHighlightElementIndexes << 0 << 1 << 2;
|
||||
m_channelIndex << 0 << 1 << 0;
|
||||
|
||||
setupActuatorMinMaxAndNeutral(0, 1, 2);
|
||||
setupActuatorMinMaxAndNeutral(1, 1, 2);
|
||||
|
||||
getWizard()->setActuatorSettings(m_actuatorSettings);
|
||||
break;
|
||||
@ -257,12 +280,6 @@ void OutputCalibrationPage::setupVehicle()
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_calibrationUtil) {
|
||||
delete m_calibrationUtil;
|
||||
m_calibrationUtil = 0;
|
||||
}
|
||||
m_calibrationUtil = new OutputCalibrationUtil();
|
||||
|
||||
setupVehicleItems();
|
||||
}
|
||||
|
||||
@ -326,7 +343,15 @@ void OutputCalibrationPage::setWizardPage()
|
||||
if (currentChannel >= 0) {
|
||||
if (currentPageIndex == 1) {
|
||||
ui->motorNeutralSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral);
|
||||
ui->motorPWMValue->setText(QString("Output value : <b>%1</b> µs").arg(m_actuatorSettings[currentChannel].channelNeutral));
|
||||
// Reversable motor found
|
||||
if (m_actuatorSettings[currentChannel].isReversableMotor) {
|
||||
ui->motorNeutralSlider->setMinimum(m_actuatorSettings[currentChannel].channelMin);
|
||||
ui->motorNeutralSlider->setMaximum(m_actuatorSettings[currentChannel].channelMax);
|
||||
ui->motorInfo->setText(tr("<html><head/><body><p><span style=\" font-size:10pt;\">To find </span><span style=\" font-size:10pt; font-weight:600;\">the neutral rate for this reversable motor</span><span style=\" font-size:10pt;\">, press the Start button below and slide the slider to the right or left until you find the value where the motor don't start. <br/><br/>When done press button again to stop.</span></p></body></html>"));
|
||||
}
|
||||
} else if (currentPageIndex == 2) {
|
||||
ui->servoPWMValue->setText(QString("Output value : <b>%1</b> µs").arg(m_actuatorSettings[currentChannel].channelNeutral));
|
||||
if (m_actuatorSettings[currentChannel].channelMax < m_actuatorSettings[currentChannel].channelMin &&
|
||||
!ui->reverseCheckbox->isChecked()) {
|
||||
ui->reverseCheckbox->setChecked(true);
|
||||
@ -416,6 +441,11 @@ void OutputCalibrationPage::on_motorNeutralButton_toggled(bool checked)
|
||||
ui->motorNeutralSlider->setEnabled(checked);
|
||||
quint16 channel = getCurrentChannel();
|
||||
quint16 safeValue = m_actuatorSettings[channel].channelMin;
|
||||
|
||||
if (m_actuatorSettings[channel].isReversableMotor) {
|
||||
safeValue = m_actuatorSettings[channel].channelNeutral;
|
||||
}
|
||||
|
||||
onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, safeValue, ui->motorNeutralSlider);
|
||||
}
|
||||
|
||||
@ -425,7 +455,6 @@ void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, quint16
|
||||
if (checkAlarms()) {
|
||||
enableButtons(false);
|
||||
enableServoSliders(true);
|
||||
OutputCalibrationUtil::startOutputCalibration();
|
||||
m_calibrationUtil->startChannelOutput(channel, safeValue);
|
||||
slider->setValue(value);
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
@ -433,8 +462,16 @@ void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, quint16
|
||||
button->setChecked(false);
|
||||
}
|
||||
} else {
|
||||
// Servos and ReversableMotors
|
||||
m_calibrationUtil->startChannelOutput(channel, m_actuatorSettings[channel].channelNeutral);
|
||||
|
||||
// Normal motor
|
||||
if ((button->objectName() == "motorNeutralButton") && !m_actuatorSettings[channel].isReversableMotor) {
|
||||
m_calibrationUtil->startChannelOutput(channel, m_actuatorSettings[channel].channelMin);
|
||||
}
|
||||
|
||||
m_calibrationUtil->stopChannelOutput();
|
||||
OutputCalibrationUtil::stopOutputCalibration();
|
||||
|
||||
enableServoSliders(false);
|
||||
enableButtons(true);
|
||||
}
|
||||
@ -492,6 +529,8 @@ void OutputCalibrationPage::debugLogChannelValues()
|
||||
void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
|
||||
{
|
||||
Q_UNUSED(value);
|
||||
ui->motorPWMValue->setText(QString("Output value : <b>%1</b> µs").arg(value));
|
||||
|
||||
if (ui->motorNeutralButton->isChecked()) {
|
||||
quint16 value = ui->motorNeutralSlider->value();
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
@ -515,6 +554,7 @@ void OutputCalibrationPage::on_servoCenterAngleSlider_valueChanged(int position)
|
||||
m_calibrationUtil->setChannelOutputValue(value);
|
||||
quint16 channel = getCurrentChannel();
|
||||
m_actuatorSettings[channel].channelNeutral = value;
|
||||
ui->servoPWMValue->setText(QString("Output value : <b>%1</b> µs").arg(value));
|
||||
|
||||
// Adjust min and max
|
||||
if (ui->reverseCheckbox->isChecked()) {
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
<width>776</width>
|
||||
<height>505</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -94,8 +94,10 @@ p, li { white-space: pre-wrap; }
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">In this step we will set the neutral rate for the motor highlighted in the illustration to the right. <br />Please pay attention to the details and in particular the motors position and its rotation direction. Ensure the motors are spinning in the correct direction as shown in the diagram. Swap any 2 motor wires to change the direction of a motor. </span></p>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">To find </span><span style=" font-size:10pt; font-weight:600;">the neutral rate for this motor</span><span style=" font-size:10pt;">, press the Start button below and slide the slider to the right until the motor just starts to spin stable. <br /><br />When done press button again to stop.</span></p></body></html></string>
|
||||
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">In this step we will set the neutral rate for the motor highlighted in the illustration to the right. <br />Please pay attention to the details and in particular the motors position and its rotation direction. Ensure the motors are spinning in the correct direction as shown in the diagram. Swap any 2 motor wires to change the direction of a motor. </span></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
@ -105,6 +107,29 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="motorInfo">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-size:10pt;">To find </span><span style=" font-size:10pt; font-weight:600;">the neutral rate for this motor</span><span style=" font-size:10pt;">, press the Start button below and slide the slider to the right until the motor just starts to spin stable. <br/><br/>When done press button again to stop.</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="motorPWMValue">
|
||||
<property name="text">
|
||||
<string>Output value: 1000µs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="motorNeutralSlider">
|
||||
<property name="enabled">
|
||||
@ -184,6 +209,13 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="servoPWMValue">
|
||||
<property name="text">
|
||||
<string>Output value: 1000µs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
|
@ -679,8 +679,10 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings ch
|
||||
}
|
||||
}
|
||||
|
||||
// Default maxThrottle
|
||||
// Default maxThrottle and minThrottle
|
||||
float maxThrottle = 0.9;
|
||||
float minThrottle = 0;
|
||||
|
||||
|
||||
// Save mixer values for sliders
|
||||
switch (m_configSource->getVehicleType()) {
|
||||
@ -737,17 +739,26 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings ch
|
||||
{
|
||||
switch (m_configSource->getVehicleSubType()) {
|
||||
case VehicleConfigurationSource::GROUNDVEHICLE_MOTORCYCLE:
|
||||
case VehicleConfigurationSource::GROUNDVEHICLE_CAR:
|
||||
mSettings->setMixerValueRoll(100);
|
||||
mSettings->setMixerValuePitch(100);
|
||||
mSettings->setMixerValueYaw(100);
|
||||
maxThrottle = 1;
|
||||
break;
|
||||
case VehicleConfigurationSource::GROUNDVEHICLE_CAR:
|
||||
mSettings->setMixerValueRoll(100);
|
||||
mSettings->setMixerValuePitch(100);
|
||||
mSettings->setMixerValueYaw(100);
|
||||
// Set curve2 range from -0.926 to 1 : take in account 4% offset in Throttle input
|
||||
// 0.5 / 0.54 = 0.926
|
||||
maxThrottle = 1;
|
||||
minThrottle = -0.926;
|
||||
break;
|
||||
case VehicleConfigurationSource::GROUNDVEHICLE_DIFFERENTIAL:
|
||||
mSettings->setMixerValueRoll(100);
|
||||
mSettings->setMixerValuePitch(100);
|
||||
mSettings->setMixerValueYaw(100);
|
||||
maxThrottle = 0.8;
|
||||
minThrottle = -0.8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -765,7 +776,7 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings ch
|
||||
UAVObjectField *field = mSettings->getField(throttlePattern.arg(i));
|
||||
Q_ASSERT(field);
|
||||
for (quint32 i = 0; i < field->getNumElements(); i++) {
|
||||
field->setValue(i * (maxThrottle / (field->getNumElements() - 1)), i);
|
||||
field->setValue(minThrottle + (i * ((maxThrottle - minThrottle) / (field->getNumElements() - 1))), i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2033,7 +2044,7 @@ void VehicleConfigurationHelper::setupCar()
|
||||
channels[0].yaw = 100;
|
||||
|
||||
// Motor (Chan 2)
|
||||
channels[1].type = MIXER_TYPE_MOTOR;
|
||||
channels[1].type = MIXER_TYPE_REVERSABLEMOTOR;
|
||||
channels[1].throttle1 = 0;
|
||||
channels[1].throttle2 = 100;
|
||||
channels[1].roll = 0;
|
||||
@ -2058,7 +2069,7 @@ void VehicleConfigurationHelper::setupTank()
|
||||
GUIConfigDataUnion guiSettings = getGUIConfigData();
|
||||
|
||||
// Left Motor (Chan 1)
|
||||
channels[0].type = MIXER_TYPE_SERVO;
|
||||
channels[0].type = MIXER_TYPE_REVERSABLEMOTOR;
|
||||
channels[0].throttle1 = 0;
|
||||
channels[0].throttle2 = 100;
|
||||
channels[0].roll = 0;
|
||||
@ -2066,7 +2077,7 @@ void VehicleConfigurationHelper::setupTank()
|
||||
channels[0].yaw = 100;
|
||||
|
||||
// Right Motor (Chan 2)
|
||||
channels[1].type = MIXER_TYPE_MOTOR;
|
||||
channels[1].type = MIXER_TYPE_REVERSABLEMOTOR;
|
||||
channels[1].throttle1 = 0;
|
||||
channels[1].throttle2 = 100;
|
||||
channels[1].roll = 0;
|
||||
@ -2098,10 +2109,10 @@ void VehicleConfigurationHelper::setupMotorcycle()
|
||||
channels[0].pitch = 0;
|
||||
channels[0].yaw = 100;
|
||||
|
||||
// Motor (Chan 2)
|
||||
// Motor (Chan 2) : Curve1, no reverse
|
||||
channels[1].type = MIXER_TYPE_MOTOR;
|
||||
channels[1].throttle1 = 0;
|
||||
channels[1].throttle2 = 100;
|
||||
channels[1].throttle1 = 100;
|
||||
channels[1].throttle2 = 0;
|
||||
channels[1].roll = 0;
|
||||
channels[1].pitch = 0;
|
||||
channels[1].yaw = 0;
|
||||
|
@ -46,9 +46,10 @@ struct actuatorChannelSettings {
|
||||
quint16 channelMin;
|
||||
quint16 channelNeutral;
|
||||
quint16 channelMax;
|
||||
bool isReversableMotor;
|
||||
|
||||
// Default values
|
||||
actuatorChannelSettings() : channelMin(1000), channelNeutral(1000), channelMax(1900) {}
|
||||
actuatorChannelSettings() : channelMin(1000), channelNeutral(1000), channelMax(1900), isReversableMotor(false) {}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user