pub struct DistanceSensor { /* private fields */ }Expand description
A struct which represents a V5 smart port configured as a distance sensor.
Implementations§
Source§impl DistanceSensor
impl DistanceSensor
Sourcepub unsafe fn new(port: u8) -> DistanceSensor
pub unsafe fn new(port: u8) -> DistanceSensor
Constructs a new distance sensor.
§Safety
This function is unsafe because it allows the user to create multiple
mutable references to the same distance sensor. You likely want to
implement Robot::new() instead.
Sourcepub fn get_distance(&self) -> Result<i32, DistanceSensorError>
pub fn get_distance(&self) -> Result<i32, DistanceSensorError>
Gets the currently measured distance from the sensor in millimetres.
Sourcepub fn get_confidence(&self) -> Result<i32, DistanceSensorError>
pub fn get_confidence(&self) -> Result<i32, DistanceSensorError>
Gets the confidence in the distance reading.
This is a value that has a range of 0 to 63. 63 means high confidence, lower values imply less confidence. Confidence is only available when distance is > 200mm (the value 10 is returned in this scenario).
Sourcepub fn get_object_size(&self) -> Result<i32, DistanceSensorError>
pub fn get_object_size(&self) -> Result<i32, DistanceSensorError>
Gets the current estimated relative object size.
This is a value that has a range of 0 to 400. A 18” x 30” grey card will return a value of approximately 75 in typical room lighting.
Sourcepub fn get_object_velocity(&self) -> Result<f64, DistanceSensorError>
pub fn get_object_velocity(&self) -> Result<f64, DistanceSensorError>
Gets the object velocity in metres per second.
Trait Implementations§
Source§impl DataSource for DistanceSensor
impl DataSource for DistanceSensor
Auto Trait Implementations§
impl Freeze for DistanceSensor
impl RefUnwindSafe for DistanceSensor
impl Send for DistanceSensor
impl Sync for DistanceSensor
impl Unpin for DistanceSensor
impl UnwindSafe for DistanceSensor
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