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