libPlayingWithFusion 2022.01.12
Playing With Fusion driver library for FRC roboRIO
|
#include <TimeOfFlight.h>
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 | |
TimeOfFlight & | operator= (const TimeOfFlight &)=delete |
TimeOfFlight (TimeOfFlight &&)=default | |
TimeOfFlight & | operator= (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 |
|
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
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. |
|
virtual |
|
delete |
|
default |
double TimeOfFlight::GetAmbientLightLevel | ( | ) | const |
Get ambient lighting level in mega counts per second.
uint32_t TimeOfFlight::GetFirmwareVersion | ( | ) | const |
Determine the sensor firmware version
double TimeOfFlight::GetRange | ( | ) | const |
Get the distance between the sensor and the target
double TimeOfFlight::GetRangeSigma | ( | ) | const |
Get the standard deviation of the distance measurment in millimeters
uint32_t TimeOfFlight::GetSerialNumber | ( | ) | const |
Determine the sensor hardware serial number
TimeOfFlight::Status TimeOfFlight::GetStatus | ( | ) | const |
Get status of the last distance measurement.
void TimeOfFlight::IdentifySensor | ( | ) |
Flash the time of flight sensor LED red and green to idicate the sensor asscioated with this instance of software
|
override |
bool TimeOfFlight::IsRangeValid | ( | ) | const |
Determine if the last measurment was valid
|
delete |
|
default |
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);
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. |
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.
mode | The desired sensor ranging mode (short, medium, long) |
sampleTime | The desired sample time in milliseconds |