CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AC_PrecLand/AC_PrecLand_Backend.h
Views: 1798
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_body(Vector3f& dir_body) {
32
if (have_los_meas()) {
33
dir_body = _los_meas_body;
34
return true;
35
}
36
return false;
37
};
38
39
// returns system time in milliseconds of last los measurement
40
uint32_t los_meas_time_ms() { return _los_meas_time_ms; };
41
42
// return true if there is a valid los measurement available
43
bool have_los_meas() { return _have_los_meas; };
44
45
// returns distance to target in meters (0 means distance is not known)
46
float distance_to_target() { return _distance_to_target; };
47
48
// parses a mavlink message from the companion computer
49
virtual void handle_msg(const mavlink_landing_target_t &packet, uint32_t timestamp_ms) {};
50
51
// get bus parameter
52
int8_t get_bus(void) const { return _frontend._bus.get(); }
53
54
protected:
55
const AC_PrecLand& _frontend; // reference to precision landing front end
56
AC_PrecLand::precland_state &_state; // reference to this instances state
57
58
Vector3f _los_meas_body; // unit vector in body frame pointing towards target
59
uint32_t _los_meas_time_ms; // system time in milliseconds when los was measured
60
bool _have_los_meas; // true if there is a valid measurement from the sensor
61
float _distance_to_target; // distance from the sensor to landing target in meters
62
};
63
64
#endif // AC_PRECLAND_ENABLED
65
66