Struct vex_rt::rotation::RotationSensor
source · 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.