Line data Source code
1 :
2 : /*
3 : This program is free software: you can redistribute it and/or modify
4 : it under the terms of the GNU General Public License as published by
5 : the Free Software Foundation, either version 3 of the License, or
6 : (at your option) any later version.
7 :
8 : This program is distributed in the hope that it will be useful,
9 : but WITHOUT ANY WARRANTY; without even the implied warranty of
10 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 : GNU General Public License for more details.
12 :
13 : You should have received a copy of the GNU General Public License
14 : along with this program. If not, see <http://www.gnu.org/licenses/>.
15 : */
16 :
17 : #include "AP_Airspeed_config.h"
18 :
19 : #if AP_AIRSPEED_ENABLED
20 :
21 : #include "AP_Airspeed.h"
22 :
23 : #include <AP_Vehicle/AP_Vehicle_Type.h>
24 :
25 : // Dummy the AP_Airspeed class to allow building Airspeed only for plane, rover, sub, and copter & heli 2MB boards
26 : // This could be removed once the build system allows for APM_BUILD_TYPE in header files
27 : // note that this is re-definition of the one in AP_Airspeed.cpp, can't be shared as vehicle dependences cant go in header files
28 : #ifndef AP_AIRSPEED_DUMMY_METHODS_ENABLED
29 : #define AP_AIRSPEED_DUMMY_METHODS_ENABLED ((APM_BUILD_COPTER_OR_HELI && HAL_PROGRAM_SIZE_LIMIT_KB <= 1024) || \
30 : APM_BUILD_TYPE(APM_BUILD_AntennaTracker) || APM_BUILD_TYPE(APM_BUILD_Blimp))
31 : #endif
32 :
33 : #if !AP_AIRSPEED_DUMMY_METHODS_ENABLED
34 :
35 : #ifndef PSI_RANGE_DEFAULT
36 : #define PSI_RANGE_DEFAULT 1.0f
37 : #endif
38 :
39 : // table of user settable parameters
40 : const AP_Param::GroupInfo AP_Airspeed_Params::var_info[] = {
41 :
42 : // @Param: TYPE
43 : // @DisplayName: Airspeed type
44 : // @Description: Type of airspeed sensor
45 : // @Values: 0:None,1:I2C-MS4525D0,2:Analog,3:I2C-MS5525,4:I2C-MS5525 (0x76),5:I2C-MS5525 (0x77),6:I2C-SDP3X,7:I2C-DLVR-5in,8:DroneCAN,9:I2C-DLVR-10in,10:I2C-DLVR-20in,11:I2C-DLVR-30in,12:I2C-DLVR-60in,13:NMEA water speed,14:MSP,15:ASP5033,16:ExternalAHRS,17:AUAV-10in,18:AUAV-5in,19:AUAV-30in,20:Scripting,100:SITL
46 : // @RebootRequired: True
47 : // @User: Standard
48 : AP_GROUPINFO_FLAGS("TYPE", 1, AP_Airspeed_Params, type, 0, AP_PARAM_FLAG_ENABLE),
49 :
50 : #ifndef HAL_BUILD_AP_PERIPH
51 : // @Param: USE
52 : // @DisplayName: Airspeed use
53 : // @Description: Enables airspeed use for automatic throttle modes and replaces control from THR_TRIM. Continues to display and log airspeed if set to 0. Uses airspeed for control if set to 1. Only uses airspeed when throttle = 0 if set to 2 (useful for gliders with airspeed sensors behind propellers).
54 : // @Description{Copter, Blimp, Rover, Sub}: This parameter is not used by this vehicle. Always set to 0.
55 : // @Values: 0:DoNotUse,1:Use,2:UseWhenZeroThrottle
56 : // @User: Standard
57 : AP_GROUPINFO("USE", 2, AP_Airspeed_Params, use, 0),
58 :
59 : // @Param: OFFSET
60 : // @DisplayName: Airspeed offset
61 : // @Description: Airspeed calibration offset
62 : // @Increment: 0.1
63 : // @User: Advanced
64 : AP_GROUPINFO("OFFSET", 3, AP_Airspeed_Params, offset, 0),
65 :
66 : // @Param: RATIO
67 : // @DisplayName: Airspeed ratio
68 : // @Description: Calibrates pitot tube pressure to velocity. Increasing this value will indicate a higher airspeed at any given dynamic pressure.
69 : // @Increment: 0.1
70 : // @User: Advanced
71 : AP_GROUPINFO("RATIO", 4, AP_Airspeed_Params, ratio, 2),
72 :
73 : // @Param: PIN
74 : // @DisplayName: Airspeed pin
75 : // @Description: The pin number that the airspeed sensor is connected to for analog sensors. Values for some autopilots are given as examples. Search wiki for "Analog pins".
76 : // @Values: -1:Disabled, 2:Pixhawk/Pixracer/Navio2/Pixhawk2_PM1, 5:Navigator, 13:Pixhawk2_PM2/CubeOrange_PM2, 14:CubeOrange, 16:Durandal, 100:PX4-v1
77 : // @Range: -1 127
78 : // @User: Advanced
79 : AP_GROUPINFO("PIN", 5, AP_Airspeed_Params, pin, 0),
80 : #endif // HAL_BUILD_AP_PERIPH
81 :
82 : #if AP_AIRSPEED_AUTOCAL_ENABLE
83 : // @Param: AUTOCAL
84 : // @DisplayName: Automatic airspeed ratio calibration
85 : // @DisplayName{Copter, Blimp, Rover, Sub}: This parameter and function is not used by this vehicle. Always set to 0.
86 : // @Description: Enables automatic adjustment of airspeed ratio during a calibration flight based on estimation of ground speed and true airspeed. New ratio saved every 2 minutes if change is > 5%. Should not be left enabled.
87 : // @User: Advanced
88 : AP_GROUPINFO("AUTOCAL", 6, AP_Airspeed_Params, autocal, 0),
89 : #endif
90 :
91 : #ifndef HAL_BUILD_AP_PERIPH
92 : // @Param: TUBE_ORDR
93 : // @DisplayName: Control pitot tube order
94 : // @Description: This parameter allows you to control whether the order in which the tubes are attached to your pitot tube matters. If you set this to 0 then the first (often the top) connector on the sensor needs to be the stagnation pressure (the pressure at the tip of the pitot tube). If set to 1 then the second (often the bottom) connector needs to be the stagnation pressure. If set to 2 (the default) then the airspeed driver will accept either order. The reason you may wish to specify the order is it will allow your airspeed sensor to detect if the aircraft is receiving excessive pressure on the static port compared to the stagnation port such as during a stall, which would otherwise be seen as a positive airspeed.
95 : // @User: Advanced
96 : // @Values: 0:Normal,1:Swapped,2:Auto Detect
97 : AP_GROUPINFO("TUBE_ORDR", 7, AP_Airspeed_Params, tube_order, 2),
98 :
99 : // @Param: SKIP_CAL
100 : // @DisplayName: Skip airspeed offset calibration on startup
101 : // @Description: This parameter allows you to skip airspeed offset calibration on startup, instead using the offset from the last calibration or requiring a manual calibration. This may be desirable if the offset variance between flights for your sensor is low and you want to avoid having to cover the pitot tube on each boot.
102 : // @Values: 0:Disable
103 : // @Values: 1:Do not require offset calibration before flight. Manual calibration should be performed during initial setup.
104 : // @Values: 2:Do not calibrate on start up. Manual calibration must be performed once per boot.
105 : // @User: Advanced
106 : AP_GROUPINFO("SKIP_CAL", 8, AP_Airspeed_Params, skip_cal, 0),
107 : #endif // HAL_BUILD_AP_PERIPH
108 :
109 : // @Param: PSI_RANGE
110 : // @DisplayName: The PSI range of the device
111 : // @Description: This parameter allows you to set the PSI (pounds per square inch) range for your sensor. You should not change this unless you examine the datasheet for your device
112 : // @User: Advanced
113 : AP_GROUPINFO("PSI_RANGE", 9, AP_Airspeed_Params, psi_range, PSI_RANGE_DEFAULT),
114 :
115 : #ifndef HAL_BUILD_AP_PERIPH
116 : // @Param: BUS
117 : // @DisplayName: Airspeed I2C bus
118 : // @Description: Bus number of the I2C bus where the airspeed sensor is connected. May not correspond to board's I2C bus number labels. Retry another bus and reboot if airspeed sensor fails to initialize.
119 : // @Values: 0:Bus0,1:Bus1,2:Bus2,3:Bus3
120 : // @RebootRequired: True
121 : // @User: Advanced
122 : AP_GROUPINFO("BUS", 10, AP_Airspeed_Params, bus, 1),
123 : #endif // HAL_BUILD_AP_PERIPH
124 :
125 : // @Param: DEVID
126 : // @DisplayName: Airspeed ID
127 : // @Description: Airspeed sensor ID, taking into account its type, bus and instance
128 : // @ReadOnly: True
129 : // @User: Advanced
130 : AP_GROUPINFO_FLAGS("DEVID", 11, AP_Airspeed_Params, bus_id, 0, AP_PARAM_FLAG_INTERNAL_USE_ONLY),
131 :
132 : AP_GROUPEND
133 : };
134 :
135 4130 : AP_Airspeed_Params::AP_Airspeed_Params(void)
136 : {
137 4130 : AP_Param::setup_object_defaults(this, var_info);
138 4130 : }
139 :
140 : #else // dummy implementation:
141 :
142 66 : AP_Airspeed_Params::AP_Airspeed_Params(void) {};
143 : const AP_Param::GroupInfo AP_Airspeed_Params::var_info[] = { AP_GROUPEND };
144 :
145 : #endif
146 :
147 : #endif // AP_AIRSPEED_ENABLED
|