PX4 Firmware
PX4 Autopilot Software http://px4.io
parameters.cpp
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 /**
35  * @file parameters.cpp
36  *
37  * @author Beat Kueng <beat-kueng@gmx.net>
38  */
39 
40 #include "parameters.h"
41 
42 namespace sensors
43 {
44 
46 {
47  /* Differential pressure offset */
48  parameter_handles.diff_pres_offset_pa = param_find("SENS_DPRES_OFF");
49 #ifdef ADC_AIRSPEED_VOLTAGE_CHANNEL
50  parameter_handles.diff_pres_analog_scale = param_find("SENS_DPRES_ANSC");
51 #endif /* ADC_AIRSPEED_VOLTAGE_CHANNEL */
52 
53  /* rotations */
54  parameter_handles.board_rotation = param_find("SENS_BOARD_ROT");
55 
56  /* rotation offsets */
57  parameter_handles.board_offset[0] = param_find("SENS_BOARD_X_OFF");
58  parameter_handles.board_offset[1] = param_find("SENS_BOARD_Y_OFF");
59  parameter_handles.board_offset[2] = param_find("SENS_BOARD_Z_OFF");
60 
61  /* Barometer QNH */
62  parameter_handles.baro_qnh = param_find("SENS_BARO_QNH");
63 
64  parameter_handles.air_cmodel = param_find("CAL_AIR_CMODEL");
65  parameter_handles.air_tube_length = param_find("CAL_AIR_TUBELEN");
66  parameter_handles.air_tube_diameter_mm = param_find("CAL_AIR_TUBED_MM");
67 
68  (void)param_find("BAT_V_DIV");
69  (void)param_find("BAT_A_PER_V");
70 
71  (void)param_find("CAL_ACC0_ID");
72  (void)param_find("CAL_GYRO0_ID");
73 
74  (void)param_find("CAL_MAG0_ID");
75  (void)param_find("CAL_MAG1_ID");
76  (void)param_find("CAL_MAG2_ID");
77  (void)param_find("CAL_MAG3_ID");
78  (void)param_find("CAL_MAG0_ROT");
79  (void)param_find("CAL_MAG1_ROT");
80  (void)param_find("CAL_MAG2_ROT");
81  (void)param_find("CAL_MAG3_ROT");
82  (void)param_find("CAL_MAG_SIDES");
83 
84  (void)param_find("SYS_PARAM_VER");
85  (void)param_find("SYS_AUTOSTART");
86  (void)param_find("SYS_AUTOCONFIG");
87  (void)param_find("TRIG_MODE");
88  (void)param_find("UAVCAN_ENABLE");
89 
90  // Parameters controlling the on-board sensor thermal calibrator
91  (void)param_find("SYS_CAL_TDEL");
92  (void)param_find("SYS_CAL_TMAX");
93  (void)param_find("SYS_CAL_TMIN");
94 }
95 
96 void update_parameters(const ParameterHandles &parameter_handles, Parameters &parameters)
97 {
98  /* Airspeed offset */
99  param_get(parameter_handles.diff_pres_offset_pa, &(parameters.diff_pres_offset_pa));
100 #ifdef ADC_AIRSPEED_VOLTAGE_CHANNEL
101  param_get(parameter_handles.diff_pres_analog_scale, &(parameters.diff_pres_analog_scale));
102 #endif /* ADC_AIRSPEED_VOLTAGE_CHANNEL */
103 
104  param_get(parameter_handles.board_rotation, &(parameters.board_rotation));
105 
106  param_get(parameter_handles.board_offset[0], &(parameters.board_offset[0]));
107  param_get(parameter_handles.board_offset[1], &(parameters.board_offset[1]));
108  param_get(parameter_handles.board_offset[2], &(parameters.board_offset[2]));
109 
110  param_get(parameter_handles.baro_qnh, &(parameters.baro_qnh));
111 
112  param_get(parameter_handles.air_cmodel, &parameters.air_cmodel);
113  param_get(parameter_handles.air_tube_length, &parameters.air_tube_length);
114  param_get(parameter_handles.air_tube_diameter_mm, &parameters.air_tube_diameter_mm);
115 }
116 
117 } /* namespace sensors */
void initialize_parameter_handles(ParameterHandles &parameter_handles)
initialize ParameterHandles struct
Definition: parameters.cpp:45
float air_tube_diameter_mm
Definition: parameters.h:63
int param_get(param_t param, void *val)
Copy the value of a parameter.
Definition: parameters.cpp:589
void update_parameters(const ParameterHandles &parameter_handles, Parameters &parameters)
Read out the parameters using the handles into the parameters struct.
Definition: parameters.cpp:96
float diff_pres_offset_pa
Definition: parameters.h:50
param_t param_find(const char *name)
Look up a parameter by name.
Definition: parameters.cpp:370
Definition: common.h:43
float board_offset[3]
Definition: parameters.h:57
int32_t board_rotation
Definition: parameters.h:55