Skip to content

Commit f6ec351

Browse files
committed
LP-603 Make QUATERNION_STABILIZATION optional. It can be harmful when using POIs on multicopter and the desired yaw jumps a lot, suddenly
1 parent aba11f0 commit f6ec351

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

flight/modules/Stabilization/outerloop.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* for more details.
2929
*
3030
* You should have received a copy of the GNU General Public License along
31-
* with this program; if not, write to the Free Software Foundation, Inc.,
31+
* with this program; if not, write to the Free Software Foundation, In.,
3232
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3333
*/
3434

@@ -146,8 +146,8 @@ static void stabilizationOuterloopTask()
146146

147147

148148
float local_error[3];
149-
{
150149
#if defined(PIOS_QUATERNION_STABILIZATION)
150+
if (stabSettings.settings.ForceRollPitchDuringYawTransition == STABILIZATIONSETTINGS_FORCEROLLPITCHDURINGYAWTRANSITION_FALSE) {
151151
// Quaternion calculation of error in each axis. Uses more memory.
152152
float rpy_desired[3];
153153
float q_desired[4];
@@ -173,8 +173,10 @@ static void stabilizationOuterloopTask()
173173
quat_mult(q_desired, &attitudeState.q1, q_error);
174174
quat_inverse(q_error);
175175
Quaternion2RPY(q_error, local_error);
176-
176+
} else {
177177
#else /* if defined(PIOS_QUATERNION_STABILIZATION) */
178+
{
179+
#endif /* if defined(PIOS_QUATERNION_STABILIZATION) */
178180
// Simpler algorithm for CC, less memory
179181
local_error[0] = stabilizationDesiredAxis[0] - attitudeState.Roll;
180182
local_error[1] = stabilizationDesiredAxis[1] - attitudeState.Pitch;
@@ -187,7 +189,6 @@ static void stabilizationOuterloopTask()
187189
} else {
188190
local_error[2] = modulo - 180.0f;
189191
}
190-
#endif /* if defined(PIOS_QUATERNION_STABILIZATION) */
191192
}
192193

193194

shared/uavobjectdefinition/stabilizationsettings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<field name="FlightModeAssistMap" units="" type="enum" options="None,GPSAssist" elements="6" defaultvalue="None,None,None,None,None,None" />
5050

5151
<field name="MeasureBasedDTerm" units="" type="enum" elements="1" options="False,True" defaultvalue="True"/>
52+
<field name="ForceRollPitchDuringYawTransition" units="" type="enum" elements="1" options="False,True" defaultvalue="True"/>
5253

5354
<access gcs="readwrite" flight="readwrite"/>
5455
<telemetrygcs acked="true" updatemode="onchange" period="0"/>

0 commit comments

Comments
 (0)