pub struct RotationSensor { /* private fields */ }
Expand description
A struct which represents a V5 smart port configured as a rotation sensor.
Implementations§
Source§impl RotationSensor
impl RotationSensor
Sourcepub unsafe fn new(port: u8, reversed: bool) -> Result<Self, RotationSensorError>
pub unsafe fn new(port: u8, reversed: bool) -> Result<Self, RotationSensorError>
Constructs a new rotation sensor.
§Safety
This function is unsafe because it allows the user to create multiple
mutable references to the same rotation sensor. You likely want to
implement Robot::new()
instead.
Sourcepub fn reset(&mut self) -> Result<(), RotationSensorError>
pub fn reset(&mut self) -> Result<(), RotationSensorError>
Reset the current absolute position to be the same as the Rotation Sensor angle.
Sourcepub fn set_position(&mut self, rotation: u32) -> Result<(), RotationSensorError>
pub fn set_position(&mut self, rotation: u32) -> Result<(), RotationSensorError>
Set the Rotation sensor to a desired rotation value in centidegrees.
Sourcepub fn reset_position(&mut self) -> Result<(), RotationSensorError>
pub fn reset_position(&mut self) -> Result<(), RotationSensorError>
Reset the current absolute position to be the same as the Rotation Sensor angle.
Sourcepub fn get_position(&self) -> Result<i32, RotationSensorError>
pub fn get_position(&self) -> Result<i32, RotationSensorError>
Get the Rotation Sensor’s current position in centidegrees.
Sourcepub fn get_velocity(&self) -> Result<i32, RotationSensorError>
pub fn get_velocity(&self) -> Result<i32, RotationSensorError>
Get the Rotation Sensor’s current velocity in centidegrees per second.
Sourcepub fn get_angle(&self) -> Result<i32, RotationSensorError>
pub fn get_angle(&self) -> Result<i32, RotationSensorError>
Get the Rotation Sensor’s current angle in centidegrees (0-36000).
Sourcepub fn set_reversed(&mut self, reverse: bool) -> Result<(), RotationSensorError>
pub fn set_reversed(&mut self, reverse: bool) -> Result<(), RotationSensorError>
Set the rotation direction of the sensor.
Sourcepub fn reverse(&mut self) -> Result<(), RotationSensorError>
pub fn reverse(&mut self) -> Result<(), RotationSensorError>
Reverses the rotational sensor’s direction.
Sourcepub fn get_reversed(&self) -> Result<bool, RotationSensorError>
pub fn get_reversed(&self) -> Result<bool, RotationSensorError>
Get the Rotation Sensor’s reversed flag.
Trait Implementations§
Source§impl DataSource for RotationSensor
impl DataSource for RotationSensor
Auto Trait Implementations§
impl Freeze for RotationSensor
impl RefUnwindSafe for RotationSensor
impl Send for RotationSensor
impl Sync for RotationSensor
impl Unpin for RotationSensor
impl UnwindSafe for RotationSensor
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