pub struct DistanceSensor { /* private fields */ }Expand description
A physical distance sensor plugged into a port. Distance sensors can only keep track of one object at a time.
Implementations§
Source§impl DistanceSensor
impl DistanceSensor
Sourcepub const fn new(port: SmartPort) -> Self
pub const fn new(port: SmartPort) -> Self
Create a new distance sensor from a smart port index.
Sourcepub fn distance(&self) -> Result<u32, PortError>
pub fn distance(&self) -> Result<u32, PortError>
Returns the distance to the object the sensor detects in millimeters.
Sourcepub fn velocity(&self) -> Result<f64, PortError>
pub fn velocity(&self) -> Result<f64, PortError>
Returns the velocity of the object the sensor detects in m/s
Sourcepub fn relative_size(&self) -> Result<u32, PortError>
pub fn relative_size(&self) -> Result<u32, PortError>
Get the current guess at 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.
This sensor reading is unusual, as it is entirely unitless with the seemingly arbitrary
range of 0-400 existing due to VEXCode’s vex::sizeType enum having four variants. It’s
unknown what the sensor is actually measuring here either, so use this data with a grain
of salt.
Sourcepub fn distance_confidence(&self) -> Result<f64, PortError>
pub fn distance_confidence(&self) -> Result<f64, PortError>
Returns the confidence in the distance measurement from 0.0 to 1.0.
Trait Implementations§
Source§impl Debug for DistanceSensor
impl Debug for DistanceSensor
Source§impl PartialEq for DistanceSensor
impl PartialEq for DistanceSensor
Source§impl SmartDevice for DistanceSensor
impl SmartDevice for DistanceSensor
Source§fn port_index(&self) -> u8
fn port_index(&self) -> u8
Source§fn device_type(&self) -> SmartDeviceType
fn device_type(&self) -> SmartDeviceType
SmartDeviceType that this device is associated with. Read more