Skip to main content

Session

Struct Session 

Source
pub struct Session {
    pub(crate) ptr: NonNull<TcsSession>,
}
Expand description

One live calibration: the sample buffer, the solver, retention, the accelerometer fit, the quality figures and the filtered compass.

Fields§

§ptr: NonNull<TcsSession>

The C handle; never null, freed in Drop.

Implementations§

Source§

impl Session

Source

pub fn new() -> Result<Session, SessionError>

Creates an empty session.

§Errors

SessionError::AbiMismatch when the linked library was built from another version of the header; SessionError::OutOfMemory when it cannot allocate.

Source

pub fn clear(&mut self)

Discards every sample, the fit, the accelerometer fit and any loaded offset; the field returns to 50 µT. The live compass filter is kept.

Source

pub fn add_sample(&mut self, mag: [f32; 3], accel: Option<[f32; 3]>) -> bool

Feeds one calibration sample: raw magnetometer, µT, and the accelerometer reading, mg, when the sample has one.

Returns true when the solver accepted a new fit on this sample.

Source

pub fn has_calibration(&self) -> bool

Whether a magnetometer calibration exists (fitted or loaded).

Source

pub fn calibrate(&self, mag: [f32; 3]) -> [f32; 3]

Applies the current magnetometer calibration, A (mag - V); the identity before a fit.

Source

pub fn points(&self) -> Vec<[f32; 3]>

Every buffered reading, calibrated, in slot order; at most SLOTS.

Source

pub fn constants(&self) -> Constants

The current magnetometer constants.

Source

pub fn set_constants(&mut self, offset: [f32; 3], mapping: [[f32; 3]; 3])

Installs magnetometer constants read back from a tag. The field is recomputed from the buffered readings, or kept when there are none.

Source

pub fn field(&self) -> f32

The field magnitude B, µT.

Source

pub fn set_accel_offset(&mut self, offset: [f32; 3])

Installs an accelerometer offset read back from a tag, mg. It stands until a live fit is valid or the session is cleared.

Source

pub fn update_quality(&mut self)

Recomputes the quality figures and the accelerometer fit. A valid fit also tightens the accelerometer’s intake gate, so how often this runs affects later samples: qtcalibrate’s replay runs it every second sample.

Source

pub fn quality(&self) -> Quality

The quality figures as of the last Session::update_quality.

Source

pub fn accel_fit(&self) -> AccelFit

The accelerometer offset in force.

Source

pub fn evictions(&self) -> Evictions

Evictions since the last clear.

Source

pub fn orientation( &mut self, mag: [f32; 3], accel: [f32; 3], ) -> Option<Orientation>

Solves the live compass from one raw sample, through the session’s low-pass filter, which this advances.

Returns None when the filtered pair admits no orientation.

Trait Implementations§

Source§

impl Drop for Session

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Session

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