TimeOfFlight
- class playingwithfusion.TimeOfFlight(sensorID: int)
Bases:
Sendable
Create an instance of the CAN Time Of Flight sensor.
This is designed to support the Playing With Fusion (PWF) SEN-36005 time of flight sensor
- Parameters:
sensorID – The 6-bit identifier used to select a particular sensor on the CAN bus. This identifier may be set through the PWF Device configuration page on the roboRIO.
- class RangingMode(value: int)
Bases:
pybind11_object
Members:
kShort
kMedium
kLong
- kLong = <RangingMode.kLong: 2>
- kMedium = <RangingMode.kMedium: 1>
- kShort = <RangingMode.kShort: 0>
- property name
- property value
- class Status(value: int)
Bases:
pybind11_object
Members:
kValid : Measured distance is valid
kSigmaHigh : Sigma estimator check is above internally defined threshold. The repeatability
or standard deviation of the measurement is bad due to a decreasing signal noise ratio. Increasing the timing budget can improve the standard deviation.
kReturnSignalLow : Return signal value is below the internal defined threshold. The return signal is
too week to return a good answer. The target may be too far, not reflective enough, or too small. Increasing the timing buget might help, but there may simply be no target available.
kReturnPhaseBad : Return signal phase is out of bounds. This means that the sensor is ranging in a
“nonappropriated” zone and the measured result may be inconsistent. This status is considered as a warning but, in general, it happens when a target is at the maximum distance possible from the sensor.
kHardwareFailure : Hardware failure
kWrappedTarget : Wrapped target, non-matching phases. This situation may occur when the target is
very reflective and the distance to the target/sensor is longer than the physical limited distance measurable by the sensor. For example, approximately 5m when the senor is in Long distance mode and approximately 1.3 m when the sensor is in Short distance mode.
kInternalError : Internal algorithm underflow or overflow
kInvalid : The measured distance is invalid
- kHardwareFailure = <Status.kHardwareFailure: 5>
- kInternalError = <Status.kInternalError: 8>
- kInvalid = <Status.kInvalid: 14>
- kReturnPhaseBad = <Status.kReturnPhaseBad: 4>
- kReturnSignalLow = <Status.kReturnSignalLow: 2>
- kSigmaHigh = <Status.kSigmaHigh: 1>
- kValid = <Status.kValid: 0>
- kWrappedTarget = <Status.kWrappedTarget: 7>
- property name
- property value
- getAmbientLightLevel() float
Get ambient lighting level in mega counts per second.
- Returns:
Ambient lighting level in mega counts per second.
- getFirmwareVersion() int
Determine the sensor firmware version
- Returns:
The sensor firmware version
- getRange() float
Get the distance between the sensor and the target
- Returns:
Distance to target in millimeters
- getRangeSigma() float
Get the standard deviation of the distance measurment in millimeters
- Returns:
Standard deviation of distance measurment in millimeters
- getSerialNumber() int
Determine the sensor hardware serial number
- Returns:
The sensor hardware serial number
- getStatus() playingwithfusion._playingwithfusion.TimeOfFlight.Status
Get status of the last distance measurement.
- Returns:
Status of last measurement. See VL53L1X datasheet for more details
- identifySensor() None
Flash the time of flight sensor LED red and green to idicate the sensor asscioated with this instance of software
- initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
- isRangeValid() bool
Determine if the last measurment was valid
- Returns:
TRUE if the Time Of Flight Sensor sucessfully measured distance to an object
- setRangeOfInterest(topLeftX: int, topLeftY: int, bottomRightX: int, bottomRightY: int) None
Specify the region of the imaging sensor used for range measurement.
The region of interest refers to the pixels within the time of flight imaging sensor that are used to detect reflected laser light form the target. The sensor contains a 16x16 pixel grid. By default, all 256 pixels are used which results in a roughly 27 degree field of view.
The Field of view refers to a cone which grows from the time of flight sensor outward. By reducing the size of the region of interest (by using a smaller area of pixels) it is possible to reduce the field of view. This can be helpfull when measuring objects far away. The smaller the field of view, the smaller the area where the sensor can detect targets.
Reducing the region of interest will reduce the sensitivity of the sensor. It may be necessary to increase the reflectivity of the target or to increase the sample time to compensate.
The range of interest rows and columns must be greater or equal to zero and less than or equal to fifteen. The top left corner row/column must be smaller than the bottom right column/row. The region of interest must be at least four coulmns wide and four rows tall. For example, to specify a 4x4 region at the center of the image sensor use:
TimeOfFlight_SetRangeOfInterest(pHandle, 8, 8, 12, 12);
- Parameters:
topLeftX – Column of the top left corner of the region of interest.
topLeftY – Row of the top left corner of the region of interest.
bottomRightX – Column of the bottom right corner of the region of interest.
bottomRightY – Row of the bottom right corner of the region of interest.
- setRangingMode(mode: playingwithfusion._playingwithfusion.TimeOfFlight.RangingMode, sampleTime: float) None
Configure the ranging mode as well as the sample rate of the time of flight sensor
The ranging mode specifies the trade off between maximum measure distance verses reliablity in bright situations. Short mode (default) works the best in bright lighting conditions, but can only measure 1.3 meters. Long mode can measure up to 4 meters in the dark, but may only be able to measure shorter distances depending on the lighting conditions. See the Vl53L1x datasheet for more information
The sample time specifies the how frequently the time of flight sensor attempts to measure the distance to a target. The sample time must be between 24 and 1000 milliseconds.
- Parameters:
mode – The desired sensor ranging mode (short, medium, long)
sampleTime – The desired sample time in milliseconds