Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AC_PrecLand/AC_PrecLand_Backend.h
9742 views
1
#pragma once
2
3
#include "AC_PrecLand_config.h"
4
5
#if AC_PRECLAND_ENABLED
6
7
#include "AC_PrecLand.h"
8
#include <AP_Math/AP_Math.h>
9
#include <AC_PID/AC_PID.h>
10
11
12
class AC_PrecLand_Backend
13
{
14
public:
15
// Constructor
16
AC_PrecLand_Backend(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state) :
17
_frontend(frontend),
18
_state(state) {}
19
20
// destructor
21
virtual ~AC_PrecLand_Backend() {}
22
23
// perform any required initialisation of backend
24
virtual void init() = 0;
25
26
// retrieve updates from sensor
27
virtual void update() = 0;
28
29
// provides a unit vector towards the target in body frame
30
// returns same as have_los_meas()
31
bool get_los_meas(Vector3f& vec_unit, AC_PrecLand::VectorFrame& frame) const {
32
if (!_los_meas.valid) {
33
return false;
34
}
35
vec_unit = _los_meas.vec_unit;
36
frame = _los_meas.frame;
37
return true;
38
};
39
40
// returns system time in milliseconds of last los measurement
41
uint32_t los_meas_time_ms() const { return _los_meas.time_ms; };
42
43
// returns distance to target in meters (0 means distance is not known)
44
float distance_to_target() const { return _distance_to_target; };
45
46
// parses a mavlink message from the companion computer
47
virtual void handle_msg(const mavlink_landing_target_t &packet, uint32_t timestamp_ms) {};
48
49
// get bus parameter
50
int8_t get_bus(void) const { return _frontend._bus.get(); }
51
52
protected:
53
const AC_PrecLand& _frontend; // reference to precision landing front end
54
AC_PrecLand::precland_state &_state; // reference to this instances state
55
56
struct {
57
Vector3f vec_unit; // unit vector pointing towards target in earth or body frame (see frame)
58
AC_PrecLand::VectorFrame frame; // frame of vector pointing towards target
59
uint32_t time_ms; // system time in milliseconds when the vector was measured
60
bool valid; // true if there is a valid measurement from the sensor
61
} _los_meas;
62
float _distance_to_target; // distance from the sensor to landing target in meters
63
};
64
65
#endif // AC_PRECLAND_ENABLED
66
67