libPlayingWithFusion 2022.01.12
Playing With Fusion driver library for FRC roboRIO
frc::TimeOfFlight Class Reference

#include <TimeOfFlight.h>

Inheritance diagram for frc::TimeOfFlight:

Public Types

enum  RangingMode { kShort = 0 , kMedium = 1 , kLong = 2 }
 
enum  Status {
  kValid = 0 , kSigmaHigh = 1 , kReturnSignalLow = 2 , kReturnPhaseBad = 4 ,
  kHardwareFailure = 5 , kWrappedTarget = 7 , kInternalError = 8 , kInvalid = 14
}
 

Public Member Functions

 TimeOfFlight (uint8_t sensorID)
 
virtual ~TimeOfFlight ()
 
 TimeOfFlight (const TimeOfFlight &)=delete
 
TimeOfFlightoperator= (const TimeOfFlight &)=delete
 
 TimeOfFlight (TimeOfFlight &&)=default
 
TimeOfFlightoperator= (TimeOfFlight &&)=default
 
void IdentifySensor ()
 
uint32_t GetFirmwareVersion () const
 
uint32_t GetSerialNumber () const
 
bool IsRangeValid () const
 
double GetRange () const
 
double GetRangeSigma () const
 
double GetAmbientLightLevel () const
 
Status GetStatus () const
 
void SetRangingMode (RangingMode mode, double sampleTime)
 
void SetRangeOfInterest (uint8_t topLeftX, uint8_t topLeftY, uint8_t bottomRightX, uint8_t bottomRightY)
 
void InitSendable (wpi::SendableBuilder &builder) override
 

Member Enumeration Documentation

◆ RangingMode

Enumerator
kShort 
kMedium 
kLong 

◆ Status

Enumerator
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

Constructor & Destructor Documentation

◆ TimeOfFlight() [1/3]

TimeOfFlight::TimeOfFlight ( uint8_t  sensorID)
explicit

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
sensorIDThe 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.

◆ ~TimeOfFlight()

TimeOfFlight::~TimeOfFlight ( )
virtual

◆ TimeOfFlight() [2/3]

frc::TimeOfFlight::TimeOfFlight ( const TimeOfFlight )
delete

◆ TimeOfFlight() [3/3]

frc::TimeOfFlight::TimeOfFlight ( TimeOfFlight &&  )
default

Member Function Documentation

◆ GetAmbientLightLevel()

double TimeOfFlight::GetAmbientLightLevel ( ) const

Get ambient lighting level in mega counts per second.

Returns
Ambient lighting level in mega counts per second.

◆ GetFirmwareVersion()

uint32_t TimeOfFlight::GetFirmwareVersion ( ) const

Determine the sensor firmware version

Returns
The sensor firmware version

◆ GetRange()

double TimeOfFlight::GetRange ( ) const

Get the distance between the sensor and the target

Returns
Distance to target in millimeters

◆ GetRangeSigma()

double TimeOfFlight::GetRangeSigma ( ) const

Get the standard deviation of the distance measurment in millimeters

Returns
Standard deviation of distance measurment in millimeters

◆ GetSerialNumber()

uint32_t TimeOfFlight::GetSerialNumber ( ) const

Determine the sensor hardware serial number

Returns
The sensor hardware serial number

◆ GetStatus()

TimeOfFlight::Status TimeOfFlight::GetStatus ( ) const

Get status of the last distance measurement.

Returns
Status of last measurement. See VL53L1X datasheet for more details

◆ IdentifySensor()

void TimeOfFlight::IdentifySensor ( )

Flash the time of flight sensor LED red and green to idicate the sensor asscioated with this instance of software

◆ InitSendable()

void TimeOfFlight::InitSendable ( wpi::SendableBuilder &  builder)
override

◆ IsRangeValid()

bool TimeOfFlight::IsRangeValid ( ) const

Determine if the last measurment was valid

Returns
TRUE if the Time Of Flight Sensor sucessfully measured distance to an object

◆ operator=() [1/2]

TimeOfFlight & frc::TimeOfFlight::operator= ( const TimeOfFlight )
delete

◆ operator=() [2/2]

TimeOfFlight & frc::TimeOfFlight::operator= ( TimeOfFlight &&  )
default

◆ SetRangeOfInterest()

void TimeOfFlight::SetRangeOfInterest ( uint8_t  topLeftX,
uint8_t  topLeftY,
uint8_t  bottomRightX,
uint8_t  bottomRightY 
)

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
topLeftXColumn of the top left corner of the region of interest.
topLeftYRow of the top left corner of the region of interest.
bottomRightXColumn of the bottom right corner of the region of interest.
bottomRightYRow of the bottom right corner of the region of interest.

◆ SetRangingMode()

void TimeOfFlight::SetRangingMode ( RangingMode  mode,
double  sampleTime 
)

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
modeThe desired sensor ranging mode (short, medium, long)
sampleTimeThe desired sample time in milliseconds

The documentation for this class was generated from the following files: