2013-06-26 07:47:04 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
|
2016-02-17 21:25:50 -04:00
|
|
|
#pragma once
|
2013-06-26 07:47:04 -03:00
|
|
|
|
|
|
|
/// @file AP_SpdHgtControl.h
|
|
|
|
/// @brief generic speed & height controller interface
|
|
|
|
|
|
|
|
/*
|
|
|
|
This defines a generic interface for speed & height controllers. Each
|
|
|
|
specific controller should be a subclass of this generic
|
|
|
|
interface. All variables used by controllers should be in their
|
|
|
|
own class.
|
|
|
|
*/
|
|
|
|
|
2015-08-11 03:28:45 -03:00
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
#include <DataFlash/DataFlash.h>
|
2013-06-26 07:47:04 -03:00
|
|
|
|
|
|
|
class AP_SpdHgtControl {
|
|
|
|
public:
|
|
|
|
// Update the internal state of the height and height rate estimator
|
|
|
|
// Update of the inertial speed rate estimate internal state
|
|
|
|
// Should be called at 50Hz or faster
|
2013-07-08 20:04:48 -03:00
|
|
|
virtual void update_50hz(float height_above_field) = 0;
|
2013-06-26 07:47:04 -03:00
|
|
|
|
2013-10-11 23:12:16 -03:00
|
|
|
/**
|
|
|
|
stages of flight so the altitude controller can choose to
|
|
|
|
prioritise height or speed
|
|
|
|
*/
|
|
|
|
enum FlightStage {
|
2016-01-30 01:58:50 -04:00
|
|
|
FLIGHT_TAKEOFF = 1,
|
|
|
|
FLIGHT_VTOL = 2,
|
|
|
|
FLIGHT_NORMAL = 3,
|
2016-01-01 02:36:18 -04:00
|
|
|
FLIGHT_LAND_APPROACH = 4,
|
2016-01-30 01:58:50 -04:00
|
|
|
FLIGHT_LAND_PREFLARE = 5,
|
|
|
|
FLIGHT_LAND_FINAL = 6,
|
|
|
|
FLIGHT_LAND_ABORT = 7
|
2013-10-11 23:12:16 -03:00
|
|
|
};
|
|
|
|
|
2013-06-26 07:47:04 -03:00
|
|
|
// Update of the pitch and throttle demands
|
|
|
|
// Should be called at 10Hz or faster
|
2013-07-09 07:50:37 -03:00
|
|
|
virtual void update_pitch_throttle( int32_t hgt_dem_cm,
|
|
|
|
int32_t EAS_dem_cm,
|
2013-10-11 23:12:16 -03:00
|
|
|
enum FlightStage flight_stage,
|
2016-02-12 14:59:35 -04:00
|
|
|
bool is_doing_auto_land,
|
2016-02-12 15:39:12 -04:00
|
|
|
float distance_beyond_land_wp,
|
2013-07-09 07:50:37 -03:00
|
|
|
int32_t ptchMinCO_cd,
|
2013-07-10 00:32:13 -03:00
|
|
|
int16_t throttle_nudge,
|
2014-11-11 22:33:14 -04:00
|
|
|
float hgt_afe,
|
|
|
|
float load_factor) = 0;
|
2013-06-26 07:47:04 -03:00
|
|
|
|
|
|
|
// demanded throttle in percentage
|
|
|
|
// should return 0 to 100
|
|
|
|
virtual int32_t get_throttle_demand(void)=0;
|
|
|
|
|
|
|
|
// demanded pitch angle in centi-degrees
|
|
|
|
// should return -9000 to +9000
|
|
|
|
virtual int32_t get_pitch_demand(void)=0;
|
|
|
|
|
|
|
|
// Rate of change of velocity along X body axis in m/s^2
|
|
|
|
virtual float get_VXdot(void)=0;
|
|
|
|
|
|
|
|
// log data on internal state of the controller. Called at 10Hz
|
|
|
|
virtual void log_data(DataFlash_Class &dataflash, uint8_t msgid) = 0;
|
|
|
|
|
2014-03-19 17:57:01 -03:00
|
|
|
// return current target airspeed
|
|
|
|
virtual float get_target_airspeed(void) const = 0;
|
|
|
|
|
2014-08-06 20:29:40 -03:00
|
|
|
// return maximum climb rate
|
|
|
|
virtual float get_max_climbrate(void) const = 0;
|
|
|
|
|
2014-12-15 06:44:03 -04:00
|
|
|
// return landing sink rate
|
|
|
|
virtual float get_land_sinkrate(void) const = 0;
|
|
|
|
|
2016-01-08 20:01:02 -04:00
|
|
|
// set path_proportion accessor
|
|
|
|
virtual void set_path_proportion(float path_proportion) = 0;
|
|
|
|
|
2013-06-26 07:47:04 -03:00
|
|
|
// add new controllers to this enum. Users can then
|
|
|
|
// select which controller to use by setting the
|
|
|
|
// SPDHGT_CONTROLLER parameter
|
|
|
|
enum ControllerType {
|
|
|
|
CONTROLLER_TECS = 1
|
|
|
|
};
|
2013-10-11 23:12:16 -03:00
|
|
|
|
2013-06-26 07:47:04 -03:00
|
|
|
|
|
|
|
};
|