Skip to content

Commit acfc32d

Browse files
Oleg Semyonovpeabody124
Oleg Semyonov
authored andcommitted
GCS vehicle config: do not reset existing camera/accessory mixers [OP-691]
Still no fix for helicopter config (some code refactoring is desired).
1 parent 7c5b49b commit acfc32d

File tree

7 files changed

+31
-56
lines changed

7 files changed

+31
-56
lines changed

HISTORY.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Short summary of changes. For a complete list see the git log.
22

3+
2012-11-11
4+
[OP-691] Camera/accessory mixers won't be reset when a vehicle configuration changed.
5+
Still no fix for helicopter configuration changes, though (some code refactoring is desired).
6+
37
2012-10-06
48
Receiver port can now be configured as PPM *and* PWM inputs.
59
Pin 1 is PPM, other pins are PWM inputs.

KNOWN_ISSUES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
+ XAircraft ESCs uses non-standard PPM range which may cause issues with Vehicle Wizard.
99
+ Spectrum Satellite Receivers setup in Radio Wizard may have wrong protocol set.
1010
+ Old Intel 965 have an OpenGL bug that turns the QML PFD black and while.
11+
+ [OP-691] Helicopter configuration change still resets camera/accessory mixers (some code refactoring is desired).

ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp

+6-25
Original file line numberDiff line numberDiff line change
@@ -281,23 +281,16 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
281281

282282
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
283283
Q_ASSERT(mixer);
284+
resetMixers(mixer);
284285

285286
// ... and compute the matrix:
286287
// In order to make code a bit nicer, we assume:
287288
// - Channel dropdowns start with 'None', then 0 to 7
288289

289290
// 1. Assign the servo/motor/none for each channel
290291

291-
int channel;
292-
//disable all
293-
for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++)
294-
{
295-
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
296-
resetMixerVector(mixer, channel);
297-
}
298-
299292
//motor
300-
channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
293+
int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
301294
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
302295
setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
303296

@@ -359,6 +352,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
359352

360353
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
361354
Q_ASSERT(mixer);
355+
resetMixers(mixer);
362356

363357
// Save the curve:
364358
// ... and compute the matrix:
@@ -367,17 +361,10 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
367361

368362
// 1. Assign the servo/motor/none for each channel
369363

370-
int channel;
371364
double value;
372-
//disable all
373-
for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++)
374-
{
375-
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
376-
resetMixerVector(mixer, channel);
377-
}
378365

379366
//motor
380-
channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
367+
int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
381368
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
382369
setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
383370

@@ -437,6 +424,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
437424

438425
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
439426
Q_ASSERT(mixer);
427+
resetMixers(mixer);
440428

441429
// Save the curve:
442430
// ... and compute the matrix:
@@ -445,17 +433,10 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
445433

446434
// 1. Assign the servo/motor/none for each channel
447435

448-
int channel;
449436
double value;
450-
//disable all
451-
for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++)
452-
{
453-
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
454-
resetMixerVector(mixer, channel);
455-
}
456437

457438
//motor
458-
channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
439+
int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
459440
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
460441
setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
461442

ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp

+6-24
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,10 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp
295295

296296
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
297297
Q_ASSERT(mixer);
298-
299-
int channel;
300-
//disable all
301-
for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) {
302-
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
303-
resetMixerVector(mixer, channel);
304-
}
298+
resetMixers(mixer);
305299

306300
//motor
307-
channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
301+
int channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
308302
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
309303
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
310304
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
@@ -352,16 +346,10 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
352346

353347
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
354348
Q_ASSERT(mixer);
355-
356-
int channel;
357-
//disable all
358-
for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) {
359-
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
360-
resetMixerVector(mixer, channel);
361-
}
349+
resetMixers(mixer);
362350

363351
//left motor
364-
channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
352+
int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
365353
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
366354
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
367355
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
@@ -407,15 +395,9 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
407395

408396
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
409397
Q_ASSERT(mixer);
398+
resetMixers(mixer);
410399

411-
int channel;
412-
//disable all
413-
for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) {
414-
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
415-
resetMixerVector(mixer, channel);
416-
}
417-
418-
channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1;
400+
int channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1;
419401
setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO);
420402
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
421403

ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -1032,13 +1032,7 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3])
10321032

10331033
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
10341034
Q_ASSERT(mixer);
1035-
1036-
//disable all
1037-
for (int channel=0; channel<(int)VehicleConfig::CHANNEL_NUMELEM; channel++)
1038-
{
1039-
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
1040-
resetMixerVector(mixer, channel);
1041-
}
1035+
resetMixers(mixer);
10421036

10431037
// and enable only the relevant channels:
10441038
double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100;

ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel)
181181
}
182182
}
183183

184+
// Disable all servo/motor mixers (but keep camera and accessory ones)
185+
void VehicleConfig::resetMixers(UAVDataObject *mixer)
186+
{
187+
for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) {
188+
QString type = getMixerType(mixer, channel);
189+
if ((type == "Disabled") || (type == "Motor") || (type == "Servo")) {
190+
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
191+
resetMixerVector(mixer, channel);
192+
}
193+
}
194+
}
195+
184196
double VehicleConfig::getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName)
185197
{
186198
Q_ASSERT(mixer);

ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class VehicleConfig: public ConfigTaskWidget
127127
double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName);
128128
void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value);
129129
void resetMixerVector(UAVDataObject* mixer, int channel);
130+
void resetMixers(UAVDataObject* mixer);
130131
QString getMixerType(UAVDataObject* mixer, int channel);
131132
void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType);
132133
double getMixerValue(UAVDataObject* mixer, QString elementName);

0 commit comments

Comments
 (0)