Struct PlanarState

Source
pub struct PlanarState {
    pub position: Vec2,
    pub velocity: Vec2,
    pub yaw: f32,
    pub turn_rate: f32,
}

Fields§

§position: Vec2§velocity: Vec2§yaw: f32§turn_rate: f32

Implementations§

Source§

impl PlanarState

Source

pub fn telemetry(&self) -> Result<PlanarTelemetry, VehicleError>

Read heading, speed and slip without advancing or modifying the motor.

Returns VehicleError::Invalid if any state field is nonfinite or a derived speed cannot be represented as a finite f32.

use ferravex_math::Vec2;
use ferravex_play::vehicle::PlanarState;
let motor = PlanarState {
    position: Vec2::ZERO, velocity: Vec2::new(3., 4.), yaw: 0., turn_rate: 0.,
};
let hud = motor.telemetry()?;
assert_eq!((hud.speed, hud.forward_speed, hud.lateral_speed), (5., 4., 3.));
assert!(hud.slip_angle > 0.); // Sliding to the right.
Source

pub fn reset( &mut self, position: Vec2, yaw: f32, velocity: Vec2, ) -> Result<(), VehicleError>

Replace pose and linear velocity, clearing the smoothed turn rate.

Position, yaw and velocity must be finite, and velocity magnitude must be at most 10000 (the largest supported handling speed). Yaw is retained as supplied; the next step applies its usual wrapping and speed cap. Pass Vec2::ZERO to stop. Invalid targets leave every field unchanged, while a valid target can repair an invalid old state. No simulation tick elapses. Reset the host’s previous pose too, to avoid interpolating across a teleport.

use ferravex_math::Vec2;
use ferravex_play::vehicle::PlanarState;
let mut motor = PlanarState {
    position: Vec2::ZERO, velocity: Vec2::X * 8., yaw: 1., turn_rate: 2.,
};
motor.reset(Vec2::new(10., 20.), 0., Vec2::ZERO)?;
assert_eq!(motor.position, Vec2::new(10., 20.));
assert_eq!((motor.telemetry()?.speed, motor.turn_rate), (0., 0.));
Source

pub fn step( &mut self, p: PlanarHandling, input: DriveInput, dt: f32, ) -> Result<(), VehicleError>

Trait Implementations§

Source§

impl Clone for PlanarState

Source§

fn clone(&self) -> PlanarState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PlanarState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PlanarState

Source§

fn eq(&self, other: &PlanarState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PlanarState

Source§

impl StructuralPartialEq for PlanarState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.