From 32c6ec061e46785b9913ae22409fd41f537987da Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Wed, 20 Jul 2022 00:57:14 -0400 Subject: [PATCH] sensors: add kconfig options to skip angular velocity and acceleration --- src/modules/sensors/CMakeLists.txt | 24 +++++++++++++++++------ src/modules/sensors/Kconfig | 8 ++++++++ src/modules/sensors/sensors.cpp | 31 +++++++++++++++++++++++++++--- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/modules/sensors/CMakeLists.txt b/src/modules/sensors/CMakeLists.txt index 9af0ab04cb..1f84dec4db 100644 --- a/src/modules/sensors/CMakeLists.txt +++ b/src/modules/sensors/CMakeLists.txt @@ -35,14 +35,20 @@ add_subdirectory(data_validator) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_subdirectory(vehicle_acceleration) -add_subdirectory(vehicle_angular_velocity) +if(CONFIG_SENSORS_VEHICLE_ACCELERATION) + add_subdirectory(vehicle_acceleration) +endif() + add_subdirectory(vehicle_imu) if(CONFIG_SENSORS_VEHICLE_AIR_DATA) add_subdirectory(vehicle_air_data) endif() +if(CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY) + add_subdirectory(vehicle_angular_velocity) +endif() + if(CONFIG_SENSORS_VEHICLE_GPS_POSITION) add_subdirectory(vehicle_gps_position) endif() @@ -72,17 +78,23 @@ px4_add_module( data_validator mathlib sensor_calibration - vehicle_acceleration - vehicle_angular_velocity vehicle_imu ) +if(CONFIG_SENSORS_VEHICLE_ACCELERATION) + target_link_libraries(modules__sensors PRIVATE vehicle_acceleration) +endif() + +if(CONFIG_SENSORS_VEHICLE_AIR_DATA) + target_link_libraries(modules__sensors PRIVATE vehicle_air_data) +endif() + if(CONFIG_SENSORS_VEHICLE_AIRSPEED) target_link_libraries(modules__sensors PRIVATE airspeed) endif() -if(CONFIG_SENSORS_VEHICLE_AIR_DATA) - target_link_libraries(modules__sensors PRIVATE vehicle_air_data) +if(CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY) + target_link_libraries(modules__sensors PRIVATE vehicle_angular_velocity) endif() if(CONFIG_SENSORS_VEHICLE_GPS_POSITION) diff --git a/src/modules/sensors/Kconfig b/src/modules/sensors/Kconfig index 163ac29506..9319e80633 100644 --- a/src/modules/sensors/Kconfig +++ b/src/modules/sensors/Kconfig @@ -20,6 +20,14 @@ if MODULES_SENSORS bool "Include vehicle air data" default y + config SENSORS_VEHICLE_ANGULAR_VELOCITY + bool "Include vehicle angular velocity" + default y + + config SENSORS_VEHICLE_ACCELERATION + bool "Include vehicle acceleration" + default y + config SENSORS_VEHICLE_GPS_POSITION bool "Include vehicle gps position" default y diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index 840d722597..ae7f718bb8 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -65,10 +65,12 @@ #include #include "voted_sensors_update.h" -#include "vehicle_acceleration/VehicleAcceleration.hpp" -#include "vehicle_angular_velocity/VehicleAngularVelocity.hpp" #include "vehicle_imu/VehicleIMU.hpp" +#if defined(CONFIG_SENSORS_VEHICLE_ACCELERATION) +# include "vehicle_acceleration/VehicleAcceleration.hpp" +#endif // CONFIG_SENSORS_VEHICLE_ACCELERATION + #if defined(CONFIG_SENSORS_VEHICLE_AIRSPEED) # include # include @@ -83,6 +85,10 @@ # include "vehicle_air_data/VehicleAirData.hpp" #endif // CONFIG_SENSORS_VEHICLE_AIR_DATA +#if defined(CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY) +# include "vehicle_angular_velocity/VehicleAngularVelocity.hpp" +#endif // CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY + #if defined(CONFIG_SENSORS_VEHICLE_GPS_POSITION) # include "vehicle_gps_position/VehicleGPSPosition.hpp" #endif // CONFIG_SENSORS_VEHICLE_GPS_POSITION @@ -196,8 +202,13 @@ private: VotedSensorsUpdate _voted_sensors_update; - VehicleAcceleration _vehicle_acceleration; +#if defined(CONFIG_SENSORS_VEHICLE_ACCELERATION) + VehicleAcceleration _vehicle_acceleration; +#endif // CONFIG_SENSORS_VEHICLE_ACCELERATION + +#if defined(CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY) VehicleAngularVelocity _vehicle_angular_velocity; +#endif // CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY #if defined(CONFIG_SENSORS_VEHICLE_AIR_DATA) VehicleAirData *_vehicle_air_data {nullptr}; @@ -276,8 +287,13 @@ Sensors::Sensors(bool hil_enabled) : { _sensor_pub.advertise(); +#if defined(CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY) _vehicle_angular_velocity.Start(); +#endif // CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY + +#if defined(CONFIG_SENSORS_VEHICLE_ACCELERATION) _vehicle_acceleration.Start(); +#endif // CONFIG_SENSORS_VEHICLE_ACCELERATION #if defined(CONFIG_SENSORS_VEHICLE_AIRSPEED) /* Differential pressure offset */ @@ -315,8 +331,13 @@ Sensors::~Sensors() sub.unregisterCallback(); } +#if defined(CONFIG_SENSORS_VEHICLE_ACCELERATION) _vehicle_acceleration.Stop(); +#endif // CONFIG_SENSORS_VEHICLE_ACCELERATION + +#if defined(CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY) _vehicle_angular_velocity.Stop(); +#endif // CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY #if defined(CONFIG_SENSORS_VEHICLE_AIR_DATA) @@ -936,11 +957,15 @@ int Sensors::print_status() #endif // CONFIG_SENSORS_VEHICLE_OPTICAL_FLOW +#if defined(CONFIG_SENSORS_VEHICLE_ACCELERATION) PX4_INFO_RAW("\n"); _vehicle_acceleration.PrintStatus(); +#endif // CONFIG_SENSORS_VEHICLE_ACCELERATION +#if defined(CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY) PX4_INFO_RAW("\n"); _vehicle_angular_velocity.PrintStatus(); +#endif // CONFIG_SENSORS_VEHICLE_ANGULAR_VELOCITY #if defined(CONFIG_SENSORS_VEHICLE_GPS_POSITION)