1use super::CopterGuidanceConfig;
4use crate::params::{Param, ParamTable, param};
5
6impl ParamTable for CopterGuidanceConfig {
7 const PARAMS: &'static [Param<Self>] = &[
8 param!("GUID_ALT_P", altitude.gains.p),
9 param!("GUID_ALT_I", altitude.gains.i),
10 param!("GUID_ALT_D", altitude.gains.d),
11 param!("GUID_ALT_IMAX", altitude.max_integral),
12 param!("GUID_ALT_HOVER", altitude.hover_thrust),
13 param!("GUID_LAT_POS_P", lateral.position_p),
14 param!("GUID_LAT_VEL_P", lateral.velocity.p),
15 param!("GUID_LAT_VEL_I", lateral.velocity.i),
16 param!("GUID_LAT_VEL_D", lateral.velocity.d),
17 param!("GUID_LAT_IMAX", lateral.max_integral),
18 param!("GUID_LAT_ACC", lateral.max_accel_mps2),
19 param!("GUID_LAT_BRK", lateral.brake_mps2),
20 param!("GUID_NAV_PERIOD", navigation_period_s),
21 param!(deg "GUID_TILT_MAX", max_tilt_rad),
22 param!("GUID_DESC_MAX", max_descent_mps),
23 param!("GUID_DESC_ACC", descent_accel_mps2),
24 param!("GUID_CLIMB_DEC", climb_decel_mps2),
25 param!("GUID_LAND_SPD", land_speed_mps),
26 param!(deg "GUID_YAW_SLEW", waypoint_yaw_radps),
27 param!(deg "GUID_HDG_RATE", heading_rate_radps),
28 param!("GUID_YAW_MIN_LEG", waypoint_yaw_min_leg_m),
29 param!(deg "GUID_YAW_YLD_ERR", heading_yield_rad),
30 param!(deg "GUID_YAW_YLD_RT", heading_yield_rate_radps),
31 param!("GUID_YAW_YLD_S", heading_yield_s),
32 param!("GUID_WND_HDG_SPD", wind_heading_min_mps),
33 param!("GUID_THR_MIN", thrust.min_thrust),
34 param!("GUID_SINK_LIM", thrust.sink_limit_mps),
35 param!("GUID_SINK_GAIN", thrust.sink_gain),
36 param!("GUID_BOOST_MAX", thrust.max_boost_thrust),
37 param!(deg "GUID_STICK_X", max_stick_angles_rad.x),
38 param!(deg "GUID_STICK_Y", max_stick_angles_rad.y),
39 param!(deg "GUID_STICK_YAW", stick_yaw_rate_radps),
40 param!("GUID_THR_IDLE", idle_throttle),
41 param!("GUID_ALT_LEASH", altitude_leash_m),
42 param!(deg "GUID_WND_HDG_OFF", wind_heading_from_wind_rad),
43 param!(deg "GUID_WND_HDG_SD", wind_heading_max_sd_rad),
44 param!(deg "GUID_WND_HDG_DB", wind_heading_deadband_rad),
45 param!("GUID_WND_AIR_HT", airborne_height_m),
46 param!("GUID_WND_FF_BAND", feedforward_hold_band_mps),
47 param!("GUID_WND_BCOEF_X", wind.ballistic_kgpm2.x),
48 param!("GUID_WND_BCOEF_Y", wind.ballistic_kgpm2.y),
49 param!("GUID_WND_MCOEF_X", wind.momentum_per_s.x),
50 param!("GUID_WND_MCOEF_Y", wind.momentum_per_s.y),
51 param!("GUID_WND_F_NSE", wind.force_noise_mps2),
52 param!("GUID_WND_P_NSE", wind.process_noise_mps_per_rt_s),
53 param!("GUID_WND_INIT_SD", wind.initial_sd_mps),
54 param!("GUID_WND_GATE", wind.gate_sigma),
55 param!("GUID_WND_AX_SPD", wind.max_axial_speed_mps),
56 param!("GUID_ALT_IBAND", altitude.integration_band_m),
57 param!("GUID_LAT_BRK_SHR", lateral.braking_share),
58 ];
59}
60
61#[cfg(feature = "param-metadata")]
62mod metadata {
63 use super::CopterGuidanceConfig;
64 use crate::commanders::touchdown::DESCENDING_MPS;
65 use crate::params::metadata::{ParamMeta, ParamMetadata};
66
67 const ALTITUDE: ParamMeta = ParamMeta::in_group("Guidance", "Altitude");
68 const LATERAL: ParamMeta = ParamMeta::in_group("Guidance", "Lateral");
69 const NAVIGATION: ParamMeta = ParamMeta::in_group("Guidance", "Navigation");
70 const LIMITS: ParamMeta = ParamMeta::in_group("Guidance", "Limits");
71 const LANDING: ParamMeta = ParamMeta::in_group("Guidance", "Landing");
72 const WIND: ParamMeta = ParamMeta::in_group("Guidance", "Wind");
73 const STICKS: ParamMeta = ParamMeta::in_group("Guidance", "Sticks");
74
75 impl ParamMetadata for CopterGuidanceConfig {
76 const METADATA: &'static [ParamMeta] = &[
77 ALTITUDE.param("GUID_ALT_P", "Altitude loop proportional gain"),
78 ALTITUDE.param("GUID_ALT_I", "Altitude loop integral gain"),
79 ALTITUDE.param("GUID_ALT_D", "Altitude loop derivative gain"),
80 ALTITUDE
81 .param("GUID_ALT_IMAX", "Altitude loop integral limit")
82 .with_units("m*s")
83 .at_least(0.0),
84 ALTITUDE
85 .param("GUID_ALT_HOVER", "Linear thrust that holds a level hover")
86 .above(0.0)
87 .at_most(1.0),
88 LATERAL
89 .param("GUID_LAT_POS_P", "Position error to velocity gain")
90 .with_units("1/s")
91 .at_least(0.0),
92 LATERAL.param("GUID_LAT_VEL_P", "Velocity loop proportional gain"),
93 LATERAL.param("GUID_LAT_VEL_I", "Velocity loop integral gain"),
94 LATERAL.param("GUID_LAT_VEL_D", "Velocity loop derivative gain"),
95 LATERAL
96 .param("GUID_LAT_IMAX", "Velocity loop integral limit, per axis")
97 .with_units("m")
98 .at_least(0.0),
99 LATERAL
100 .param(
101 "GUID_LAT_ACC",
102 "Most the velocity target changes per second (0: off)",
103 )
104 .with_units("m/s/s")
105 .at_least(0.0),
106 LATERAL
107 .param(
108 "GUID_LAT_BRK",
109 "Braking deceleration toward a waypoint with GUID_LAT_ACC 0 (0: linear)",
110 )
111 .with_units("m/s/s")
112 .at_least(0.0),
113 NAVIGATION
114 .param(
115 "GUID_NAV_PERIOD",
116 "Time between lateral position loop runs (0: every tick)",
117 )
118 .with_units("s")
119 .at_least(0.0),
120 LIMITS
121 .param("GUID_TILT_MAX", "Largest tilt waypoint flight requests")
122 .with_units("deg")
123 .above(0.0)
124 .below(90.0),
125 LIMITS
126 .param("GUID_DESC_MAX", "Fastest descent waypoint flight requests")
127 .with_units("m/s")
128 .above(0.0),
129 LIMITS
130 .param(
131 "GUID_DESC_ACC",
132 "Acceleration a descent or land starts with, and a waypoint descent stops with",
133 )
134 .with_units("m/s/s")
135 .above(0.0),
136 LIMITS
137 .param(
138 "GUID_CLIMB_DEC",
139 "Deceleration a descent or land started while climbing sheds the climb at",
140 )
141 .with_units("m/s/s")
142 .above(0.0),
143 LANDING
144 .param("GUID_LAND_SPD", "Descent rate while landing")
145 .with_units("m/s")
146 .above(DESCENDING_MPS),
147 NAVIGATION
148 .param(
149 "GUID_YAW_SLEW",
150 "Rate waypoint flight turns to face along the leg (0: holds heading)",
151 )
152 .with_units("deg/s")
153 .at_least(0.0),
154 NAVIGATION
155 .param(
156 "GUID_HDG_RATE",
157 "Rate waypoint flight turns to a waypoint's heading",
158 )
159 .with_units("deg/s")
160 .above(0.0),
161 NAVIGATION
162 .param(
163 "GUID_YAW_MIN_LEG",
164 "Shortest waypoint leg the heading turns along",
165 )
166 .with_units("m")
167 .at_least(0.0),
168 NAVIGATION
169 .param(
170 "GUID_YAW_YLD_ERR",
171 "Heading error past which a heading not turning is stuck",
172 )
173 .with_units("deg")
174 .at_least(0.0),
175 NAVIGATION
176 .param(
177 "GUID_YAW_YLD_RT",
178 "Yaw rate toward the target under which a heading off it is stuck",
179 )
180 .with_units("deg/s")
181 .at_least(0.0),
182 NAVIGATION
183 .param(
184 "GUID_YAW_YLD_S",
185 "Time stuck before waypoint flight yields the heading (0: never)",
186 )
187 .with_units("s")
188 .at_least(0.0),
189 NAVIGATION
190 .param(
191 "GUID_WND_HDG_SPD",
192 "Least wind that turns a wingtip into it while holding or landing (0: off)",
193 )
194 .with_units("m/s")
195 .at_least(0.0),
196 LIMITS
197 .param("GUID_THR_MIN", "Least thrust while flying (0: none)")
198 .at_least(0.0)
199 .below(1.0),
200 LIMITS
201 .param(
202 "GUID_SINK_LIM",
203 "Sink rate past which piloted flight gets more thrust (0: off)",
204 )
205 .with_units("m/s")
206 .at_least(0.0),
207 LIMITS
208 .param(
209 "GUID_SINK_GAIN",
210 "Thrust added per m/s of sink past the limit",
211 )
212 .with_units("s/m")
213 .at_least(0.0),
214 STICKS
215 .param(
216 "GUID_BOOST_MAX",
217 "Most thrust the attitude-mode tilt boost gives",
218 )
219 .above(0.0)
220 .at_most(1.0),
221 STICKS
222 .param("GUID_STICK_X", "Roll angle at full stick in attitude mode")
223 .with_units("deg")
224 .at_least(0.0),
225 STICKS
226 .param("GUID_STICK_Y", "Pitch angle at full stick in attitude mode")
227 .with_units("deg")
228 .at_least(0.0),
229 STICKS
230 .param(
231 "GUID_STICK_YAW",
232 "Heading slew rate at full yaw stick in attitude mode",
233 )
234 .with_units("deg/s")
235 .at_least(0.0),
236 STICKS
237 .param(
238 "GUID_THR_IDLE",
239 "Piloted throttle at or below which the motors idle, unfloored",
240 )
241 .at_least(0.0)
242 .below(1.0),
243 LIMITS
244 .param(
245 "GUID_ALT_LEASH",
246 "Furthest a descending altitude target runs below the vehicle",
247 )
248 .with_units("m")
249 .above(0.0),
250 NAVIGATION
251 .param(
252 "GUID_WND_HDG_OFF",
253 "Angle between the wind heading and where the wind comes from",
254 )
255 .with_units("deg")
256 .at_least(0.0)
257 .at_most(180.0),
258 NAVIGATION
259 .param(
260 "GUID_WND_HDG_SD",
261 "Most wind direction uncertainty that turns the heading",
262 )
263 .with_units("deg")
264 .at_least(0.0),
265 NAVIGATION
266 .param(
267 "GUID_WND_HDG_DB",
268 "Least wind heading change that moves a latched one",
269 )
270 .with_units("deg")
271 .at_least(0.0),
272 WIND.param(
273 "GUID_WND_AIR_HT",
274 "Height above the ground past which the wind estimate updates",
275 )
276 .with_units("m")
277 .at_least(0.0),
278 WIND.param(
279 "GUID_WND_FF_BAND",
280 "Commanded speed under which the drag feedforward leaves a hold to the loop",
281 )
282 .with_units("m/s")
283 .at_least(0.0),
284 WIND.param(
285 "GUID_WND_BCOEF_X",
286 "Ballistic coefficient along x (belly on a tailsitter) for the wind estimate (0: off)",
287 )
288 .with_units("kg/m/m")
289 .at_least(0.0),
290 WIND.param(
291 "GUID_WND_BCOEF_Y",
292 "Ballistic coefficient along y for the wind estimate (0: off)",
293 )
294 .with_units("kg/m/m")
295 .at_least(0.0),
296 WIND.param(
297 "GUID_WND_MCOEF_X",
298 "Momentum drag along x for the wind estimate (0: off)",
299 )
300 .with_units("1/s")
301 .at_least(0.0),
302 WIND.param(
303 "GUID_WND_MCOEF_Y",
304 "Momentum drag along y for the wind estimate (0: off)",
305 )
306 .with_units("1/s")
307 .at_least(0.0),
308 WIND.param("GUID_WND_F_NSE", "Specific-force noise of the wind estimate")
309 .with_units("m/s/s")
310 .above(0.0),
311 WIND.param("GUID_WND_P_NSE", "How fast the estimated wind may change")
312 .with_units("m/s/s^0.5")
313 .at_least(0.0),
314 WIND.param(
315 "GUID_WND_INIT_SD",
316 "Wind estimate's uncertainty before its first measurement; from next arming",
317 )
318 .with_units("m/s")
319 .above(0.0),
320 WIND.param(
321 "GUID_WND_GATE",
322 "Standard deviations past which a wind measurement is rejected",
323 )
324 .above(0.0),
325 WIND.param(
326 "GUID_WND_AX_SPD",
327 "Most climb or sink the wind estimate measures at",
328 )
329 .with_units("m/s")
330 .above(0.0),
331 ALTITUDE
332 .param(
333 "GUID_ALT_IBAND",
334 "Altitude error within which the altitude integral runs",
335 )
336 .with_units("m")
337 .above(0.0),
338 LATERAL
339 .param(
340 "GUID_LAT_BRK_SHR",
341 "Share of GUID_LAT_ACC the braking curve slows at",
342 )
343 .above(0.0)
344 .at_most(1.0),
345 ];
346 }
347}