Skip to content

Commit ea9c64d

Browse files
committed
drivers/uavcan: add new UAVCAN_SUB_* parameters to enable subscriptions
- only GPS and mag are enabled by default
1 parent fd96bbf commit ea9c64d

File tree

3 files changed

+199
-25
lines changed

3 files changed

+199
-25
lines changed

src/drivers/uavcan/sensors/sensor_bridge.cpp

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,89 @@
5656
*/
5757
void IUavcanSensorBridge::make_all(uavcan::INode &node, List<IUavcanSensorBridge *> &list)
5858
{
59-
list.add(new UavcanBarometerBridge(node));
60-
list.add(new UavcanMagnetometerBridge(node));
61-
list.add(new UavcanGnssBridge(node));
62-
list.add(new UavcanFlowBridge(node));
59+
// airspeed
60+
int32_t uavcan_sub_aspd = 1;
61+
param_get(param_find("UAVCAN_SUB_ASPD"), &uavcan_sub_aspd);
6362

64-
int32_t bat_monitor;
65-
param_t _param_bat_monitor = param_find("UAVCAN_BAT_MON");
66-
param_get(_param_bat_monitor, &bat_monitor);
63+
if (uavcan_sub_aspd != 0) {
64+
list.add(new UavcanAirspeedBridge(node));
65+
}
66+
67+
// baro
68+
int32_t uavcan_sub_baro = 1;
69+
param_get(param_find("UAVCAN_SUB_BARO"), &uavcan_sub_baro);
70+
71+
if (uavcan_sub_baro != 0) {
72+
list.add(new UavcanBarometerBridge(node));
73+
}
6774

68-
if (bat_monitor == 0) {
75+
// battery
76+
int32_t uavcan_sub_bat = 1;
77+
param_get(param_find("UAVCAN_SUB_BAT"), &uavcan_sub_bat);
78+
79+
if (uavcan_sub_bat == 1) {
6980
list.add(new UavcanBatteryBridge(node));
7081

71-
} else if (bat_monitor == 1) {
82+
} else if (uavcan_sub_bat == 2) {
7283
list.add(new UavcanCBATBridge(node));
7384
}
7485

75-
list.add(new UavcanAirspeedBridge(node));
76-
list.add(new UavcanDifferentialPressureBridge(node));
77-
list.add(new UavcanRangefinderBridge(node));
78-
list.add(new UavcanAccelBridge(node));
79-
list.add(new UavcanGyroBridge(node));
80-
list.add(new UavcanIceStatusBridge(node));
86+
// differential pressure
87+
int32_t uavcan_sub_dpres = 1;
88+
param_get(param_find("UAVCAN_SUB_DPRES"), &uavcan_sub_dpres);
89+
90+
if (uavcan_sub_dpres != 0) {
91+
list.add(new UavcanDifferentialPressureBridge(node));
92+
}
93+
94+
// flow
95+
int32_t uavcan_sub_flow = 1;
96+
param_get(param_find("UAVCAN_SUB_FLOW"), &uavcan_sub_flow);
97+
98+
if (uavcan_sub_flow != 0) {
99+
list.add(new UavcanFlowBridge(node));
100+
}
101+
102+
// GPS
103+
int32_t uavcan_sub_gps = 1;
104+
param_get(param_find("UAVCAN_SUB_GPS"), &uavcan_sub_gps);
105+
106+
if (uavcan_sub_gps != 0) {
107+
list.add(new UavcanGnssBridge(node));
108+
}
109+
110+
// ice (internal combustion engine)
111+
int32_t uavcan_sub_ice = 1;
112+
param_get(param_find("UAVCAN_SUB_ICE"), &uavcan_sub_ice);
113+
114+
if (uavcan_sub_ice != 0) {
115+
list.add(new UavcanIceStatusBridge(node));
116+
}
117+
118+
// IMU
119+
int32_t uavcan_sub_imu = 1;
120+
param_get(param_find("UAVCAN_SUB_IMU"), &uavcan_sub_imu);
121+
122+
if (uavcan_sub_imu != 0) {
123+
list.add(new UavcanAccelBridge(node));
124+
list.add(new UavcanGyroBridge(node));
125+
}
126+
127+
// magnetometer
128+
int32_t uavcan_sub_mag = 1;
129+
param_get(param_find("UAVCAN_SUB_MAG"), &uavcan_sub_mag);
130+
131+
if (uavcan_sub_mag != 0) {
132+
list.add(new UavcanMagnetometerBridge(node));
133+
}
134+
135+
// range finder
136+
int32_t uavcan_sub_rng = 1;
137+
param_get(param_find("UAVCAN_SUB_RNG"), &uavcan_sub_rng);
138+
139+
if (uavcan_sub_rng != 0) {
140+
list.add(new UavcanRangefinderBridge(node));
141+
}
81142
}
82143

83144
/*

src/drivers/uavcan/sensors/sensor_bridge.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/****************************************************************************
22
*
3-
* Copyright (c) 2014, 2015 PX4 Development Team. All rights reserved.
3+
* Copyright (c) 2014-2021 PX4 Development Team. All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions

src/drivers/uavcan/uavcan_params.c

Lines changed: 122 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/****************************************************************************
22
*
3-
* Copyright (c) 2014-2017 PX4 Development Team. All rights reserved.
3+
* Copyright (c) 2014-2021 PX4 Development Team. All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions
@@ -195,18 +195,131 @@ PARAM_DEFINE_INT32(UAVCAN_LGT_NAV, 3);
195195
PARAM_DEFINE_INT32(UAVCAN_LGT_LAND, 0);
196196

197197
/**
198-
* UAVCAN BATTERY_MONITOR battery monitor selection
198+
* subscription airspeed
199199
*
200-
* This parameter defines that the system will select the battery monitor under the following conditions
200+
* Enable UAVCAN airspeed subscriptions.
201+
* uavcan::equipment::air_data::IndicatedAirspeed
202+
* uavcan::equipment::air_data::TrueAirspeed
203+
* uavcan::equipment::air_data::StaticTemperature
201204
*
202-
* 0 - default battery monitor
203-
* 1 - CUAV battery monitor
205+
* @boolean
206+
* @reboot_required true
207+
* @group UAVCAN
208+
*/
209+
PARAM_DEFINE_INT32(UAVCAN_SUB_ASPD, 0);
210+
211+
/**
212+
* subscription barometer
213+
*
214+
* Enable UAVCAN barometer subscription.
215+
* uavcan::equipment::air_data::StaticPressure
216+
* uavcan::equipment::air_data::StaticTemperature
217+
*
218+
* @boolean
219+
* @reboot_required true
220+
* @group UAVCAN
221+
*/
222+
PARAM_DEFINE_INT32(UAVCAN_SUB_BARO, 0);
223+
224+
/**
225+
* subscription battery
226+
*
227+
* Enable UAVCAN battery subscription.
228+
* 1) uavcan::equipment::power::BatteryInfo
229+
* 2) cuav::equipment::power::CBAT
204230
*
205231
* @min 0
206-
* @max 1
207-
* @value 0 default battery monitor
208-
* @value 1 CUAV battery monitor
232+
* @max 2
233+
* @value 0 disabled
234+
* @value 1 default
235+
* @value 2 CUAV battery monitor
236+
* @reboot_required true
237+
* @group UAVCAN
238+
*/
239+
PARAM_DEFINE_INT32(UAVCAN_SUB_BAT, 0);
240+
241+
/**
242+
* subscription differential pressure
243+
*
244+
* Enable UAVCAN differential pressure subscription.
245+
* uavcan::equipment::air_data::RawAirData
246+
*
247+
* @boolean
248+
* @reboot_required true
249+
* @group UAVCAN
250+
*/
251+
PARAM_DEFINE_INT32(UAVCAN_SUB_DPRES, 0);
252+
253+
/**
254+
* subscription flow
255+
*
256+
* Enable UAVCAN optical flow subscription.
257+
*
258+
* @boolean
259+
* @reboot_required true
260+
* @group UAVCAN
261+
*/
262+
PARAM_DEFINE_INT32(UAVCAN_SUB_FLOW, 0);
263+
264+
/**
265+
* subscription GPS
266+
*
267+
* Enable UAVCAN GPS subscriptions.
268+
* uavcan::equipment::gnss::Fix
269+
* uavcan::equipment::gnss::Fix2
270+
* uavcan::equipment::gnss::Auxiliary
271+
*
272+
* @boolean
273+
* @reboot_required true
274+
* @group UAVCAN
275+
*/
276+
PARAM_DEFINE_INT32(UAVCAN_SUB_GPS, 1);
277+
278+
/**
279+
* subscription ICE
280+
*
281+
* Enable UAVCAN internal combusion engine (ICE) subscription.
282+
* uavcan::equipment::ice::reciprocating::Status
283+
*
284+
* @boolean
285+
* @reboot_required true
286+
* @group UAVCAN
287+
*/
288+
PARAM_DEFINE_INT32(UAVCAN_SUB_ICE, 0);
289+
290+
/**
291+
* subscription IMU
292+
*
293+
* Enable UAVCAN IMU subscription.
294+
* uavcan::equipment::ahrs::RawIMU
295+
*
296+
* @boolean
297+
* @reboot_required true
298+
* @group UAVCAN
299+
*/
300+
PARAM_DEFINE_INT32(UAVCAN_SUB_IMU, 0);
301+
302+
/**
303+
* subscription magnetometer
304+
*
305+
* Enable UAVCAN GPS subscription.
306+
* uavcan::equipment::ahrs::MagneticFieldStrength
307+
* uavcan::equipment::ahrs::MagneticFieldStrength2
308+
*
309+
* @boolean
310+
* @reboot_required true
311+
* @group UAVCAN
312+
*/
313+
PARAM_DEFINE_INT32(UAVCAN_SUB_MAG, 1);
314+
315+
/**
316+
* subscription range finder
317+
*
318+
* Enable UAVCAN GPS subscription.
319+
* uavcan::equipment::range_sensor::Measurement
320+
*
321+
* @boolean
209322
* @reboot_required true
210323
* @group UAVCAN
211324
*/
212-
PARAM_DEFINE_INT32(UAVCAN_BAT_MON, 0);
325+
PARAM_DEFINE_INT32(UAVCAN_SUB_RNG, 0);

0 commit comments

Comments
 (0)