InertialSensor

Struct InertialSensor 

Source
pub struct InertialSensor { /* private fields */ }
Expand description

A struct which represents a V5 smart port configured as a inertial sensor.

Implementations§

Source§

impl InertialSensor

Source

pub unsafe fn new(port: u8) -> InertialSensor

Constructs a new inertial sensor.

§Safety

This function is unsafe because it allows the user to create multiple mutable references to the same inertial sensor. You likely want to implement Robot::new() instead.

Source

pub fn calibrate(&mut self) -> Result<(), InertialSensorError>

Calibrate IMU.

This calls the reset function from PROS. This takes approximately 2 seconds, and is a non-blocking operation.

Source

pub fn get_rotation(&self) -> Result<f64, InertialSensorError>

Get the total number of degrees the Inertial Sensor has spun about the z-axis.

This value is theoretically unbounded. Clockwise rotations are represented with positive degree values, while counterclockwise rotations are represented with negative ones.

Source

pub fn get_heading(&self) -> Result<f64, InertialSensorError>

Get the Inertial Sensor’s heading relative to the initial direction of its x-axis.

This value is bounded by [0,360). Clockwise rotations are represented with positive degree values, while counterclockwise rotations are represented with negative ones.

Source

pub fn get_quaternion( &self, ) -> Result<InertialSensorQuaternion, InertialSensorError>

Get a quaternion representing the Inertial Sensor’s orientation.

Source

pub fn get_euler(&self) -> Result<InertialSensorEuler, InertialSensorError>

Get the Euler angles representing the Inertial Sensor’s orientation.

Source

pub fn get_pitch(&self) -> Result<f64, InertialSensorError>

Get the Inertial Sensor’s pitch angle bounded by (-180,180).

Source

pub fn get_roll(&self) -> Result<f64, InertialSensorError>

Get the Inertial Sensor’s roll angle bounded by (-180,180).

Source

pub fn get_yaw(&self) -> Result<f64, InertialSensorError>

Get the Inertial Sensor’s yaw angle bounded by (-180,180).

Source

pub fn get_gyro_rate(&self) -> Result<InertialSensorRaw, InertialSensorError>

Get the Inertial Sensor’s raw gyroscope values.

Source

pub fn get_accel(&self) -> Result<InertialSensorRaw, InertialSensorError>

Get the Inertial Sensor’s raw accelerometer values.

Source

pub fn get_status(&self) -> Result<InertialSensorStatus, InertialSensorError>

Get the Inertial Sensor’s status.

Source

pub fn reset_heading(&mut self) -> Result<(), InertialSensorError>

Resets the current reading of the Inertial Sensor’s rotation to zero.

Source

pub fn reset_rotation(&mut self) -> Result<(), InertialSensorError>

Resets the current reading of the Inertial Sensor’s rotation to zero.

Source

pub fn reset_pitch(&mut self) -> Result<(), InertialSensorError>

Resets the current reading of the Inertial Sensor’s pitch to zero.

Source

pub fn reset_roll(&mut self) -> Result<(), InertialSensorError>

Resets the current reading of the Inertial Sensor’s roll to zero.

Source

pub fn reset_yaw(&mut self) -> Result<(), InertialSensorError>

Resets the current reading of the Inertial Sensor’s yaw to zero.

Source

pub fn reset_euler(&mut self) -> Result<(), InertialSensorError>

Reset all 3 euler values of the Inertial Sensor to 0.

Source

pub fn reset(&mut self) -> Result<(), InertialSensorError>

Resets all 5 values of the Inertial Sensor to 0.

Source

pub fn set_zero_euler( &mut self, euler: InertialSensorEuler, ) -> Result<(), InertialSensorError>

Sets the current reading of the Inertial Sensor’s euler values to target euler values. Will default to +/- 180 if target exceeds +/- 180.

Source

pub fn set_rotation(&mut self, rotation: f64) -> Result<(), InertialSensorError>

Sets the current reading of the Inertial Sensor’s rotation to target value.

Source

pub fn set_heading(&mut self, heading: f64) -> Result<(), InertialSensorError>

Sets the current reading of the Inertial Sensor’s heading to target value Target will default to 360 if above 360 and default to 0 if below 0.

Source

pub fn set_pitch(&mut self, pitch: f64) -> Result<(), InertialSensorError>

Sets the current reading of the Inertial Sensor’s pitch to target value Will default to +/- 180 if target exceeds +/- 180.

Source

pub fn set_roll(&mut self, roll: f64) -> Result<(), InertialSensorError>

Sets the current reading of the Inertial Sensor’s roll to target value Will default to +/- 180 if target exceeds +/- 180.

Source

pub fn set_yaw(&mut self, yaw: f64) -> Result<(), InertialSensorError>

Sets the current reading of the Inertial Sensor’s yaw to target value Will default to +/- 180 if target exceeds +/- 180.

Trait Implementations§

Source§

impl DataSource for InertialSensor

Source§

type Data = InertialSensorData

The type of data produced by the data source.
Source§

type Error = InertialSensorError

The type of errors which could occur while reading data.
Source§

fn read(&self) -> Result<Self::Data, Self::Error>

Tries to read a new value form the data source.
Source§

impl From<SmartPort> for InertialSensor

Source§

fn from(port: SmartPort) -> Self

Converts to this type from the input type.

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> IntoBroadcast for T
where T: DataSource,

Source§

fn into_broadcast( self, ) -> Result<BroadcastWrapper<T>, (<T as DataSource>::Error, T)>

Converts the data source into a BroadcastWrapper. 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.