summaryrefslogtreecommitdiffstats
path: root/uav_params.m
blob: da8a19b8a175552511eb441994334375dd147011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
% Retrieve or compute parameters for ducted-fan VTOL micro-UAV.
%
% Copyright (C) 2024, Naoki Sean Pross, ETH Zürich
% This work is distributed under a permissive license, see LICENSE.txt

function [params] = uav_params()

% Unit of measurements unless specified otherwise are
% Mass in kg
% Lenghts in m
% Time in s
% Frequencies in Hz
% Angular velocities in rad / s

params = struct();

% ------------------------------------------------------------------------
% Physical constants

params.physics = struct(...
  'Gravity', 9.81, ...
  'AirDensity', 1.204 ... % kg / m^3
);

% ------------------------------------------------------------------------
% Mechanical measurements

% Inertia marix at center of mass,
% numbers from CAD are in g * mm^2, convert to kg * m^2
J = [
  5.856E+08, 1.121E+06, -3.506E+05;
  1.121E+06, 4.222E+08, 6.643E+06;
  -3.506E+05, 6.643E+06, 4.678E+08
] * 1e-9;

% Approximate propeller with a disk
m_prop = 200e-3; % mass of propeller
r_prop = 85e-3; % radius of propeller
J_prop = .5 * m_prop * r_prop^2;

params.mechanical = struct(...
  'Mass', 3.0, ...
  'DuctRadius', 46e-3, ...
  'DuctHeight', 171e-3, ...
  'FlapZDistance', 98e-3, ... % flap distance along z from center of mass
  'InertiaTensor', J, ...
  'GyroscopicInertiaZ', J_prop ... % assume small angle
);

% ------------------------------------------------------------------------
% Actuator limits and measurements

% Servos usually give a "speed" in seconds / 60 degrees without load
servo_speed = 0.13; % seconds / 60 deg
servo_angular_velocity = (60 / servo_speed) * (pi / 180); % rad / s

params.actuators = struct(...
  'PropellerMaxAngularVelocity', 620.7, ... % in rad / s
  'ServoAbsMaxAngle', 20 * pi / 180, ... % in radians
  'ServoMaxTorque', 4.3 * 1e-2, ... % in kg / m
  'ServoNominalAngularVelocity', servo_angular_velocity ...
);

% IMU runs in NDOF mode
params.measurements = struct(...
  'SensorFusionDelay', 20e-3, ... % in s
  'LIDARAccuracy', 10e-3, ... % in m
  'LIDARMaxDistance', 40, ... % inm
  'LIDARBandwidth', 100, ... % in Hz for z position
  'IMUBandwidth', 100 ... % in Hz
);

% ------------------------------------------------------------------------
% Aerodynamics modelling

% Compute thrust proportionality factor from actuator limits
% from thrust relation F = k * omega^2.
% FIXME: this is not ideal, need better measurements
omega_max = params.actuators.PropellerMaxAngularVelocity;
F_max = 38.637; % in N (measured)
k_T = F_max / omega_max^2;

% FIXME: LiftCoefficient comes from
% https://scienceworld.wolfram.com/physics/LiftCoefficient.html
params.aerodynamics = struct(...
  'ThrustOmegaProp', k_T, ... % in s^2 / (rad * N)
  'FlapArea', 23e-3 * 10e-3, ... % in m^2
  'DragCoefficients', [1, .1], ... % TODO
  'LiftCoefficient', 2 * pi ... % TODO
);


% ------------------------------------------------------------------------
% Linearization point of non-linear dynamics.

% Compute theoretical thrust required to make the UAV hover
% from the relation mg = k * omega^2
% FIXME: This value should probably be replaced with a measurement
g = params.physics.Gravity;
m = params.mechanical.Mass;
k = params.aerodynamics.ThrustOmegaProp;

omega_hover = sqrt(m * g / k);

params.linearization = struct(...
  'PadeApproxOrder', 2, ...
  'Position', [0; 0; -2], ... % in inertial frame, z points down
  'Velocity', [0; 0; 0], ... % in inertial frame
  'Angles', [0; 0; pi / 4], ...   % in body frame
  'AngularVelocities', [0; 0; 0], ... % in body frame
  'Inputs', [0; 0; 0; 0; omega_hover] ... % Flaps at rest and turbine at X
);

% ------------------------------------------------------------------------
% Performance requirements

params.performance = struct(...
  'ReferencePosMaxDistance', 1, ... % m
  'HorizontalPosMaxError', 2, ... % m
  'HorizontalMaxSpeed', 2, ... % m / s
  'HorizontalSettleTime', 6, ... % s
  'VerticalPosMaxError', 2, ... % m
  'VerticalMaxSpeed', 2, ... % m / s
  'VerticalSettleTime', 4, ... % s
  'AngleMaxPitchRoll', 10 * pi / 180, ... % in rad
  'AngleMaxYaw', pi, ... % rad
  'AngleMaxAngularRate', 20 * pi / 180 ... % rad / s
);

% Scaling matrices (because signals are normalized wrt parameter performance)
p = params.performance;

params.ErrorScalingMatrix = blkdiag(...
  eye(4) * params.actuators.ServoAbsMaxAngle, ...
  params.actuators.PropellerMaxAngularVelocity ...
    - params.linearization.Inputs(5), ...
  eye(2) * p.HorizontalPosMaxError, ...
  p.VerticalPosMaxError, ...
  eye(2) * p.HorizontalMaxSpeed, ...
  p.VerticalMaxSpeed, ...
  eye(2) * p.AngleMaxPitchRoll, ...
  p.AngleMaxYaw);

params.OutputScalingMatrix = blkdiag(...
  eye(2) * p.HorizontalPosMaxError, ...
  p.VerticalPosMaxError, ...
  eye(2) * p.HorizontalMaxSpeed, ...
  p.VerticalMaxSpeed, ...
  eye(2) * p.AngleMaxPitchRoll, ...
  p.AngleMaxYaw, ...
  eye(3) * p.AngleMaxAngularRate);


horiz_settle_speed = (1 - exp(-1)) / params.performance.HorizontalSettleTime;
if horiz_settle_speed > params.performance.HorizontalMaxSpeed
  fprintf(['Contradictory performance requirements: ' ...
    'velocity needed to attain horizontal settle time is ' ...
    'higher than HorizontalMaxSpeed']);
end

vert_settle_speed = (1 - exp(-1)) / params.performance.VerticalSettleTime;
if vert_settle_speed > params.performance.VerticalMaxSpeed
  fprintf(['Contradictory performance requirements: ' ...
    'velocity needed to attain vertical settle time is ' ...
    'higher than VerticalMaxSpeed']);
end

end
% vim: ts=2 sw=2 et: