Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
guidance_indi_quadrotor.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
28#include "state.h"
29#include "autopilot.h"
30#include "generated/modules.h"
31
40{
41 float sphi = sinf(euler_zyx.phi);
42 float cphi = cosf(euler_zyx.phi);
43 float stheta = sinf(euler_zyx.theta);
44 float ctheta = cosf(euler_zyx.theta);
45 float spsi = sinf(euler_zyx.psi);
46 float cpsi = cosf(euler_zyx.psi);
47 // minus gravity is a guesstimate of the thrust force, thrust measurement would be better
48 float T = -9.81f;
49
50 Gmat[0][0] = (cphi * spsi - sphi * cpsi * stheta) * T;
51 Gmat[1][0] = (-sphi * spsi * stheta - cpsi * cphi) * T;
52 Gmat[2][0] = -ctheta * sphi * T;
53 Gmat[0][1] = (cphi * cpsi * ctheta) * T;
54 Gmat[1][1] = (cphi * spsi * ctheta) * T;
55 Gmat[2][1] = -stheta * cphi * T;
56 Gmat[0][2] = sphi * spsi + cphi * cpsi * stheta;
57 Gmat[1][2] = cphi * spsi * stheta - cpsi * sphi;
58 Gmat[2][2] = cphi * ctheta;
59}
60
68static void guidance_indi_calcG_yxz(float Gmat[3][3], struct FloatEulers euler_yxz)
69{
70 float sphi = sinf(euler_yxz.phi);
71 float cphi = cosf(euler_yxz.phi);
72 float stheta = sinf(euler_yxz.theta);
73 float ctheta = cosf(euler_yxz.theta);
74 // minus gravity is a guesstimate of the thrust force, thrust measurement would be better
75 float T = -9.81f;
76
77 Gmat[0][0] = ctheta * cphi * T;
78 Gmat[1][0] = 0;
79 Gmat[2][0] = -stheta * cphi * T;
80 Gmat[0][1] = -stheta * sphi * T;
81 Gmat[1][1] = -cphi * T;
82 Gmat[2][1] = -ctheta * sphi * T;
83 Gmat[0][2] = stheta * cphi;
84 Gmat[1][2] = -sphi;
85 Gmat[2][2] = ctheta * cphi;
86}
87
92void guidance_indi_calcG(float Gmat[3][3], struct FloatEulers att) {
93#ifdef GUIDANCE_INDI_CALC_G_ZYX
95#else
96 guidance_indi_calcG_yxz(Gmat, att); // default case
97#endif
98}
99
Core autopilot interface common to all firmwares.
#define UNUSED(x)
euler angles
static float Gmat[GUIDANCE_INDI_NV][GUIDANCE_INDI_NU]
A guidance mode based on Incremental Nonlinear Dynamic Inversion.
void guidance_indi_calcG(float Gmat[3][3], struct FloatEulers att)
Compute effectiveness matrix for guidance.
static void guidance_indi_calcG_yxz(float Gmat[3][3], struct FloatEulers euler_yxz)
static UNUSED void guidance_indi_calcG_zyx(float Gmat[3][3], struct FloatEulers euler_zyx)
Simple first order low pass filter with bilinear transform.
uint16_t foo
Definition main_demo5.c:58
API to get/set the generic vehicle states.