1use super::PlaneGuidanceConfig;
4use crate::params::{Param, ParamTable, param};
5
6impl ParamTable for PlaneGuidanceConfig {
7 const PARAMS: &'static [Param<Self>] = &[
8 param!(deg "PGUID_BANK_MAX", max_bank_rad),
9 param!(deg "PGUID_PIT_UP", max_pitch_up_rad),
10 param!(deg "PGUID_PIT_DN", max_pitch_down_rad),
11 param!(deg "PGUID_ACRO_X", max_rate_radps.x),
12 param!(deg "PGUID_ACRO_Y", max_rate_radps.y),
13 param!(deg "PGUID_ACRO_Z", max_rate_radps.z),
14 param!(deg "PGUID_TRIM_PIT", trim_pitch_rad),
15 param!("PGUID_CRUISE", cruise_thrust),
16 param!("PGUID_L1_PERIOD", l1_period_s),
17 param!("PGUID_L1_DAMP", l1_damping),
18 param!("PGUID_LOIT_RAD", loiter_radius_m),
19 param!("PGUID_ALT_P", altitude_p),
20 param!("PGUID_ALT_I", altitude_i),
21 param!("PGUID_ALT_IMAX", altitude_max_integral),
22 param!("PGUID_TCONST", tecs.time_constant_s),
23 param!("PGUID_CLMB_MAX", tecs.max_climb_mps),
24 param!("PGUID_SINK_MIN", tecs.min_sink_mps),
25 param!("PGUID_SINK_MAX", tecs.max_sink_mps),
26 param!("PGUID_THR_DAMP", tecs.thrust_damping),
27 param!("PGUID_INTEG", tecs.integrator_gain),
28 param!("PGUID_PTCH_DAMP", tecs.pitch_damping),
29 param!("PGUID_PTCH_INTEG", tecs.pitch_integrator_gain),
30 param!("PGUID_SPDWEIGHT", tecs.speed_weight),
31 param!("PGUID_RLL2THR", tecs.roll_compensation),
32 param!("PGUID_ASPD_MIN", tecs.min_airspeed_mps),
33 param!("PGUID_ASPD_MAX", tecs.max_airspeed_mps),
34 param!("PGUID_USPD_SHARE", tecs.underspeed_share),
35 param!("PGUID_HDEM_TC", tecs.height_demand_time_constant_s),
36 param!("PGUID_ASPD_RT_TC", tecs.airspeed_rate_time_constant_s),
37 param!("PGUID_KE_HPF_TC", tecs.kinetic_rate_high_pass_s),
38 param!("PGUID_THR_MIN", min_thrust),
39 param!("PGUID_THR_MAX", max_thrust),
40 param!("PGUID_CLMB_THR", climb_thrust_per_rad),
41 ];
42}
43
44#[cfg(feature = "param-metadata")]
45mod metadata {
46 use super::PlaneGuidanceConfig;
47 use crate::params::metadata::{ParamMeta, ParamMetadata};
48
49 const STICKS: ParamMeta = ParamMeta::in_group("Plane Guidance", "Sticks");
50 const CRUISE: ParamMeta = ParamMeta::in_group("Plane Guidance", "Cruise");
51 const NAVIGATION: ParamMeta = ParamMeta::in_group("Plane Guidance", "Navigation");
52 const TECS: ParamMeta = ParamMeta::in_group("Plane Guidance", "Total energy control");
53
54 const fn at_least_zero(meta: ParamMeta) -> ParamMeta {
56 meta.at_least(0.0)
57 }
58
59 impl ParamMetadata for PlaneGuidanceConfig {
60 const METADATA: &'static [ParamMeta] = &[
61 STICKS
62 .param("PGUID_BANK_MAX", "Bank at full roll stick")
63 .with_units("deg")
64 .at_least(0.0)
65 .at_most(90.0),
66 STICKS
67 .param("PGUID_PIT_UP", "Pitch up at full back stick")
68 .with_units("deg")
69 .at_least(0.0)
70 .at_most(90.0),
71 STICKS
72 .param("PGUID_PIT_DN", "Pitch down at full forward stick")
73 .with_units("deg")
74 .at_least(0.0)
75 .at_most(90.0),
76 STICKS
77 .param("PGUID_ACRO_X", "Roll rate at full stick in rate mode")
78 .with_units("deg/s")
79 .at_least(0.0),
80 STICKS
81 .param("PGUID_ACRO_Y", "Pitch rate at full stick in rate mode")
82 .with_units("deg/s")
83 .at_least(0.0),
84 STICKS
85 .param("PGUID_ACRO_Z", "Yaw rate at full stick in rate mode")
86 .with_units("deg/s")
87 .at_least(0.0),
88 CRUISE
89 .param("PGUID_TRIM_PIT", "Pitch for wings-level cruise")
90 .with_units("deg")
91 .at_least(-90.0)
92 .at_most(90.0),
93 CRUISE
94 .param(
95 "PGUID_CRUISE",
96 "Throttle for level cruise at the trim airspeed",
97 )
98 .at_least(0.0)
99 .at_most(1.0),
100 NAVIGATION
101 .param(
102 "PGUID_L1_PERIOD",
103 "L1 period: shorter captures the path tighter",
104 )
105 .with_units("s")
106 .above(0.0),
107 NAVIGATION
108 .param("PGUID_L1_DAMP", "L1 damping ratio")
109 .above(0.0),
110 NAVIGATION
111 .param(
112 "PGUID_LOIT_RAD",
113 "Loiter radius around a waypoint with no leg",
114 )
115 .with_units("m")
116 .above(0.0),
117 at_least_zero(
118 NAVIGATION
119 .param(
120 "PGUID_ALT_P",
121 "Without airspeed: pitch per meter of altitude error",
122 )
123 .with_units("rad/m"),
124 ),
125 at_least_zero(NAVIGATION.param(
126 "PGUID_ALT_I",
127 "Without airspeed: altitude loop integral gain",
128 )),
129 at_least_zero(
130 NAVIGATION
131 .param(
132 "PGUID_ALT_IMAX",
133 "Without airspeed: altitude loop integral limit",
134 )
135 .with_units("m*s"),
136 ),
137 TECS.param(
138 "PGUID_TCONST",
139 "Time constant height and airspeed errors close in",
140 )
141 .with_units("s")
142 .above(0.0),
143 TECS.param(
144 "PGUID_CLMB_MAX",
145 "Climb rate at full throttle and trim airspeed",
146 )
147 .with_units("m/s")
148 .above(0.0),
149 TECS.param(
150 "PGUID_SINK_MIN",
151 "Sink rate at least throttle and trim airspeed",
152 )
153 .with_units("m/s")
154 .above(0.0),
155 at_least_zero(
156 TECS.param("PGUID_SINK_MAX", "Most sink rate the height demand asks")
157 .with_units("m/s"),
158 ),
159 at_least_zero(TECS.param(
160 "PGUID_THR_DAMP",
161 "Throttle damping on the total energy rate",
162 )),
163 at_least_zero(TECS.param("PGUID_INTEG", "Integrator gain of the throttle loop")),
164 at_least_zero(TECS.param(
165 "PGUID_PTCH_DAMP",
166 "Pitch damping on the energy balance rate",
167 )),
168 at_least_zero(TECS.param("PGUID_PTCH_INTEG", "Integrator gain of the pitch loop")),
169 TECS.param(
170 "PGUID_SPDWEIGHT",
171 "Pitch weight on airspeed vs height: 0 height, 1 both, 2 airspeed",
172 )
173 .at_least(0.0)
174 .at_most(2.0),
175 at_least_zero(
176 TECS.param("PGUID_RLL2THR", "Energy rate added for a bank's drag")
177 .with_units("m^2/s^3"),
178 ),
179 TECS.param(
180 "PGUID_ASPD_MIN",
181 "Least airspeed demanded; underspeed below",
182 )
183 .with_units("m/s")
184 .above(0.0),
185 TECS.param("PGUID_ASPD_MAX", "Most airspeed demanded")
186 .with_units("m/s")
187 .above(0.0),
188 TECS.param(
189 "PGUID_USPD_SHARE",
190 "Share of the least airspeed underspeed latches below",
191 )
192 .above(0.0)
193 .at_most(1.0),
194 TECS.param("PGUID_HDEM_TC", "Time constant of the height demand's lag")
195 .with_units("s")
196 .above(0.0),
197 TECS.param(
198 "PGUID_ASPD_RT_TC",
199 "Time constant of the airspeed rate's filter",
200 )
201 .with_units("s")
202 .above(0.0),
203 TECS.param(
204 "PGUID_KE_HPF_TC",
205 "Time constant of the kinetic energy rate's high-pass",
206 )
207 .with_units("s")
208 .above(0.0),
209 NAVIGATION
210 .param("PGUID_THR_MIN", "Least thrust in waypoint flight")
211 .at_least(0.0)
212 .at_most(1.0),
213 NAVIGATION
214 .param("PGUID_THR_MAX", "Most thrust in waypoint flight")
215 .at_least(0.0)
216 .at_most(1.0),
217 at_least_zero(NAVIGATION.param(
218 "PGUID_CLMB_THR",
219 "Without airspeed: thrust added per radian of climb pitch",
220 )),
221 ];
222 }
223}