2015-11-24 04:24:04 -04:00
|
|
|
#include <AP_Motors/AP_Motors.h>
|
|
|
|
#include <AC_PID/AC_PID.h>
|
|
|
|
#include <AC_AttitudeControl/AC_AttitudeControl_Multi.h> // Attitude control library
|
|
|
|
#include <AP_InertialNav/AP_InertialNav.h>
|
|
|
|
#include <AC_AttitudeControl/AC_PosControl.h>
|
2015-12-26 04:51:05 -04:00
|
|
|
#include <AC_WPNav/AC_WPNav.h>
|
2018-03-27 23:24:05 -03:00
|
|
|
#include <AC_WPNav/AC_Loiter.h>
|
2016-06-20 02:33:47 -03:00
|
|
|
#include <AC_Fence/AC_Fence.h>
|
|
|
|
#include <AC_Avoidance/AC_Avoid.h>
|
2016-08-16 09:21:50 -03:00
|
|
|
#include <AP_Proximity/AP_Proximity.h>
|
2015-11-24 04:24:04 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
QuadPlane specific functionality
|
|
|
|
*/
|
|
|
|
class QuadPlane
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
friend class Plane;
|
2016-05-06 01:43:39 -03:00
|
|
|
friend class AP_Tuning_Plane;
|
2016-08-11 00:19:00 -03:00
|
|
|
friend class GCS_MAVLINK_Plane;
|
2016-07-22 05:36:28 -03:00
|
|
|
friend class AP_AdvancedFailsafe_Plane;
|
2016-05-06 01:43:39 -03:00
|
|
|
|
2015-11-24 04:24:04 -04:00
|
|
|
QuadPlane(AP_AHRS_NavEKF &_ahrs);
|
|
|
|
|
|
|
|
// var_info for holding Parameter information
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
2017-11-05 05:44:42 -04:00
|
|
|
static const struct AP_Param::GroupInfo var_info2[];
|
2015-11-24 04:24:04 -04:00
|
|
|
|
2015-12-26 06:40:40 -04:00
|
|
|
void control_run(void);
|
|
|
|
void control_auto(const Location &loc);
|
|
|
|
bool init_mode(void);
|
2016-01-06 03:17:08 -04:00
|
|
|
bool setup(void);
|
2016-04-28 23:53:20 -03:00
|
|
|
|
2016-05-05 19:27:47 -03:00
|
|
|
void vtol_position_controller(void);
|
2016-04-28 23:53:20 -03:00
|
|
|
void setup_target_position(void);
|
|
|
|
void takeoff_controller(void);
|
|
|
|
void waypoint_controller(void);
|
2015-11-24 04:24:04 -04:00
|
|
|
|
|
|
|
// update transition handling
|
|
|
|
void update(void);
|
|
|
|
|
|
|
|
// set motor arming
|
|
|
|
void set_armed(bool armed);
|
2015-12-26 06:40:40 -04:00
|
|
|
|
|
|
|
// is VTOL available?
|
|
|
|
bool available(void) const {
|
|
|
|
return initialised;
|
|
|
|
}
|
|
|
|
|
2016-01-01 02:36:41 -04:00
|
|
|
// is quadplane assisting?
|
|
|
|
bool in_assisted_flight(void) const {
|
|
|
|
return available() && assisted_flight;
|
|
|
|
}
|
2017-10-29 03:31:09 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
return true if we are in a transition to fwd flight from hover
|
|
|
|
*/
|
|
|
|
bool in_transition(void) const;
|
2017-10-30 01:19:38 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
return true if we are a tailsitter transitioning to VTOL flight
|
|
|
|
*/
|
|
|
|
bool in_tailsitter_vtol_transition(void) const;
|
2016-01-01 02:36:41 -04:00
|
|
|
|
2016-04-22 05:22:31 -03:00
|
|
|
bool handle_do_vtol_transition(enum MAV_VTOL_STATE state);
|
2015-12-26 06:40:40 -04:00
|
|
|
|
2016-01-01 05:42:10 -04:00
|
|
|
bool do_vtol_takeoff(const AP_Mission::Mission_Command& cmd);
|
|
|
|
bool do_vtol_land(const AP_Mission::Mission_Command& cmd);
|
|
|
|
bool verify_vtol_takeoff(const AP_Mission::Mission_Command &cmd);
|
2016-04-29 02:31:08 -03:00
|
|
|
bool verify_vtol_land(void);
|
2017-10-30 01:19:38 -03:00
|
|
|
bool in_vtol_auto(void) const;
|
|
|
|
bool in_vtol_mode(void) const;
|
2016-01-01 06:39:36 -04:00
|
|
|
|
|
|
|
// vtol help for is_flying()
|
|
|
|
bool is_flying(void);
|
2016-01-03 06:38:51 -04:00
|
|
|
|
|
|
|
// return current throttle as a percentate
|
|
|
|
uint8_t throttle_percentage(void) const {
|
2016-05-07 19:11:00 -03:00
|
|
|
return last_throttle * 100;
|
2016-01-03 06:38:51 -04:00
|
|
|
}
|
2016-03-24 22:33:19 -03:00
|
|
|
|
2016-04-20 02:13:20 -03:00
|
|
|
// return desired forward throttle percentage
|
|
|
|
int8_t forward_throttle_pct(void);
|
2016-04-20 03:23:17 -03:00
|
|
|
float get_weathervane_yaw_rate_cds(void);
|
2016-04-22 07:20:06 -03:00
|
|
|
|
|
|
|
// see if we are flying from vtol point of view
|
|
|
|
bool is_flying_vtol(void);
|
2017-02-11 01:50:03 -04:00
|
|
|
|
2017-02-11 04:12:56 -04:00
|
|
|
// return true when tailsitter frame configured
|
2017-10-30 01:19:38 -03:00
|
|
|
bool is_tailsitter(void) const;
|
2017-02-11 04:12:56 -04:00
|
|
|
|
|
|
|
// return true when flying a tailsitter in VTOL
|
|
|
|
bool tailsitter_active(void);
|
2017-02-11 01:50:03 -04:00
|
|
|
|
|
|
|
// create outputs for tailsitters
|
|
|
|
void tailsitter_output(void);
|
2017-02-12 05:58:00 -04:00
|
|
|
|
2017-02-24 01:47:09 -04:00
|
|
|
// handle different tailsitter input types
|
|
|
|
void tailsitter_check_input(void);
|
|
|
|
|
2017-10-30 01:19:38 -03:00
|
|
|
// check if we have completed transition to fixed wing
|
|
|
|
bool tailsitter_transition_fw_complete(void);
|
2017-09-06 04:58:08 -03:00
|
|
|
|
2017-10-30 01:19:38 -03:00
|
|
|
// check if we have completed transition to vtol
|
|
|
|
bool tailsitter_transition_vtol_complete(void) const;
|
2017-11-05 02:05:08 -04:00
|
|
|
|
|
|
|
// account for surface speed scaling in hover
|
|
|
|
void tailsitter_speed_scaling(void);
|
2017-10-30 01:19:38 -03:00
|
|
|
|
2017-09-06 04:58:08 -03:00
|
|
|
// user initiated takeoff for guided mode
|
|
|
|
bool do_user_takeoff(float takeoff_altitude);
|
2016-04-20 02:13:20 -03:00
|
|
|
|
2016-03-24 22:33:19 -03:00
|
|
|
struct PACKED log_QControl_Tuning {
|
|
|
|
LOG_PACKET_HEADER;
|
|
|
|
uint64_t time_us;
|
2016-03-25 09:09:59 -03:00
|
|
|
float angle_boost;
|
2016-03-24 22:33:19 -03:00
|
|
|
float throttle_out;
|
|
|
|
float desired_alt;
|
|
|
|
float inav_alt;
|
|
|
|
int16_t desired_climb_rate;
|
|
|
|
int16_t climb_rate;
|
2016-04-03 20:50:15 -03:00
|
|
|
float dvx;
|
|
|
|
float dvy;
|
2016-04-10 07:36:20 -03:00
|
|
|
float dax;
|
|
|
|
float day;
|
2017-04-18 09:25:14 -03:00
|
|
|
float throttle_mix;
|
2016-03-24 22:33:19 -03:00
|
|
|
};
|
|
|
|
|
2015-11-24 04:24:04 -04:00
|
|
|
private:
|
|
|
|
AP_AHRS_NavEKF &ahrs;
|
|
|
|
AP_Vehicle::MultiCopter aparm;
|
|
|
|
|
|
|
|
AP_InertialNav_NavEKF inertial_nav{ahrs};
|
|
|
|
|
2016-02-07 20:00:19 -04:00
|
|
|
AP_Int8 frame_class;
|
|
|
|
AP_Int8 frame_type;
|
2015-11-24 04:24:04 -04:00
|
|
|
|
2017-01-09 04:19:42 -04:00
|
|
|
AP_MotorsMulticopter *motors;
|
2017-02-27 02:39:46 -04:00
|
|
|
const struct AP_Param::GroupInfo *motors_var_info;
|
|
|
|
|
2015-12-26 06:40:40 -04:00
|
|
|
AC_AttitudeControl_Multi *attitude_control;
|
|
|
|
AC_PosControl *pos_control;
|
|
|
|
AC_WPNav *wp_nav;
|
2018-03-27 23:24:05 -03:00
|
|
|
AC_Loiter *loiter_nav;
|
2015-12-26 04:51:05 -04:00
|
|
|
|
2015-12-26 03:45:42 -04:00
|
|
|
// maximum vertical velocity the pilot may request
|
|
|
|
AP_Int16 pilot_velocity_z_max;
|
|
|
|
|
|
|
|
// vertical acceleration the pilot may request
|
|
|
|
AP_Int16 pilot_accel_z;
|
2016-08-29 03:44:54 -03:00
|
|
|
|
|
|
|
// check for quadplane assistance needed
|
|
|
|
bool assistance_needed(float aspeed);
|
|
|
|
|
2015-11-24 04:24:04 -04:00
|
|
|
// update transition handling
|
|
|
|
void update_transition(void);
|
2015-12-26 04:27:13 -04:00
|
|
|
|
2017-04-18 09:40:06 -03:00
|
|
|
// check for an EKF yaw reset
|
|
|
|
void check_yaw_reset(void);
|
|
|
|
|
2015-12-26 04:27:13 -04:00
|
|
|
// hold hover (for transition)
|
|
|
|
void hold_hover(float target_climb_rate);
|
|
|
|
|
|
|
|
// hold stabilize (for transition)
|
|
|
|
void hold_stabilize(float throttle_in);
|
2015-12-26 04:51:05 -04:00
|
|
|
|
2016-01-09 18:42:46 -04:00
|
|
|
// get pilot desired yaw rate in cd/s
|
|
|
|
float get_pilot_input_yaw_rate_cds(void);
|
2015-12-26 04:51:05 -04:00
|
|
|
|
2016-01-09 18:42:46 -04:00
|
|
|
// get overall desired yaw rate in cd/s
|
|
|
|
float get_desired_yaw_rate_cds(void);
|
|
|
|
|
2015-12-26 04:51:05 -04:00
|
|
|
// get desired climb rate in cm/s
|
|
|
|
float get_pilot_desired_climb_rate_cms(void);
|
2015-12-26 05:13:20 -04:00
|
|
|
|
|
|
|
// initialise throttle_wait when entering mode
|
|
|
|
void init_throttle_wait();
|
2015-12-26 06:40:40 -04:00
|
|
|
|
2017-03-13 04:45:46 -03:00
|
|
|
// use multicopter rate controller
|
2017-07-10 01:00:45 -03:00
|
|
|
void multicopter_attitude_rate_update(float yaw_rate_cds);
|
2017-03-13 04:45:46 -03:00
|
|
|
|
2015-12-26 06:40:40 -04:00
|
|
|
// main entry points for VTOL flight modes
|
|
|
|
void init_stabilize(void);
|
|
|
|
void control_stabilize(void);
|
|
|
|
|
|
|
|
void init_hover(void);
|
|
|
|
void control_hover(void);
|
2016-09-20 22:46:15 -03:00
|
|
|
void run_rate_controller(void);
|
2015-12-26 06:40:40 -04:00
|
|
|
|
|
|
|
void init_loiter(void);
|
2016-03-09 03:20:41 -04:00
|
|
|
void init_land(void);
|
2015-12-26 06:40:40 -04:00
|
|
|
void control_loiter(void);
|
2016-03-09 03:20:41 -04:00
|
|
|
void check_land_complete(void);
|
2015-12-26 06:40:40 -04:00
|
|
|
|
2016-04-29 02:31:08 -03:00
|
|
|
void init_qrtl(void);
|
|
|
|
void control_qrtl(void);
|
|
|
|
|
2015-12-26 06:40:40 -04:00
|
|
|
float assist_climb_rate_cms(void);
|
|
|
|
|
|
|
|
// calculate desired yaw rate for assistance
|
2016-01-09 18:42:46 -04:00
|
|
|
float desired_auto_yaw_rate_cds(void);
|
2015-12-26 06:40:40 -04:00
|
|
|
|
|
|
|
bool should_relax(void);
|
2016-03-24 22:11:56 -03:00
|
|
|
void motors_output(void);
|
2016-03-24 22:33:19 -03:00
|
|
|
void Log_Write_QControl_Tuning();
|
2016-04-02 08:45:51 -03:00
|
|
|
float landing_descent_rate_cms(float height_above_ground);
|
2016-03-24 22:11:56 -03:00
|
|
|
|
2016-02-07 20:00:19 -04:00
|
|
|
// setup correct aux channels for frame class
|
|
|
|
void setup_default_channels(uint8_t num_motors);
|
2016-05-05 22:28:26 -03:00
|
|
|
|
|
|
|
void guided_start(void);
|
|
|
|
void guided_update(void);
|
2016-08-01 19:21:44 -03:00
|
|
|
|
|
|
|
void check_throttle_suppression(void);
|
2017-03-13 04:04:09 -03:00
|
|
|
|
|
|
|
void run_z_controller(void);
|
2017-04-03 19:18:30 -03:00
|
|
|
|
|
|
|
void setup_defaults(void);
|
|
|
|
void setup_defaults_table(const struct defaults_struct *defaults, uint8_t count);
|
2017-11-05 05:44:42 -04:00
|
|
|
|
|
|
|
// calculate a stopping distance for fixed-wing to vtol transitions
|
|
|
|
float stopping_distance(void);
|
2015-11-24 04:24:04 -04:00
|
|
|
|
|
|
|
AP_Int16 transition_time_ms;
|
2015-12-26 06:40:40 -04:00
|
|
|
|
2017-11-05 05:44:42 -04:00
|
|
|
// transition deceleration, m/s/s
|
|
|
|
AP_Float transition_decel;
|
|
|
|
|
2015-12-26 06:40:40 -04:00
|
|
|
AP_Int16 rc_speed;
|
|
|
|
|
|
|
|
// min and max PWM for throttle
|
|
|
|
AP_Int16 thr_min_pwm;
|
|
|
|
AP_Int16 thr_max_pwm;
|
|
|
|
|
|
|
|
// speed below which quad assistance is given
|
|
|
|
AP_Float assist_speed;
|
2016-01-02 00:25:49 -04:00
|
|
|
|
2016-08-29 03:44:54 -03:00
|
|
|
// angular error at which quad assistance is given
|
|
|
|
AP_Int8 assist_angle;
|
|
|
|
uint32_t angle_error_start_ms;
|
|
|
|
|
2016-01-02 00:25:49 -04:00
|
|
|
// maximum yaw rate in degrees/second
|
|
|
|
AP_Float yaw_rate_max;
|
2016-01-02 02:55:56 -04:00
|
|
|
|
|
|
|
// landing speed in cm/s
|
|
|
|
AP_Int16 land_speed_cms;
|
|
|
|
|
2016-04-29 02:31:08 -03:00
|
|
|
// QRTL start altitude, meters
|
|
|
|
AP_Int16 qrtl_alt;
|
|
|
|
|
2016-01-02 02:55:56 -04:00
|
|
|
// alt to switch to QLAND_FINAL
|
|
|
|
AP_Float land_final_alt;
|
2016-06-03 19:35:09 -03:00
|
|
|
AP_Float vel_forward_alt_cutoff;
|
2015-12-26 06:40:40 -04:00
|
|
|
|
|
|
|
AP_Int8 enable;
|
2016-01-15 01:49:49 -04:00
|
|
|
AP_Int8 transition_pitch_max;
|
2016-04-20 02:13:20 -03:00
|
|
|
|
2016-04-29 03:31:22 -03:00
|
|
|
// control if a VTOL RTL will be used
|
|
|
|
AP_Int8 rtl_mode;
|
2016-05-05 19:27:47 -03:00
|
|
|
|
|
|
|
// control if a VTOL GUIDED will be used
|
|
|
|
AP_Int8 guided_mode;
|
2016-06-02 00:10:39 -03:00
|
|
|
|
|
|
|
// control ESC throttle calibration
|
|
|
|
AP_Int8 esc_calibration;
|
|
|
|
void run_esc_calibration(void);
|
2016-07-25 02:46:17 -03:00
|
|
|
|
|
|
|
// ICEngine control on landing
|
|
|
|
AP_Int8 land_icengine_cut;
|
2017-04-18 09:40:06 -03:00
|
|
|
|
2017-10-20 01:39:44 -03:00
|
|
|
// HEARTBEAT mav_type override
|
|
|
|
AP_Int8 mav_type;
|
2018-03-22 06:16:35 -03:00
|
|
|
MAV_TYPE get_mav_type(void) const;
|
2017-10-20 01:39:44 -03:00
|
|
|
|
2017-04-18 09:40:06 -03:00
|
|
|
// time we last got an EKF yaw reset
|
|
|
|
uint32_t ekfYawReset_ms;
|
|
|
|
|
2016-04-20 02:13:20 -03:00
|
|
|
struct {
|
|
|
|
AP_Float gain;
|
|
|
|
float integrator;
|
2016-06-02 18:57:10 -03:00
|
|
|
uint32_t last_ms;
|
2016-04-20 02:13:20 -03:00
|
|
|
int8_t last_pct;
|
|
|
|
} vel_forward;
|
2016-04-20 03:23:17 -03:00
|
|
|
|
|
|
|
struct {
|
|
|
|
AP_Float gain;
|
2016-04-21 08:52:25 -03:00
|
|
|
AP_Float min_roll;
|
2016-04-20 03:23:17 -03:00
|
|
|
uint32_t last_pilot_input_ms;
|
|
|
|
float last_output;
|
|
|
|
} weathervane;
|
2016-01-15 01:49:49 -04:00
|
|
|
|
2015-12-26 06:40:40 -04:00
|
|
|
bool initialised;
|
2015-11-24 04:24:04 -04:00
|
|
|
|
2015-12-26 04:51:05 -04:00
|
|
|
// timer start for transition
|
|
|
|
uint32_t transition_start_ms;
|
2015-11-24 04:24:04 -04:00
|
|
|
|
2015-12-26 06:40:40 -04:00
|
|
|
Location last_auto_target;
|
|
|
|
|
2015-11-24 04:24:04 -04:00
|
|
|
// last throttle value when active
|
2015-12-26 04:27:13 -04:00
|
|
|
float last_throttle;
|
2015-11-24 04:24:04 -04:00
|
|
|
|
2017-09-08 04:54:55 -03:00
|
|
|
// pitch when we enter loiter mode
|
|
|
|
int32_t loiter_initial_pitch_cd;
|
2015-12-26 04:27:13 -04:00
|
|
|
|
|
|
|
// true if we have reached the airspeed threshold for transition
|
|
|
|
enum {
|
|
|
|
TRANSITION_AIRSPEED_WAIT,
|
|
|
|
TRANSITION_TIMER,
|
2017-10-30 01:19:38 -03:00
|
|
|
TRANSITION_ANGLE_WAIT_FW,
|
|
|
|
TRANSITION_ANGLE_WAIT_VTOL,
|
2015-12-26 04:27:13 -04:00
|
|
|
TRANSITION_DONE
|
|
|
|
} transition_state;
|
2015-12-26 05:13:20 -04:00
|
|
|
|
|
|
|
// true when waiting for pilot throttle
|
2016-08-01 19:21:44 -03:00
|
|
|
bool throttle_wait:1;
|
2015-12-26 06:40:40 -04:00
|
|
|
|
|
|
|
// true when quad is assisting a fixed wing mode
|
2016-08-01 19:21:44 -03:00
|
|
|
bool assisted_flight:1;
|
2015-12-26 06:40:40 -04:00
|
|
|
|
2016-08-29 03:44:54 -03:00
|
|
|
// true when in angle assist
|
|
|
|
bool in_angle_assist:1;
|
|
|
|
|
2017-09-06 04:58:08 -03:00
|
|
|
// are we in a guided takeoff?
|
|
|
|
bool guided_takeoff:1;
|
2017-10-29 03:31:09 -03:00
|
|
|
|
2016-06-16 05:17:46 -03:00
|
|
|
struct {
|
|
|
|
// time when motors reached lower limit
|
|
|
|
uint32_t lower_limit_start_ms;
|
|
|
|
uint32_t land_start_ms;
|
|
|
|
float vpos_start_m;
|
|
|
|
} landing_detect;
|
2016-01-01 03:18:53 -04:00
|
|
|
|
|
|
|
// time we last set the loiter target
|
|
|
|
uint32_t last_loiter_ms;
|
2016-01-01 05:42:10 -04:00
|
|
|
|
2016-05-05 19:27:47 -03:00
|
|
|
enum position_control_state {
|
|
|
|
QPOS_POSITION1,
|
|
|
|
QPOS_POSITION2,
|
|
|
|
QPOS_LAND_DESCEND,
|
|
|
|
QPOS_LAND_FINAL,
|
|
|
|
QPOS_LAND_COMPLETE
|
2016-04-28 23:53:20 -03:00
|
|
|
};
|
2016-04-10 07:36:20 -03:00
|
|
|
struct {
|
2016-05-05 19:27:47 -03:00
|
|
|
enum position_control_state state;
|
2016-04-10 07:36:20 -03:00
|
|
|
float speed_scale;
|
|
|
|
Vector2f target_velocity;
|
2016-04-20 05:07:04 -03:00
|
|
|
float max_speed;
|
2016-04-28 23:53:20 -03:00
|
|
|
Vector3f target;
|
2016-04-29 02:50:45 -03:00
|
|
|
bool slow_descent:1;
|
2016-05-05 19:27:47 -03:00
|
|
|
} poscontrol;
|
2016-02-07 20:00:19 -04:00
|
|
|
|
2016-03-12 19:05:10 -04:00
|
|
|
struct {
|
|
|
|
bool running;
|
|
|
|
uint32_t start_ms; // system time the motor test began
|
|
|
|
uint32_t timeout_ms = 0; // test will timeout this many milliseconds after the motor_test_start_ms
|
|
|
|
uint8_t seq = 0; // motor sequence number of motor being tested
|
|
|
|
uint8_t throttle_type = 0; // motor throttle type (0=throttle percentage, 1=PWM, 2=pilot throttle channel pass-through)
|
|
|
|
uint16_t throttle_value = 0; // throttle to be sent to motor, value depends upon it's type
|
2016-03-31 21:09:51 -03:00
|
|
|
uint8_t motor_count; // number of motors to cycle
|
2016-03-12 19:05:10 -04:00
|
|
|
} motor_test;
|
|
|
|
|
2016-05-27 01:16:44 -03:00
|
|
|
// time of last control log message
|
|
|
|
uint32_t last_ctrl_log_ms;
|
2016-07-03 09:02:38 -03:00
|
|
|
|
|
|
|
// types of tilt mechanisms
|
2017-04-22 22:35:25 -03:00
|
|
|
enum {TILT_TYPE_CONTINUOUS=0,
|
|
|
|
TILT_TYPE_BINARY=1,
|
|
|
|
TILT_TYPE_VECTORED_YAW=2};
|
2016-05-27 01:16:44 -03:00
|
|
|
|
2016-05-01 05:07:52 -03:00
|
|
|
// tiltrotor control variables
|
|
|
|
struct {
|
|
|
|
AP_Int16 tilt_mask;
|
2017-02-24 06:05:27 -04:00
|
|
|
AP_Int16 max_rate_up_dps;
|
|
|
|
AP_Int16 max_rate_down_dps;
|
2016-05-01 05:07:52 -03:00
|
|
|
AP_Int8 max_angle_deg;
|
2016-07-03 09:02:38 -03:00
|
|
|
AP_Int8 tilt_type;
|
2017-04-22 22:35:25 -03:00
|
|
|
AP_Float tilt_yaw_angle;
|
2016-05-01 05:07:52 -03:00
|
|
|
float current_tilt;
|
|
|
|
float current_throttle;
|
2016-05-01 20:33:54 -03:00
|
|
|
bool motors_active:1;
|
2016-05-01 05:07:52 -03:00
|
|
|
} tilt;
|
|
|
|
|
2017-02-24 01:47:09 -04:00
|
|
|
enum tailsitter_input {
|
|
|
|
TAILSITTER_INPUT_MULTICOPTER = 0,
|
|
|
|
TAILSITTER_INPUT_PLANE = 1,
|
|
|
|
};
|
2017-02-24 03:02:34 -04:00
|
|
|
|
|
|
|
enum tailsitter_mask {
|
|
|
|
TAILSITTER_MASK_AILERON = 1,
|
|
|
|
TAILSITTER_MASK_ELEVATOR = 2,
|
|
|
|
TAILSITTER_MASK_THROTTLE = 4,
|
|
|
|
TAILSITTER_MASK_RUDDER = 8,
|
|
|
|
};
|
2017-02-24 01:47:09 -04:00
|
|
|
|
2017-02-11 04:12:56 -04:00
|
|
|
// tailsitter control variables
|
|
|
|
struct {
|
|
|
|
AP_Int8 transition_angle;
|
2017-02-24 01:47:09 -04:00
|
|
|
AP_Int8 input_type;
|
2017-02-24 03:02:34 -04:00
|
|
|
AP_Int8 input_mask;
|
|
|
|
AP_Int8 input_mask_chan;
|
2017-04-09 21:01:58 -03:00
|
|
|
AP_Float vectored_forward_gain;
|
|
|
|
AP_Float vectored_hover_gain;
|
2017-05-04 18:34:27 -03:00
|
|
|
AP_Float vectored_hover_power;
|
2017-02-11 04:12:56 -04:00
|
|
|
} tailsitter;
|
|
|
|
|
|
|
|
// the attitude view of the VTOL attitude controller
|
|
|
|
AP_AHRS_View *ahrs_view;
|
|
|
|
|
2016-08-01 19:21:44 -03:00
|
|
|
// time when motors were last active
|
|
|
|
uint32_t last_motors_active_ms;
|
2017-03-13 04:04:09 -03:00
|
|
|
|
|
|
|
// time when we last ran the vertical accel controller
|
|
|
|
uint32_t last_pidz_active_ms;
|
2017-04-08 01:39:55 -03:00
|
|
|
uint32_t last_pidz_init_ms;
|
2017-10-30 01:19:38 -03:00
|
|
|
|
|
|
|
// time when we were last in a vtol control mode
|
|
|
|
uint32_t last_vtol_mode_ms;
|
2016-08-01 19:21:44 -03:00
|
|
|
|
2016-05-01 05:07:52 -03:00
|
|
|
void tiltrotor_slew(float tilt);
|
2016-07-03 09:02:38 -03:00
|
|
|
void tiltrotor_binary_slew(bool forward);
|
2016-05-01 05:07:52 -03:00
|
|
|
void tiltrotor_update(void);
|
2016-07-03 09:02:38 -03:00
|
|
|
void tiltrotor_continuous_update(void);
|
|
|
|
void tiltrotor_binary_update(void);
|
2017-04-22 22:35:25 -03:00
|
|
|
void tiltrotor_vectored_yaw(void);
|
2017-03-13 07:53:22 -03:00
|
|
|
void tilt_compensate_up(float *thrust, uint8_t num_motors);
|
|
|
|
void tilt_compensate_down(float *thrust, uint8_t num_motors);
|
2016-05-08 20:11:11 -03:00
|
|
|
void tilt_compensate(float *thrust, uint8_t num_motors);
|
2017-03-13 07:53:22 -03:00
|
|
|
bool is_motor_tilting(uint8_t motor) const {
|
|
|
|
return (((uint8_t)tilt.tilt_mask.get()) & (1U<<motor));
|
|
|
|
}
|
2017-01-22 22:06:31 -04:00
|
|
|
bool tiltrotor_fully_fwd(void);
|
2017-02-24 06:05:27 -04:00
|
|
|
float tilt_max_change(bool up);
|
2016-09-26 22:46:51 -03:00
|
|
|
|
|
|
|
void afs_terminate(void);
|
2016-09-30 19:35:58 -03:00
|
|
|
bool guided_mode_enabled(void);
|
2017-09-05 19:22:38 -03:00
|
|
|
|
|
|
|
// set altitude target to current altitude
|
|
|
|
void set_alt_target_current(void);
|
|
|
|
|
|
|
|
// adjust altitude target smoothly
|
|
|
|
void adjust_alt_target(float target_cm);
|
2017-10-29 03:31:09 -03:00
|
|
|
|
|
|
|
// additional options
|
|
|
|
AP_Int32 options;
|
|
|
|
enum {
|
|
|
|
OPTION_LEVEL_TRANSITION=(1<<0),
|
|
|
|
OPTION_ALLOW_FW_TAKEOFF=(1<<1),
|
|
|
|
OPTION_ALLOW_FW_LAND=(1<<2),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
return true if current mission item is a vtol takeoff
|
|
|
|
*/
|
|
|
|
bool is_vtol_takeoff(uint16_t id) const;
|
|
|
|
|
|
|
|
/*
|
|
|
|
return true if current mission item is a vtol landing
|
|
|
|
*/
|
|
|
|
bool is_vtol_land(uint16_t id) const;
|
2016-05-01 05:07:52 -03:00
|
|
|
|
2016-03-12 19:05:10 -04:00
|
|
|
public:
|
|
|
|
void motor_test_output();
|
2017-11-27 02:16:01 -04:00
|
|
|
MAV_RESULT mavlink_motor_test_start(mavlink_channel_t chan, uint8_t motor_seq, uint8_t throttle_type,
|
|
|
|
uint16_t throttle_value, float timeout_sec,
|
|
|
|
uint8_t motor_count);
|
2016-03-12 19:05:10 -04:00
|
|
|
private:
|
|
|
|
void motor_test_stop();
|
2015-11-24 04:24:04 -04:00
|
|
|
};
|