Skip to content

Commit

Permalink
autom. trigger baro calib on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
haumarco committed Jan 15, 2025
1 parent 68b349b commit aeb2a1a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/modules/sensors/vehicle_air_data/VehicleAirData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <px4_platform_common/events.h>
#include <lib/geo/geo.h>
#include <lib/atmosphere/atmosphere.h>
#include <uORB/topics/vehicle_command.h>

namespace sensors
{
Expand Down Expand Up @@ -293,6 +294,26 @@ void VehicleAirData::Run()
}
}
}

if (!_calibration_done) {
// allow all drivers to start up
_calibration_delay = _calibration_delay == 0 ? time_now_us : _calibration_delay;

if (time_now_us - _calibration_delay > 1_s) {
_calibration_done = true;
uORB::Publication<vehicle_command_s> _vehicle_command_sub{ORB_ID(vehicle_command)};
vehicle_command_s vcmd{};
vcmd.command = vehicle_command_s::VEHICLE_CMD_PREFLIGHT_CALIBRATION;
vcmd.param1 = 0;
vcmd.param2 = 0;
vcmd.param3 = 1;
vcmd.param4 = 0;
vcmd.param5 = 0;
vcmd.param6 = 0;
vcmd.param7 = 0;
_vehicle_command_sub.publish(vcmd);
}
}
}

if (!parameter_update) {
Expand Down
3 changes: 3 additions & 0 deletions src/modules/sensors/vehicle_air_data/VehicleAirData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class VehicleAirData : public ModuleParams, public px4::ScheduledWorkItem

float _air_temperature_celsius{20.f}; // initialize with typical 20degC ambient temperature

bool _calibration_done{false};
uint64_t _calibration_delay{0};

DEFINE_PARAMETERS(
(ParamFloat<px4::params::SENS_BARO_QNH>) _param_sens_baro_qnh,
(ParamFloat<px4::params::SENS_BARO_RATE>) _param_sens_baro_rate
Expand Down

0 comments on commit aeb2a1a

Please sign in to comment.