Skip to main content

AxisProcessor

Struct AxisProcessor 

Source
pub struct AxisProcessor<F>
where F: Filter<Input = InertialInput, Output = Radians>,
{ pub pid: PidController, pub filter: F, }
Expand description

A generic controller for a single physical axis.

The AxisProcessor is generic over any Filter that accepts InertialInput and produces Radians. This allows the same control logic to be used with Complementary filters, Kalman filters, or simple low-pass filters.

Fields§

§pid: PidController

The PID algorithm responsible for generating the corrective signal.

§filter: F

The sensor fusion filter responsible for estimating the current orientation.

Implementations§

Source§

impl<F> AxisProcessor<F>
where F: Filter<Input = InertialInput, Output = Radians>,

Source

pub fn new(filter: F, pid: PidController) -> Self

Creates a new AxisProcessor with the provided estimation and control components.

Source

pub fn process( &mut self, input: InertialInput, target_angle: Radians, dt: f32, ) -> f32

Executes one iteration of the control loop for this axis.

This method performs two primary steps:

  1. State Estimation: Updates the internal filter with new IMU data.
  2. Control Generation: Computes the PID output based on the error between the target_angle and the estimated current_angle.
§Parameters
  • input - Raw rate and reference data from sensors.
  • target_angle - The desired orientation for this axis.
  • dt - Time delta since the last update in seconds.
§Returns

A normalized control signal (f32), typically in the range [-1.0, 1.0].

Auto Trait Implementations§

§

impl<F> Freeze for AxisProcessor<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for AxisProcessor<F>
where F: RefUnwindSafe,

§

impl<F> Send for AxisProcessor<F>
where F: Send,

§

impl<F> Sync for AxisProcessor<F>
where F: Sync,

§

impl<F> Unpin for AxisProcessor<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for AxisProcessor<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for AxisProcessor<F>
where F: UnwindSafe,

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> 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, 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.