pub struct InertialSensor { /* private fields */ }Expand description
A struct which represents a V5 smart port configured as a inertial sensor.
Implementations§
Source§impl InertialSensor
impl InertialSensor
Sourcepub unsafe fn new(port: u8) -> InertialSensor
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.
Sourcepub fn calibrate(&mut self) -> Result<(), InertialSensorError>
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.
Sourcepub fn get_rotation(&self) -> Result<f64, InertialSensorError>
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.
Sourcepub fn get_heading(&self) -> Result<f64, InertialSensorError>
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.
Sourcepub fn get_quaternion(
&self,
) -> Result<InertialSensorQuaternion, InertialSensorError>
pub fn get_quaternion( &self, ) -> Result<InertialSensorQuaternion, InertialSensorError>
Get a quaternion representing the Inertial Sensor’s orientation.
Sourcepub fn get_euler(&self) -> Result<InertialSensorEuler, InertialSensorError>
pub fn get_euler(&self) -> Result<InertialSensorEuler, InertialSensorError>
Get the Euler angles representing the Inertial Sensor’s orientation.
Sourcepub fn get_pitch(&self) -> Result<f64, InertialSensorError>
pub fn get_pitch(&self) -> Result<f64, InertialSensorError>
Get the Inertial Sensor’s pitch angle bounded by (-180,180).
Sourcepub fn get_roll(&self) -> Result<f64, InertialSensorError>
pub fn get_roll(&self) -> Result<f64, InertialSensorError>
Get the Inertial Sensor’s roll angle bounded by (-180,180).
Sourcepub fn get_yaw(&self) -> Result<f64, InertialSensorError>
pub fn get_yaw(&self) -> Result<f64, InertialSensorError>
Get the Inertial Sensor’s yaw angle bounded by (-180,180).
Sourcepub fn get_gyro_rate(&self) -> Result<InertialSensorRaw, InertialSensorError>
pub fn get_gyro_rate(&self) -> Result<InertialSensorRaw, InertialSensorError>
Get the Inertial Sensor’s raw gyroscope values.
Sourcepub fn get_accel(&self) -> Result<InertialSensorRaw, InertialSensorError>
pub fn get_accel(&self) -> Result<InertialSensorRaw, InertialSensorError>
Get the Inertial Sensor’s raw accelerometer values.
Sourcepub fn get_status(&self) -> Result<InertialSensorStatus, InertialSensorError>
pub fn get_status(&self) -> Result<InertialSensorStatus, InertialSensorError>
Get the Inertial Sensor’s status.
Sourcepub fn reset_heading(&mut self) -> Result<(), InertialSensorError>
pub fn reset_heading(&mut self) -> Result<(), InertialSensorError>
Resets the current reading of the Inertial Sensor’s rotation to zero.
Sourcepub fn reset_rotation(&mut self) -> Result<(), InertialSensorError>
pub fn reset_rotation(&mut self) -> Result<(), InertialSensorError>
Resets the current reading of the Inertial Sensor’s rotation to zero.
Sourcepub fn reset_pitch(&mut self) -> Result<(), InertialSensorError>
pub fn reset_pitch(&mut self) -> Result<(), InertialSensorError>
Resets the current reading of the Inertial Sensor’s pitch to zero.
Sourcepub fn reset_roll(&mut self) -> Result<(), InertialSensorError>
pub fn reset_roll(&mut self) -> Result<(), InertialSensorError>
Resets the current reading of the Inertial Sensor’s roll to zero.
Sourcepub fn reset_yaw(&mut self) -> Result<(), InertialSensorError>
pub fn reset_yaw(&mut self) -> Result<(), InertialSensorError>
Resets the current reading of the Inertial Sensor’s yaw to zero.
Sourcepub fn reset_euler(&mut self) -> Result<(), InertialSensorError>
pub fn reset_euler(&mut self) -> Result<(), InertialSensorError>
Reset all 3 euler values of the Inertial Sensor to 0.
Sourcepub fn reset(&mut self) -> Result<(), InertialSensorError>
pub fn reset(&mut self) -> Result<(), InertialSensorError>
Resets all 5 values of the Inertial Sensor to 0.
Sourcepub fn set_zero_euler(
&mut self,
euler: InertialSensorEuler,
) -> Result<(), InertialSensorError>
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.
Sourcepub fn set_rotation(&mut self, rotation: f64) -> Result<(), InertialSensorError>
pub fn set_rotation(&mut self, rotation: f64) -> Result<(), InertialSensorError>
Sets the current reading of the Inertial Sensor’s rotation to target value.
Sourcepub fn set_heading(&mut self, heading: f64) -> Result<(), InertialSensorError>
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.
Sourcepub fn set_pitch(&mut self, pitch: f64) -> Result<(), InertialSensorError>
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.
Trait Implementations§
Source§impl DataSource for InertialSensor
impl DataSource for InertialSensor
Auto Trait Implementations§
impl Freeze for InertialSensor
impl RefUnwindSafe for InertialSensor
impl Send for InertialSensor
impl Sync for InertialSensor
impl Unpin for InertialSensor
impl UnwindSafe for InertialSensor
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> IntoBroadcast for Twhere
T: DataSource,
impl<T> IntoBroadcast for Twhere
T: DataSource,
Source§fn into_broadcast(
self,
) -> Result<BroadcastWrapper<T>, (<T as DataSource>::Error, T)>
fn into_broadcast( self, ) -> Result<BroadcastWrapper<T>, (<T as DataSource>::Error, T)>
BroadcastWrapper. Read more