pub struct AttitudeController {Show 21 fields
pub ang_vel_body: Vector3<f32>,
pub actuator_sysid: Vector3<f32>,
pub sysid_ang_vel_body: Vector3<f32>,
pub feed_forward_scalar: f32,
pub throttle_rpy_mix: f32,
pub throttle_rpy_mix_desired: f32,
pub attitude_control_max: f32,
pub dt: f32,
pub accel_max: Vector3<f32>,
pub use_sqrt_controller: bool,
pub p_angle_roll: P,
pub p_angle_pitch: P,
pub p_angle_yaw: P,
pub thrust_error_angle: f32,
pub attitude_target: Quaternion<f32>,
pub ang_vel_max: Vector3<f32>,
pub ang_vel_target: Vector3<f32>,
pub rate_bf_ff_enabled: bool,
pub input_tc: f32,
pub euler_angle_target: Vector3<f32>,
pub euler_rate_target: Vector3<f32>,
}Expand description
The attitude controller works around the concept of the desired attitude, target attitude and measured attitude. The desired attitude is the attitude input into the attitude controller that expresses where the higher level code would like the aircraft to move to. The target attitude is moved to the desired attitude with jerk, acceleration, and velocity limits. The target angular velocities are fed directly into the rate controllers. The angular error between the measured attitude and the target attitude is fed into the angle controller and the output of the angle controller summed at the input of the rate controllers. By feeding the target angular velocity directly into the rate controllers the measured and target attitudes remain very close together.
All input functions below follow the same procedure
- define the desired attitude the aircraft should attempt to achieve using the input variables
- using the desired attitude and input variables, define the target angular velocity so that it should move the target attitude towards the desired attitude
- if _rate_bf_ff_enabled is not being used then make the target attitude and target angular velocities equal to the desired attitude and desired angular velocities.
- ensure _attitude_target, _euler_angle_target, _euler_rate_target and _ang_vel_target have been defined. This ensures input modes can be changed without discontinuity.
- attitude_controller_run_quat is then run to pass the target angular velocities to the rate controllers and integrate them into the target attitude. Any errors between the target attitude and the measured attitude are corrected by first correcting the thrust vector until the angle between the target thrust vector measured trust vector drops below 2*AC_ATTITUDE_THRUST_ERROR_ANGLE. At this point the heading is also corrected.
Fields
ang_vel_body: Vector3<f32>The angular velocity (in radians per second) in the body frame.
actuator_sysid: Vector3<f32>sysid_ang_vel_body: Vector3<f32>feed_forward_scalar: f32throttle_rpy_mix: f32throttle_rpy_mix_desired: f32attitude_control_max: f32dt: f32accel_max: Vector3<f32>use_sqrt_controller: boolp_angle_roll: Pp_angle_pitch: Pp_angle_yaw: Pthrust_error_angle: f32attitude_target: Quaternion<f32>ang_vel_max: Vector3<f32>ang_vel_target: Vector3<f32>rate_bf_ff_enabled: boolinput_tc: f32euler_angle_target: Vector3<f32>euler_rate_target: Vector3<f32>Implementations
sourceimpl AttitudeController
impl AttitudeController
sourcepub fn input(
&mut self,
attitude_desired: Quaternion<f32>,
ang_vel_target: Vector3<f32>,
attitude_body: Quaternion<f32>
) -> Quaternion<f32>
pub fn input(
&mut self,
attitude_desired: Quaternion<f32>,
ang_vel_target: Vector3<f32>,
attitude_body: Quaternion<f32>
) -> Quaternion<f32>
Command a Quaternion attitude with feed-forward and smoothing.
Returns attitude_desired updated by the integral of the angular velocity
sourcepub fn attitude_control(&mut self, attitude_body: Quaternion<f32>)
pub fn attitude_control(&mut self, attitude_body: Quaternion<f32>)
Calculate the body frame angular velocities to follow the target attitude.
attitude_body represents a quaternion rotation in NED frame to the body
pub fn thrust_heading_rotation_angles(
&self,
attitude_target: Quaternion<f32>,
attitude_body: Quaternion<f32>
) -> (Quaternion<f32>, Vector3<f32>)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for AttitudeController
impl Send for AttitudeController
impl Sync for AttitudeController
impl Unpin for AttitudeController
impl UnwindSafe for AttitudeController
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self is actually part of its subset T (and can be converted to it).
fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self to the equivalent element of its superset.