pub struct State {
pub position_x: f64,
pub position_y: f64,
pub position_z: f64,
pub velocity_x: f64,
pub velocity_y: f64,
pub velocity_z: f64,
pub roll: f64,
pub pitch: f64,
pub yaw: f64,
pub roll_rate: f64,
pub pitch_rate: f64,
pub yaw_rate: f64,
}Expand description
Represents the complete state of a drone in 3D space.
This structure contains all the necessary state variables to describe a drone’s position, velocity, orientation (Euler angles), and angular velocities at any given moment in time.
§Fields
position_x,position_y,position_z- Position coordinates in the inertial frame (meters)velocity_x,velocity_y,velocity_z- Linear velocities in the inertial frame (m/s)roll,pitch,yaw- Euler angles representing orientation (radians)roll_rate,pitch_rate,yaw_rate- Angular velocities in the body frame (rad/s)
Fields§
§position_x: f64§position_y: f64§position_z: f64§velocity_x: f64§velocity_y: f64§velocity_z: f64§roll: f64§pitch: f64§yaw: f64§roll_rate: f64§pitch_rate: f64§yaw_rate: f64Implementations§
Source§impl State
impl State
Sourcepub fn to_array(&self) -> [f64; 12]
pub fn to_array(&self) -> [f64; 12]
Converts the state structure to a fixed-size array.
This method is useful for interfacing with numerical integration libraries that expect state vectors as arrays.
§Returns
A 12-element array containing all state variables in the following order: [pos_x, pos_y, pos_z, vel_x, vel_y, vel_z, roll, pitch, yaw, roll_rate, pitch_rate, yaw_rate]
§Example
let state = State::default(); let array = state.to_array(); assert_eq!(array.len(), 12);
Sourcepub fn from_array(arr: &[f64; 12]) -> Self
pub fn from_array(arr: &[f64; 12]) -> Self
Creates a state structure from a fixed-size array.
This method reconstructs a State from an array representation, typically used after numerical integration to convert back from array format.
§Arguments
arr- A 12-element array containing state variables in the same order asto_array()
§Returns
A new State instance with values from the input array
§Example
let array = [1.0, 2.0, 3.0, 0.0, 0.0, 0.0, 0.1, 0.2, 0.3, 0.0, 0.0, 0.0]; let state = State::from_array(&array); assert_eq!(state.position_x, 1.0);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnsafeUnpin for State
impl UnwindSafe for State
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.