1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-05 21:52:10 +01:00

OP-824 Feedforward fix, 0.0f, coding style, and var name changes.

This commit is contained in:
Cliff Geerdes 2013-02-07 18:27:59 -05:00
parent 8104ae25dd
commit 6d4e8e4657
2 changed files with 18 additions and 23 deletions

View File

@ -165,7 +165,7 @@ static void attitudeUpdated(UAVObjEvent* ev)
// we are guaranteed that the iteration order of i is roll pitch yaw // we are guaranteed that the iteration order of i is roll pitch yaw
// that guarnteees this won't be used uninited, but the compiler doesn't know that // that guarnteees this won't be used uninited, but the compiler doesn't know that
// so we init it or turn the warning/error off for each compiler // so we init it or turn the warning/error off for each compiler
float elevon_roll = 0.0; float elevon_roll = 0.0f;
// process axes // process axes
for (uint8_t i = 0; i < CAMERASTABSETTINGS_INPUT_NUMELEM; i++) { for (uint8_t i = 0; i < CAMERASTABSETTINGS_INPUT_NUMELEM; i++) {
@ -228,45 +228,39 @@ static void attitudeUpdated(UAVObjEvent* ev)
case CAMERASTABSETTINGS_INPUT_ROLL: case CAMERASTABSETTINGS_INPUT_ROLL:
// we are guaranteed that the iteration order of i is roll pitch yaw // we are guaranteed that the iteration order of i is roll pitch yaw
// for elevon mixing we simply grab the value for later use // for elevon mixing we simply grab the value for later use
if (cameraStab.GimbalType == CAMERASTABSETTINGS_GIMBALTYPE_ELEVONSSGYAWPITCHROLL) { if (cameraStab.GimbalType == CAMERASTABSETTINGS_GIMBALTYPE_ROLLPITCHMIXED)
elevon_roll = output; elevon_roll = output;
} else
else {
CameraDesiredRollOrServo1Set(&output); CameraDesiredRollOrServo1Set(&output);
}
break; break;
case CAMERASTABSETTINGS_INPUT_PITCH: case CAMERASTABSETTINGS_INPUT_PITCH:
// we are guaranteed that the iteration order of i is roll pitch yaw // we are guaranteed that the iteration order of i is roll pitch yaw
// for elevon mixing we use the value we previously grabbed and set both s1 and s2 // for elevon mixing we use the value we previously grabbed and set both s1 and s2
if (cameraStab.GimbalType == CAMERASTABSETTINGS_GIMBALTYPE_ELEVONSSGYAWPITCHROLL) { if (cameraStab.GimbalType == CAMERASTABSETTINGS_GIMBALTYPE_ROLLPITCHMIXED) {
float elevon_pitch; float elevon_pitch = output;
elevon_pitch = output;
// elevon reversing works like this: // elevon reversing works like this:
// first use the normal reversing facilities to get servo 1 roll working in the correct direction // first use the normal reversing facilities to get servo 1 roll working in the correct direction
// then use the normal reversing facilities to get servo 2 roll working in the correct direction // then use the normal reversing facilities to get servo 2 roll working in the correct direction
// then use these new reversing switches to reverse servo 1 and/or 2 pitch as needed // then use these new reversing switches to reverse servo 1 and/or 2 pitch as needed
// if servo 1 pitch is reversed // if servo 1 pitch is reversed
if (cameraStab.ElevonSSGServo1PitchReverse == CAMERASTABSETTINGS_ELEVONSSGSERVO1PITCHREVERSE_TRUE) { if (cameraStab.Servo1PitchReverse == CAMERASTABSETTINGS_SERVO1PITCHREVERSE_TRUE) {
// use (reversed pitch) + roll // use (reversed pitch) + roll
output = ((1.0 - elevon_pitch) + elevon_roll) / 2; output = ((1.0f - elevon_pitch) + elevon_roll) / 2.0f;
} } else {
else {
// use pitch + roll // use pitch + roll
output = (elevon_pitch + elevon_roll) / 2; output = (elevon_pitch + elevon_roll) / 2.0f;
} }
CameraDesiredRollOrServo1Set(&output); CameraDesiredRollOrServo1Set(&output);
// if servo 2 pitch is reversed // if servo 2 pitch is reversed
if (cameraStab.ElevonSSGServo2PitchReverse == CAMERASTABSETTINGS_ELEVONSSGSERVO2PITCHREVERSE_TRUE) { if (cameraStab.Servo2PitchReverse == CAMERASTABSETTINGS_SERVO2PITCHREVERSE_TRUE) {
// use (reversed pitch) - roll // use (reversed pitch) - roll
output = ((1.0 - elevon_pitch) - elevon_roll) / 2; output = ((1.0f - elevon_pitch) - elevon_roll) / 2.0f;
} } else {
else {
// use pitch - roll // use pitch - roll
output = (elevon_pitch - elevon_roll) / 2; output = (elevon_pitch - elevon_roll) / 2.0f;
} }
CameraDesiredPitchOrServo2Set(&output); CameraDesiredPitchOrServo2Set(&output);
} } else {
else {
CameraDesiredPitchOrServo2Set(&output); CameraDesiredPitchOrServo2Set(&output);
} }
break; break;
@ -294,6 +288,7 @@ void applyFeedForward(uint8_t index, float dT_millis, float *attitude, CameraSta
switch (cameraStab->GimbalType) { switch (cameraStab->GimbalType) {
case CAMERASTABSETTINGS_GIMBALTYPE_GENERIC: case CAMERASTABSETTINGS_GIMBALTYPE_GENERIC:
case CAMERASTABSETTINGS_GIMBALTYPE_ROLLPITCHMIXED:
// no correction // no correction
break; break;
case CAMERASTABSETTINGS_GIMBALTYPE_YAWROLLPITCH: case CAMERASTABSETTINGS_GIMBALTYPE_YAWROLLPITCH:

View File

@ -8,13 +8,13 @@
<field name="MaxAxisLockRate" units="deg/s" type="float" elements="1" defaultvalue="1"/> <field name="MaxAxisLockRate" units="deg/s" type="float" elements="1" defaultvalue="1"/>
<field name="OutputRange" units="deg" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="20"/> <field name="OutputRange" units="deg" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="20"/>
<field name="ResponseTime" units="ms" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="0"/> <field name="ResponseTime" units="ms" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="0"/>
<field name="GimbalType" units="" type="enum" elements="1" options="Generic,Yaw-Roll-Pitch,Yaw-Pitch-Roll,ElevonSSG(Yaw-Pitch-Roll)" defaultvalue="Generic"/> <field name="GimbalType" units="" type="enum" elements="1" options="Generic,Yaw-Roll-Pitch,Yaw-Pitch-Roll,Roll-Pitch-Mixed" defaultvalue="Generic"/>
<field name="FeedForward" units="" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="0"/> <field name="FeedForward" units="" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="0"/>
<field name="MaxAccel" units="units/sec" type="uint16" elements="1" defaultvalue="500"/> <field name="MaxAccel" units="units/sec" type="uint16" elements="1" defaultvalue="500"/>
<field name="AccelTime" units="ms" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="5"/> <field name="AccelTime" units="ms" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="5"/>
<field name="DecelTime" units="ms" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="5"/> <field name="DecelTime" units="ms" type="uint8" elementnames="Roll,Pitch,Yaw" defaultvalue="5"/>
<field name="ElevonSSGServo1PitchReverse" units="" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="FALSE"/> <field name="Servo1PitchReverse" units="" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="FALSE"/>
<field name="ElevonSSGServo2PitchReverse" units="" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="FALSE"/> <field name="Servo2PitchReverse" units="" type="enum" elements="1" options="FALSE,TRUE" defaultvalue="FALSE"/>
<access gcs="readwrite" flight="readwrite"/> <access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/> <telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/> <telemetryflight acked="true" updatemode="onchange" period="0"/>