Path: blob/master/libraries/AC_PrecLand/AC_PrecLand_IRLock.cpp
9552 views
#include "AC_PrecLand_config.h"12#if AC_PRECLAND_IRLOCK_ENABLED34#include "AC_PrecLand_IRLock.h"5#include <AP_HAL/AP_HAL.h>67// Constructor8AC_PrecLand_IRLock::AC_PrecLand_IRLock(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state)9: AC_PrecLand_Backend(frontend, state),10irlock()11{12}1314// init - perform initialisation of this backend15void AC_PrecLand_IRLock::init()16{17irlock.init(get_bus());18}1920// update - give chance to driver to get updates from sensor21void AC_PrecLand_IRLock::update()22{23// update health24_state.healthy = irlock.healthy();2526// get new sensor data27irlock.update();2829if (irlock.num_targets() > 0 && irlock.last_update_ms() != _los_meas.time_ms) {30irlock.get_unit_vector_body(_los_meas.vec_unit);31_los_meas.frame = AC_PrecLand::VectorFrame::BODY_FRD;32_los_meas.valid = true;33_los_meas.time_ms = irlock.last_update_ms();34}35_los_meas.valid = _los_meas.valid && AP_HAL::millis() - _los_meas.time_ms <= 1000;36}3738#endif // AC_PRECLAND_IRLOCK_ENABLED394041