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