sensors: add kconfig options to skip angular velocity and acceleration

This commit is contained in:
Daniel Agar 2022-07-20 00:57:14 -04:00
parent c9c62b860c
commit 32c6ec061e
3 changed files with 54 additions and 9 deletions

View File

@ -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)

View File

@ -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

View File

@ -65,10 +65,12 @@
#include <uORB/topics/vehicle_imu.h>
#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 <drivers/drv_sensor.h>
# include <drivers/drv_adc.h>
@ -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)