Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
eff_scheduling_rotwing_V2.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Tomaso De Ponti <T.M.L.DePonti@tudelft.nl>
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
26#ifndef CTRL_EFF_SCHED_ROTWING_H
27#define CTRL_EFF_SCHED_ROTWING_H
28
29#include "std.h"
30#include "generated/airframe.h"
31
32#ifndef EFF_MAT_ROWS_NB
33#define EFF_MAT_ROWS_NB 6
34#endif
35
36#ifndef COMMANDS_NB_VIRTUAL
37#define COMMANDS_NB_VIRTUAL 0
38#endif
39
40#define RW_aX 0 // X body axis (linear acceleration)
41#define RW_aY 1 // Y body axis (linear acceleration)
42#define RW_aZ 2 // Z body axis (linear acceleration)
43#define RW_aN 0 // North axis (linear acceleration)
44#define RW_aE 1 // East axis (linear acceleration)
45#define RW_aD 2 // Down axis (linear acceleration)
46#define RW_ap 3 // X body axis (angular acceleration)
47#define RW_aq 4 // Y body axis (angular acceleration)
48#define RW_ar 5 // Z body axis (angular acceleration)
49
50#ifndef EFF_MAT_COLS_NB
51#define EFF_MAT_COLS_NB (COMMANDS_NB_REAL + COMMANDS_NB_VIRTUAL)
52#endif
53
54#define RW_G_SCALE 1000.0f
55
56// Elevator ctrl definitions
57#ifndef ZERO_ELE_PPRZ
58#define ZERO_ELE_PPRZ 8000
59#endif
60
61#ifndef ELE_MIN_AS
62#define ELE_MIN_AS 8.8
63#endif
64
65#ifndef ELE_MAX_AS // should match the max airspeed
66#define ELE_MAX_AS 16.0
67#endif
68
70extern float G2_RW[EFF_MAT_COLS_NB] ;
73 float Ixx_body; // body MMOI around roll axis [kgm²]
74 float Iyy_body; // body MMOI around pitch axis [kgm²]
75 float Izz; // total MMOI around yaw axis [kgm²]
76 float Ixx_wing; // wing MMOI around the chordwise direction of the wing [kgm²]
77 float Iyy_wing; // wing MMOI around the spanwise direction of the wing [kgm²]
78 float m; // mass [kg]
79 float DMdpprz_hover_roll[2]; // Moment coeficients for roll motors (Scaled by 10000)
80 float hover_roll_pitch_coef[2]; // Model coefficients to correct pitch effective for roll motors
81 float hover_roll_roll_coef[2]; // Model coefficients to correct roll effectiveness for roll motors
82 float k_elevator[3];
83 float k_rudder[3];
84 float k_aileron;
85 float k_flaperon;
86 float k_pusher[2];
87 float k_elevator_deflection[2];
88 float d_rudder_d_pprz;
89 float k_rpm_pprz_pusher[3];
90 float k_lift_wing[2];
91 float k_lift_fuselage;
92 float k_lift_tail;
93};
94
96 float Ixx; // Total MMOI around roll axis [kgm²]
97 float Iyy; // Total MMOI around pitch axis [kgm²]
98 float wing_rotation_rad; // Wing rotation angle in radians: from ABI message
99 float wing_rotation_deg; // Wing rotation angle in degrees: (clone in degrees)
100 float cosr; // cosine of wing rotation angle
101 float sinr; // sine of wing rotation angle
102 float cosr2; // cosine² of wing rotation angle
103 float sinr2; // sine² of wing rotation angle
104 float cosr3; // cosine³ of wing rotation angle
105 float sinr3; // sine³ of wing rotation angle
106
107 // Set during initialization
108 float pitch_motor_dMdpprz; // derivative of delta moment with respect to a delta paparazzi command for the pitch motors [Nm/pprz]
109 float roll_motor_dMdpprz; // derivative of delta moment with respect to a delta paparazzi command for the roll motors [Nm/pprz]
110
111 // commands
112 float cmd_elevator;
113 float cmd_pusher;
114 float cmd_pusher_scaled;
115 float cmd_T_mean_scaled;
116
117 // airspeed
118 float airspeed;
119 float airspeed2;
120};
121
122struct I{
123 float xx;
124 float yy;
125 float zz;
126 float w_xx;
127 float w_yy;
128 float b_xx;
129 float b_yy;
130};
131struct F_M_Body{
132 float dFdu; // derivative of the force with respect to the control input (e.g. linear coefficient)
133 float dMdu; // derivative of the reaction trque with respect to the control input (e.g. linear coefficient)
134 float dMdud; // derivative of the reaction torque with respect to the control input time derivative
135 float l; // arm length
136};
137
138struct wing_model{
139 float k0; // Linear coefficient (theta u²)
140 float k1; // Linear coeeficient (theta u² s(Lambda)²)
141 float k2; // linear coefficient with (u² s(Lambda)²)
142 float dLdtheta; // derivative of lift with respect to the pitch angle
143 float L; // Lift
144};
145
146struct RW_attitude{
147 float phi;
148 float theta;
149 float psi;
150 float sphi;
151 float cphi;
152 float stheta;
153 float ctheta;
154 float spsi;
155 float cpsi;
156};
157
158struct RW_skew{
159 float rad; // Wing rotation angle in radians: from ABI message
160 float deg; // Wing rotation angle in degrees: (clone in degrees)
161 float cosr; // cosine of wing rotation angle
162 float sinr; // sine of wing rotation angle
163 float cosr2; // cosine² of wing rotation angle
164 float sinr2; // sine² of wing rotation angle
165 float cosr3; // cosine³ of wing rotation angle
166 float sinr3; // sine³ of wing rotation angle
167 float cosr4; // cosine⁴ of wing rotation angle
168 float sinr4; // sine⁴ of wing rotation angle
169};
170struct RW_Model{
171 struct I I; // Inertia matrix
172 float m; // mass [kg]
173 float T; // Thrust [N]
174 float P; // Pusher thrust [N]
175 struct RW_skew skew;
176 struct RW_attitude att;
177 struct wing_model wing;
178 struct F_M_Body mF;
179 struct F_M_Body mR;
180 struct F_M_Body mB;
181 struct F_M_Body mL;
182 struct F_M_Body mP;
183 struct F_M_Body ele;
184 struct F_M_Body rud;
185 struct F_M_Body ail;
186 struct F_M_Body flp;
187 float as; // airspeed [m/s]
188 float as2; // airspeed squared [m/s²]
189 float ele_pref;
190
191};
192
193extern bool manual_roll ;
194extern bool manual_pitch ;
195extern bool manual_yaw ;
196
197extern int G2_on;
198extern int thrust_curve;
199extern float temp_mQ_k;
200
201extern bool airspeed_fake_on;
202extern float airspeed_fake;
203extern float ele_eff;
204extern float roll_eff;
205extern float yaw_eff;
206extern float ele_min;
207
208extern float rotation_angle_setpoint_deg;
209extern int16_t rotation_cmd;
210
211extern float eff_sched_pusher_time;
212
213extern void eff_scheduling_rotwing_init(void);
214extern void eff_scheduling_rotwing_periodic(void);
215
216extern struct RW_Model RW;
217#endif // CTRL_EFF_SCHED_ROTWING_H
218
float G2_RW[EFF_MAT_COLS_NB]
int thrust_curve
struct wing_model wing
float G1_RW[EFF_MAT_ROWS_NB][EFF_MAT_COLS_NB]
struct F_M_Body ele
float ele_min
struct F_M_Body mP
struct F_M_Body mL
float airspeed_fake
struct RW_Model RW
bool manual_pitch
float roll_eff
#define EFF_MAT_COLS_NB
float EFF_MAT_RW[EFF_MAT_ROWS_NB][EFF_MAT_COLS_NB]
bool manual_roll
float rotation_angle_setpoint_deg
struct F_M_Body mR
struct F_M_Body mF
float yaw_eff
struct RW_attitude att
void eff_scheduling_rotwing_init(void)
#define EFF_MAT_ROWS_NB
struct F_M_Body rud
bool airspeed_fake_on
int16_t rotation_cmd
struct RW_skew skew
float eff_sched_pusher_time
bool manual_yaw
void eff_scheduling_rotwing_periodic(void)
struct F_M_Body flp
float temp_mQ_k
struct F_M_Body mB
struct F_M_Body ail
short int16_t
Typedef defining 16 bit short type.