Path: blob/master/libraries/AC_AttitudeControl/AC_AttitudeControl_Multi_6DoF.h
9742 views
#pragma once1#if AP_SCRIPTING_ENABLED23#include "AC_AttitudeControl_Multi.h"45class AC_AttitudeControl_Multi_6DoF : public AC_AttitudeControl_Multi {6public:7AC_AttitudeControl_Multi_6DoF(AP_AHRS_View &ahrs, AP_MotorsMulticopter& motors):8AC_AttitudeControl_Multi(ahrs,motors) {910if (_singleton != nullptr) {11AP_HAL::panic("Can only be one AC_AttitudeControl_Multi_6DoF");12}13_singleton = this;14}1516static AC_AttitudeControl_Multi_6DoF *get_singleton() {17return _singleton;18}1920// Sets a desired attitude using a quaternion and body-frame angular velocity (rad/s).21// The desired quaternion is incrementally updated each timestep. Angular velocity is shaped by acceleration limits and feedforward.22void input_quaternion(Quaternion& attitude_desired_quat, Vector3f ang_vel_body) override;23/*24override input functions to attitude controller and convert desired angles into thrust angles and substitute for offset angles25*/2627// Sets desired roll and pitch angles (in radians) and yaw rate (in radians/s).28// Used when roll/pitch stabilization is needed with manual or autonomous yaw rate control.29// Applies acceleration-limited input shaping for smooth transitions and computes body-frame angular velocity targets.30void input_euler_angle_roll_pitch_euler_rate_yaw_rad(float euler_roll_angle_rad, float euler_pitch_angle_rad, float euler_yaw_rate_rads) override;313233// Sets desired roll, pitch, and yaw angles (in radians).34// Used to follow an absolute attitude setpoint. Input shaping and yaw slew limits are applied.35// Outputs are passed to the rate controller via shaped angular velocity targets.36void input_euler_angle_roll_pitch_yaw_rad(float euler_roll_angle_rad, float euler_pitch_angle_rad, float euler_yaw_angle_rad, bool slew_yaw) override;3738// Sets desired thrust vector and heading rate (in radians/s).39// Used for tilt-based navigation with independent yaw control.40// The thrust vector defines the desired orientation (e.g., pointing direction for vertical thrust),41// while the heading rate adjusts yaw. The input is shaped by acceleration and slew limits.42void input_thrust_vector_rate_heading_rads(const Vector3f& thrust_vector, float heading_rate_rads, bool slew_yaw = true) override;4344// Sets desired thrust vector and heading (in radians) with heading rate (in radians/s).45// Used for advanced attitude control where thrust direction is separated from yaw orientation.46// Heading slew is constrained based on configured limits.47void input_thrust_vector_heading_rad(const Vector3f& thrust_vector, float heading_angle_rad, float heading_rate_rads) override;4849/*50all other input functions should zero thrust vectoring and behave as a normal copter51*/5253// Command euler yaw rate and pitch angle with roll angle specified in body frame54// (used only by tailsitter quadplanes)55void input_euler_rate_yaw_euler_angle_pitch_bf_roll_rad(bool plane_controls, float euler_roll_angle_rad, float euler_pitch_angle_rad, float euler_yaw_rate_rads) override;5657// Command an euler roll, pitch, and yaw rate with angular velocity feedforward and smoothing58void input_euler_rate_roll_pitch_yaw_rads(float euler_roll_rate_rads, float euler_pitch_rate_rads, float euler_yaw_rate_rads) override;596061// Sets desired roll, pitch, and yaw angular rates in body-frame (in radians/s).62// This command is used by fully stabilized acro modes.63// It applies angular velocity targets in the body frame,64// shaped using acceleration limits and passed to the rate controller.65void input_rate_bf_roll_pitch_yaw_rads(float roll_rate_bf_rads, float pitch_rate_bf_rads, float yaw_rate_bf_rads) override;6667// Sets desired roll, pitch, and yaw angular rates in body-frame (in radians/s).68// Used by Copter's rate-only acro mode.69// Applies raw angular velocity targets directly to the rate controller with smoothing70// and no attitude feedback or stabilization.71void input_rate_bf_roll_pitch_yaw_2_rads(float roll_rate_bf_rads, float pitch_rate_bf_rads, float yaw_rate_bf_rads) override;727374// Sets desired roll, pitch, and yaw angular rates in body-frame (in radians/s).75// Used by Plane's acro mode with rate error integration.76// Integrates attitude error over time to generate target angular rates.77void input_rate_bf_roll_pitch_yaw_3_rads(float roll_rate_bf_rads, float pitch_rate_bf_rads, float yaw_rate_bf_rads) override;7879// Applies a one-time angular offset in body-frame roll/pitch/yaw angles (in radians).80// Used for initiating step responses during autotuning or manual test inputs.81void input_angle_step_bf_roll_pitch_yaw_rad(float roll_angle_step_bf_rad, float pitch_angle_step_bf_rad, float yaw_angle_step_bf_rad) override;8283// run lowest level body-frame rate controller and send outputs to the motors84void rate_controller_run() override;8586// limiting lean angle based on throttle makes no sense for 6DoF, always allow 90 deg, return in centi-degrees87float get_althold_lean_angle_max_rad() const override { return radians(90.0f); }8889// set the attitude that will be used in 6DoF flight90void set_offset_roll_pitch(float roll_deg, float pitch_deg) {91roll_offset_deg = roll_deg;92pitch_offset_deg = pitch_deg;93}9495// these flags enable or disable lateral or forward thrust, with both disabled the vehicle acts like a traditional copter96// it will roll and pitch to move, its also possible to enable only forward or lateral to suit the vehicle configuration.97// by default the vehicle is full 6DoF, these can be set in flight via scripting98void set_forward_enable(bool b) {99forward_enable = b;100}101void set_lateral_enable(bool b) {102lateral_enable = b;103}104105private:106107void set_forward_lateral_rad(float &euler_pitch_angle_rad, float &euler_roll_angle_rad);108109float roll_offset_deg;110float pitch_offset_deg;111112bool forward_enable = true;113bool lateral_enable = true;114115static AC_AttitudeControl_Multi_6DoF *_singleton;116117};118119#endif // AP_SCRIPTING_ENABLED120121122