Firmware
parameters.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2016 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 #pragma once
35 
43 #include <px4_config.h>
44 #include <drivers/drv_rc_input.h>
45 
46 #include <parameters/param.h>
47 #include <mathlib/mathlib.h>
48 
49 #include <uORB/topics/rc_parameter_map.h>
50 #include <uORB/topics/input_rc.h>
51 
52 namespace sensors
53 {
54 
55 static const unsigned RC_MAX_CHAN_COUNT =
56  input_rc_s::RC_INPUT_MAX_CHANNELS;
58 struct Parameters {
59  float min[RC_MAX_CHAN_COUNT];
60  float trim[RC_MAX_CHAN_COUNT];
61  float max[RC_MAX_CHAN_COUNT];
62  float rev[RC_MAX_CHAN_COUNT];
63  float dz[RC_MAX_CHAN_COUNT];
64  float scaling_factor[RC_MAX_CHAN_COUNT];
65 
66  float diff_pres_offset_pa;
67 #ifdef ADC_AIRSPEED_VOLTAGE_CHANNEL
68  float diff_pres_analog_scale;
69 #endif /* ADC_AIRSPEED_VOLTAGE_CHANNEL */
70 
71  int32_t board_rotation;
72 
73  float board_offset[3];
74 
75  int32_t rc_map_roll;
76  int32_t rc_map_pitch;
77  int32_t rc_map_yaw;
78  int32_t rc_map_throttle;
79  int32_t rc_map_failsafe;
80 
81  int32_t rc_map_mode_sw;
82  int32_t rc_map_return_sw;
83  int32_t rc_map_rattitude_sw;
84  int32_t rc_map_posctl_sw;
85  int32_t rc_map_loiter_sw;
86  int32_t rc_map_acro_sw;
87  int32_t rc_map_offboard_sw;
88  int32_t rc_map_kill_sw;
89  int32_t rc_map_arm_sw;
90  int32_t rc_map_trans_sw;
91  int32_t rc_map_gear_sw;
92  int32_t rc_map_stab_sw;
93  int32_t rc_map_man_sw;
94  int32_t rc_map_flaps;
95 
96  int32_t rc_map_aux1;
97  int32_t rc_map_aux2;
98  int32_t rc_map_aux3;
99  int32_t rc_map_aux4;
100  int32_t rc_map_aux5;
101  int32_t rc_map_aux6;
102 
103  int32_t rc_map_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN];
104 
105  int32_t rc_map_flightmode;
106 
107  int32_t rc_fails_thr;
108  float rc_assist_th;
109  float rc_auto_th;
110  float rc_rattitude_th;
111  float rc_posctl_th;
112  float rc_return_th;
113  float rc_loiter_th;
114  float rc_acro_th;
115  float rc_offboard_th;
116  float rc_killswitch_th;
117  float rc_armswitch_th;
118  float rc_trans_th;
119  float rc_gear_th;
120  float rc_stab_th;
121  float rc_man_th;
122 
123  bool rc_assist_inv;
124  bool rc_auto_inv;
125  bool rc_rattitude_inv;
126  bool rc_posctl_inv;
127  bool rc_return_inv;
128  bool rc_loiter_inv;
129  bool rc_acro_inv;
130  bool rc_offboard_inv;
131  bool rc_killswitch_inv;
132  bool rc_armswitch_inv;
133  bool rc_trans_inv;
134  bool rc_gear_inv;
135  bool rc_stab_inv;
136  bool rc_man_inv;
137 
138  float rc_flt_smp_rate;
139  float rc_flt_cutoff;
140 
141  float battery_voltage_scaling;
142  float battery_current_scaling;
143  float battery_current_offset;
144  float battery_v_div;
145  float battery_a_per_v;
146  int32_t battery_source;
147  int32_t battery_adc_channel;
148 
149  float baro_qnh;
150 
151  int32_t air_cmodel;
152  float air_tube_length;
153  float air_tube_diameter_mm;
154 };
155 
157  param_t min[RC_MAX_CHAN_COUNT];
158  param_t trim[RC_MAX_CHAN_COUNT];
159  param_t max[RC_MAX_CHAN_COUNT];
160  param_t rev[RC_MAX_CHAN_COUNT];
161  param_t dz[RC_MAX_CHAN_COUNT];
162 
163  param_t diff_pres_offset_pa;
164 #ifdef ADC_AIRSPEED_VOLTAGE_CHANNEL
165  param_t diff_pres_analog_scale;
166 #endif /* ADC_AIRSPEED_VOLTAGE_CHANNEL */
167 
168  param_t rc_map_roll;
169  param_t rc_map_pitch;
170  param_t rc_map_yaw;
171  param_t rc_map_throttle;
172  param_t rc_map_failsafe;
173 
174  param_t rc_map_mode_sw;
175  param_t rc_map_return_sw;
176  param_t rc_map_rattitude_sw;
177  param_t rc_map_posctl_sw;
178  param_t rc_map_loiter_sw;
179  param_t rc_map_acro_sw;
180  param_t rc_map_offboard_sw;
181  param_t rc_map_kill_sw;
182  param_t rc_map_arm_sw;
183  param_t rc_map_trans_sw;
184  param_t rc_map_gear_sw;
185  param_t rc_map_flaps;
186  param_t rc_map_stab_sw;
187  param_t rc_map_man_sw;
188 
189  param_t rc_map_aux1;
190  param_t rc_map_aux2;
191  param_t rc_map_aux3;
192  param_t rc_map_aux4;
193  param_t rc_map_aux5;
194  param_t rc_map_aux6;
195 
196  param_t rc_map_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN];
197  param_t rc_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN];
202  param_t rc_map_flightmode;
203 
204  param_t rc_fails_thr;
205  param_t rc_assist_th;
206  param_t rc_auto_th;
207  param_t rc_rattitude_th;
208  param_t rc_posctl_th;
209  param_t rc_return_th;
210  param_t rc_loiter_th;
211  param_t rc_acro_th;
212  param_t rc_offboard_th;
213  param_t rc_killswitch_th;
214  param_t rc_armswitch_th;
215  param_t rc_trans_th;
216  param_t rc_gear_th;
217  param_t rc_stab_th;
218  param_t rc_man_th;
219 
220  param_t rc_flt_smp_rate;
221  param_t rc_flt_cutoff;
222 
223  param_t battery_voltage_scaling;
224  param_t battery_current_scaling;
225  param_t battery_current_offset;
226  param_t battery_v_div;
227  param_t battery_a_per_v;
228  param_t battery_source;
229  param_t battery_adc_channel;
230 
231  param_t board_rotation;
232 
233  param_t board_offset[3];
234 
235  param_t baro_qnh;
236 
237  param_t air_cmodel;
238  param_t air_tube_length;
239  param_t air_tube_diameter_mm;
240 
241 };
242 
246 void initialize_parameter_handles(ParameterHandles &parameter_handles);
247 
248 
253 int update_parameters(const ParameterHandles &parameter_handles, Parameters &parameters);
254 
255 } /* namespace sensors */
R/C input interface.
Configuration flags used in code.
Definition: parameters.h:156
Global flash based parameter store.
Definition: parameters.h:58
Definition: common.h:43
Common header for mathlib exports.
uint32_t param_t
Parameter handle.
Definition: param.h:98