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_AttitudeControl/AC_AttitudeControl_Multi_6DoF.h
Views: 1798
1
#pragma once
2
#if AP_SCRIPTING_ENABLED
3
4
#include "AC_AttitudeControl_Multi.h"
5
6
class AC_AttitudeControl_Multi_6DoF : public AC_AttitudeControl_Multi {
7
public:
8
AC_AttitudeControl_Multi_6DoF(AP_AHRS_View &ahrs, const AP_MultiCopter &aparm, AP_MotorsMulticopter& motors):
9
AC_AttitudeControl_Multi(ahrs,aparm,motors) {
10
11
if (_singleton != nullptr) {
12
AP_HAL::panic("Can only be one AC_AttitudeControl_Multi_6DoF");
13
}
14
_singleton = this;
15
}
16
17
static AC_AttitudeControl_Multi_6DoF *get_singleton() {
18
return _singleton;
19
}
20
21
// Command a Quaternion attitude with feedforward and smoothing
22
// attitude_desired_quat: is updated on each time_step (_dt) by the integral of the angular velocity
23
void input_quaternion(Quaternion& attitude_desired_quat, Vector3f ang_vel_body) override;
24
/*
25
override input functions to attitude controller and convert desired angles into thrust angles and substitute for offset angles
26
*/
27
28
// Command an euler roll and pitch angle and an euler yaw rate with angular velocity feedforward and smoothing
29
void input_euler_angle_roll_pitch_euler_rate_yaw(float euler_roll_angle_cd, float euler_pitch_angle_cd, float euler_yaw_rate_cds) override;
30
31
// Command an euler roll, pitch and yaw angle with angular velocity feedforward and smoothing
32
void input_euler_angle_roll_pitch_yaw(float euler_roll_angle_cd, float euler_pitch_angle_cd, float euler_yaw_angle_cd, bool slew_yaw) override;
33
34
// Command a thrust vector in the earth frame and a heading angle and/or rate
35
void input_thrust_vector_rate_heading(const Vector3f& thrust_vector, float heading_rate_cds, bool slew_yaw = true) override;
36
void input_thrust_vector_heading(const Vector3f& thrust_vector, float heading_angle_cd, float heading_rate_cds) override;
37
38
/*
39
all other input functions should zero thrust vectoring and behave as a normal copter
40
*/
41
42
// Command euler yaw rate and pitch angle with roll angle specified in body frame
43
// (used only by tailsitter quadplanes)
44
void input_euler_rate_yaw_euler_angle_pitch_bf_roll(bool plane_controls, float euler_roll_angle_cd, float euler_pitch_angle_cd, float euler_yaw_rate_cds) override;
45
46
// Command an euler roll, pitch, and yaw rate with angular velocity feedforward and smoothing
47
void input_euler_rate_roll_pitch_yaw(float euler_roll_rate_cds, float euler_pitch_rate_cds, float euler_yaw_rate_cds) override;
48
49
// Command an angular velocity with angular velocity feedforward and smoothing
50
void input_rate_bf_roll_pitch_yaw(float roll_rate_bf_cds, float pitch_rate_bf_cds, float yaw_rate_bf_cds) override;
51
52
// Command an angular velocity with angular velocity feedforward and smoothing
53
void input_rate_bf_roll_pitch_yaw_2(float roll_rate_bf_cds, float pitch_rate_bf_cds, float yaw_rate_bf_cds) override;
54
55
// Command an angular velocity with angular velocity smoothing using rate loops only with integrated rate error stabilization
56
void input_rate_bf_roll_pitch_yaw_3(float roll_rate_bf_cds, float pitch_rate_bf_cds, float yaw_rate_bf_cds) override;
57
58
// Command an angular step (i.e change) in body frame angle
59
void input_angle_step_bf_roll_pitch_yaw(float roll_angle_step_bf_cd, float pitch_angle_step_bf_cd, float yaw_angle_step_bf_cd) override;
60
61
// run lowest level body-frame rate controller and send outputs to the motors
62
void rate_controller_run() override;
63
64
// limiting lean angle based on throttle makes no sense for 6DoF, always allow 90 deg, return in centi-degrees
65
float get_althold_lean_angle_max_cd() const override { return 9000.0f; }
66
67
// set the attitude that will be used in 6DoF flight
68
void set_offset_roll_pitch(float roll_deg, float pitch_deg) {
69
roll_offset_deg = roll_deg;
70
pitch_offset_deg = pitch_deg;
71
}
72
73
// these flags enable or disable lateral or forward thrust, with both disabled the vehicle acts like a traditional copter
74
// it will roll and pitch to move, its also possible to enable only forward or lateral to suit the vehicle configuration.
75
// by default the vehicle is full 6DoF, these can be set in flight via scripting
76
void set_forward_enable(bool b) {
77
forward_enable = b;
78
}
79
void set_lateral_enable(bool b) {
80
lateral_enable = b;
81
}
82
83
private:
84
85
void set_forward_lateral(float &euler_pitch_angle_cd, float &euler_roll_angle_cd);
86
87
float roll_offset_deg;
88
float pitch_offset_deg;
89
90
bool forward_enable = true;
91
bool lateral_enable = true;
92
93
static AC_AttitudeControl_Multi_6DoF *_singleton;
94
95
};
96
97
#endif // AP_SCRIPTING_ENABLED
98
99