2016-02-17 21:25:09 -04:00
|
|
|
#pragma once
|
2015-02-16 00:37:13 -04:00
|
|
|
|
2023-03-22 05:45:41 -03:00
|
|
|
#include "AC_PrecLand_config.h"
|
|
|
|
|
|
|
|
#if AC_PRECLAND_ENABLED
|
|
|
|
|
|
|
|
#include "AC_PrecLand.h"
|
2015-08-28 05:11:52 -03:00
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
#include <AC_PID/AC_PID.h>
|
2023-03-22 05:45:41 -03:00
|
|
|
|
2015-02-16 00:37:13 -04:00
|
|
|
|
|
|
|
class AC_PrecLand_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
AC_PrecLand_Backend(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state) :
|
|
|
|
_frontend(frontend),
|
|
|
|
_state(state) {}
|
|
|
|
|
|
|
|
// destructor
|
|
|
|
virtual ~AC_PrecLand_Backend() {}
|
|
|
|
|
2016-07-05 16:37:17 -03:00
|
|
|
// perform any required initialisation of backend
|
2015-02-16 00:37:13 -04:00
|
|
|
virtual void init() = 0;
|
|
|
|
|
2016-07-05 16:37:17 -03:00
|
|
|
// retrieve updates from sensor
|
|
|
|
virtual void update() = 0;
|
|
|
|
|
|
|
|
// provides a unit vector towards the target in body frame
|
|
|
|
// returns same as have_los_meas()
|
2024-02-22 10:08:29 -04:00
|
|
|
bool get_los_body(Vector3f& dir_body) {
|
|
|
|
if (have_los_meas()) {
|
|
|
|
dir_body = _los_meas_body;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2017-02-03 03:01:03 -04:00
|
|
|
|
2016-07-05 16:37:17 -03:00
|
|
|
// returns system time in milliseconds of last los measurement
|
2024-02-22 10:08:29 -04:00
|
|
|
uint32_t los_meas_time_ms() { return _los_meas_time_ms; };
|
2017-02-03 03:01:03 -04:00
|
|
|
|
2016-07-05 16:37:17 -03:00
|
|
|
// return true if there is a valid los measurement available
|
2024-02-22 10:08:29 -04:00
|
|
|
bool have_los_meas() { return _have_los_meas; };
|
2017-02-03 03:03:02 -04:00
|
|
|
|
|
|
|
// returns distance to target in meters (0 means distance is not known)
|
2024-02-22 10:08:29 -04:00
|
|
|
float distance_to_target() { return _distance_to_target; };
|
2017-01-27 07:02:39 -04:00
|
|
|
|
2016-07-05 16:37:17 -03:00
|
|
|
// parses a mavlink message from the companion computer
|
2021-04-12 23:49:59 -03:00
|
|
|
virtual void handle_msg(const mavlink_landing_target_t &packet, uint32_t timestamp_ms) {};
|
2015-09-11 08:00:18 -03:00
|
|
|
|
2017-04-11 21:19:21 -03:00
|
|
|
// get bus parameter
|
|
|
|
int8_t get_bus(void) const { return _frontend._bus.get(); }
|
|
|
|
|
2015-02-16 00:37:13 -04:00
|
|
|
protected:
|
|
|
|
const AC_PrecLand& _frontend; // reference to precision landing front end
|
|
|
|
AC_PrecLand::precland_state &_state; // reference to this instances state
|
2024-02-22 10:08:29 -04:00
|
|
|
|
|
|
|
Vector3f _los_meas_body; // unit vector in body frame pointing towards target
|
|
|
|
uint32_t _los_meas_time_ms; // system time in milliseconds when los was measured
|
|
|
|
bool _have_los_meas; // true if there is a valid measurement from the sensor
|
|
|
|
float _distance_to_target; // distance from the sensor to landing target in meters
|
2015-02-16 00:37:13 -04:00
|
|
|
};
|
2023-03-22 05:45:41 -03:00
|
|
|
|
|
|
|
#endif // AC_PRECLAND_ENABLED
|