2016-02-17 21:25:09 -04:00
|
|
|
#pragma once
|
2015-02-16 00:37:13 -04:00
|
|
|
|
2015-08-28 05:11:52 -03:00
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <AP_Math/AP_Math.h>
|
|
|
|
#include <AP_InertialNav/AP_InertialNav.h>
|
2016-06-16 14:10:48 -03:00
|
|
|
#include <GCS_MAVLink/GCS_MAVLink.h>
|
|
|
|
#include <stdint.h>
|
2016-07-15 14:30:21 -03:00
|
|
|
#include "PosVelEKF.h"
|
|
|
|
#include <AP_Buffer/AP_Buffer.h>
|
2015-02-16 00:37:13 -04:00
|
|
|
|
|
|
|
// declare backend classes
|
|
|
|
class AC_PrecLand_Backend;
|
|
|
|
class AC_PrecLand_Companion;
|
|
|
|
class AC_PrecLand_IRLock;
|
2016-11-10 07:41:17 -04:00
|
|
|
class AC_PrecLand_SITL_Gazebo;
|
2016-11-11 01:10:35 -04:00
|
|
|
class AC_PrecLand_SITL;
|
2015-02-16 00:37:13 -04:00
|
|
|
|
|
|
|
class AC_PrecLand
|
|
|
|
{
|
|
|
|
// declare backends as friends
|
|
|
|
friend class AC_PrecLand_Backend;
|
|
|
|
friend class AC_PrecLand_Companion;
|
|
|
|
friend class AC_PrecLand_IRLock;
|
2016-11-10 07:41:17 -04:00
|
|
|
friend class AC_PrecLand_SITL_Gazebo;
|
2016-11-11 01:10:35 -04:00
|
|
|
friend class AC_PrecLand_SITL;
|
2015-02-16 00:37:13 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// precision landing behaviours (held in PRECLAND_ENABLED parameter)
|
|
|
|
enum PrecLandBehaviour {
|
|
|
|
PRECLAND_BEHAVIOUR_DISABLED,
|
|
|
|
PRECLAND_BEHAVIOR_ALWAYSLAND,
|
|
|
|
PRECLAND_BEHAVIOR_CAUTIOUS
|
|
|
|
};
|
|
|
|
|
|
|
|
// types of precision landing (used for PRECLAND_TYPE parameter)
|
|
|
|
enum PrecLandType {
|
|
|
|
PRECLAND_TYPE_NONE = 0,
|
|
|
|
PRECLAND_TYPE_COMPANION,
|
2016-11-10 07:41:17 -04:00
|
|
|
PRECLAND_TYPE_IRLOCK,
|
|
|
|
PRECLAND_TYPE_SITL_GAZEBO,
|
2016-11-11 01:10:35 -04:00
|
|
|
PRECLAND_TYPE_SITL,
|
2015-02-16 00:37:13 -04:00
|
|
|
};
|
|
|
|
|
2016-06-16 14:10:48 -03:00
|
|
|
// constructor
|
2016-05-05 23:03:59 -03:00
|
|
|
AC_PrecLand(const AP_AHRS& ahrs, const AP_InertialNav& inav);
|
2015-02-16 00:37:13 -04:00
|
|
|
|
2016-06-16 14:10:48 -03:00
|
|
|
// perform any required initialisation of landing controllers
|
2015-02-16 00:37:13 -04:00
|
|
|
void init();
|
|
|
|
|
2016-06-16 14:10:48 -03:00
|
|
|
// returns true if precision landing is healthy
|
2016-07-15 14:30:21 -03:00
|
|
|
bool healthy() const { return _backend_state.healthy; }
|
2015-02-16 00:37:13 -04:00
|
|
|
|
2016-06-16 14:10:48 -03:00
|
|
|
// returns time of last update
|
2016-07-15 14:30:21 -03:00
|
|
|
uint32_t last_update_ms() const { return _last_update_ms; }
|
2016-06-16 14:10:48 -03:00
|
|
|
|
|
|
|
// give chance to driver to get updates from sensor
|
2016-07-15 14:30:21 -03:00
|
|
|
void update(float rangefinder_alt_cm, bool rangefinder_alt_valid);
|
2015-02-16 00:37:13 -04:00
|
|
|
|
2016-06-16 14:10:48 -03:00
|
|
|
// returns target position relative to origin
|
2016-07-15 14:30:21 -03:00
|
|
|
bool get_target_position_cm(Vector2f& ret) const;
|
2016-06-16 14:10:48 -03:00
|
|
|
|
|
|
|
// returns target position relative to vehicle
|
2016-07-15 14:30:21 -03:00
|
|
|
bool get_target_position_relative_cm(Vector2f& ret) const;
|
2016-06-16 14:10:48 -03:00
|
|
|
|
|
|
|
// returns target velocity relative to vehicle
|
2016-07-15 14:30:21 -03:00
|
|
|
bool get_target_velocity_relative_cms(Vector2f& ret) const;
|
2016-06-16 14:10:48 -03:00
|
|
|
|
|
|
|
// returns true when the landing target has been detected
|
2016-07-15 14:30:21 -03:00
|
|
|
bool target_acquired() const;
|
2016-06-16 14:10:48 -03:00
|
|
|
|
|
|
|
// process a LANDING_TARGET mavlink message
|
2015-09-11 08:00:18 -03:00
|
|
|
void handle_msg(mavlink_message_t* msg);
|
|
|
|
|
2015-02-16 00:37:13 -04:00
|
|
|
// accessors for logging
|
|
|
|
bool enabled() const { return _enabled; }
|
|
|
|
|
|
|
|
// parameter var table
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
|
|
|
private:
|
2016-06-16 14:10:48 -03:00
|
|
|
// returns enabled parameter as an behaviour
|
2015-02-16 00:37:13 -04:00
|
|
|
enum PrecLandBehaviour get_behaviour() const { return (enum PrecLandBehaviour)(_enabled.get()); }
|
|
|
|
|
|
|
|
// references to inertial nav and ahrs libraries
|
|
|
|
const AP_AHRS& _ahrs;
|
|
|
|
const AP_InertialNav& _inav;
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
AP_Int8 _enabled; // enabled/disabled and behaviour
|
|
|
|
AP_Int8 _type; // precision landing controller type
|
2016-07-15 14:30:21 -03:00
|
|
|
AP_Float _yaw_align; // Yaw angle from body x-axis to sensor x-axis.
|
|
|
|
AP_Float _land_ofs_cm_x; // Desired landing position of the camera forward of the target in vehicle body frame
|
|
|
|
AP_Float _land_ofs_cm_y; // Desired landing position of the camera right of the target in vehicle body frame
|
2015-02-16 00:37:13 -04:00
|
|
|
|
2016-06-16 14:10:48 -03:00
|
|
|
uint32_t _last_update_ms; // epoch time in millisecond when update is called
|
2016-07-05 16:37:17 -03:00
|
|
|
uint32_t _last_backend_los_meas_ms;
|
2016-06-16 14:10:48 -03:00
|
|
|
|
2016-07-15 14:30:21 -03:00
|
|
|
PosVelEKF _ekf_x, _ekf_y;
|
|
|
|
uint32_t _outlier_reject_count;
|
|
|
|
|
|
|
|
AP_Buffer<Matrix3f,8> _attitude_history;
|
2015-02-16 00:37:13 -04:00
|
|
|
|
|
|
|
// backend state
|
|
|
|
struct precland_state {
|
|
|
|
bool healthy;
|
|
|
|
} _backend_state;
|
|
|
|
AC_PrecLand_Backend *_backend; // pointers to backend precision landing driver
|
|
|
|
};
|