Browse Source

system_params: add SYS_HAS_MAG and SYS_HAS_BARO params

This allows to use PX4 on systems that do not have a mag or a baro,
such as the Omnibus F4 SD.
sbg
Beat Küng 7 years ago committed by Lorenz Meier
parent
commit
f2516bbf5f
  1. 8
      src/modules/commander/PreflightCheck.cpp
  2. 3
      src/modules/sensors/parameters.cpp
  3. 29
      src/modules/systemlib/system_params.c

8
src/modules/commander/PreflightCheck.cpp

@ -712,12 +712,14 @@ bool preflightCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &statu @@ -712,12 +712,14 @@ bool preflightCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &statu
bool prime_found = false;
int32_t prime_id = 0;
param_get(param_find("CAL_MAG_PRIME"), &prime_id);
int32_t sys_has_mag = 1;
param_get(param_find("SYS_HAS_MAG"), &sys_has_mag);
bool mag_fail_reported = false;
/* check all sensors, but fail only for mandatory ones */
for (unsigned i = 0; i < max_optional_mag_count; i++) {
bool required = (i < max_mandatory_mag_count);
bool required = (i < max_mandatory_mag_count) && sys_has_mag == 1;
int device_id = -1;
if (!magnometerCheck(mavlink_log_pub, i, !required, device_id, (reportFailures && !failed && !mag_fail_reported)) && required) {
@ -816,12 +818,14 @@ bool preflightCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &statu @@ -816,12 +818,14 @@ bool preflightCheck(orb_advert_t *mavlink_log_pub, const vehicle_status_s &statu
bool prime_found = false;
int32_t prime_id = 0;
param_get(param_find("CAL_BARO_PRIME"), &prime_id);
int32_t sys_has_baro = 1;
param_get(param_find("SYS_HAS_BARO"), &sys_has_baro);
bool baro_fail_reported = false;
/* check all sensors, but fail only for mandatory ones */
for (unsigned i = 0; i < max_optional_baro_count; i++) {
bool required = (i < max_mandatory_baro_count);
bool required = (i < max_mandatory_baro_count) && sys_has_baro == 1;
int device_id = -1;
if (!baroCheck(mavlink_log_pub, i, !required, device_id, (reportFailures && !failed && !baro_fail_reported)) && required) {

3
src/modules/sensors/parameters.cpp

@ -188,6 +188,9 @@ void initialize_parameter_handles(ParameterHandles &parameter_handles) @@ -188,6 +188,9 @@ void initialize_parameter_handles(ParameterHandles &parameter_handles)
(void)param_find("SYS_CAL_TDEL");
(void)param_find("SYS_CAL_TMAX");
(void)param_find("SYS_CAL_TMIN");
(void)param_find("SYS_HAS_MAG");
(void)param_find("SYS_HAS_BARO");
}
int update_parameters(const ParameterHandles &parameter_handles, Parameters &parameters)

29
src/modules/systemlib/system_params.c

@ -248,3 +248,32 @@ PARAM_DEFINE_INT32(SYS_CAL_TMIN, 5); @@ -248,3 +248,32 @@ PARAM_DEFINE_INT32(SYS_CAL_TMIN, 5);
* @group System
*/
PARAM_DEFINE_INT32(SYS_CAL_TMAX, 10);
/**
* Control if the vehicle has a magnetometer
*
* Disable this if the board has no magnetometer, such as the Omnibus F4 SD.
* If disabled, the preflight checks will not check for the presence of a
* magnetometer.
*
* @boolean
* @reboot_required true
*
* @group System
*/
PARAM_DEFINE_INT32(SYS_HAS_MAG, 1);
/**
* Control if the vehicle has a barometer
*
* Disable this if the board has no barometer, such as some of the the Omnibus
* F4 SD variants.
* If disabled, the preflight checks will not check for the presence of a
* barometer.
*
* @boolean
* @reboot_required true
*
* @group System
*/
PARAM_DEFINE_INT32(SYS_HAS_BARO, 1);

Loading…
Cancel
Save