AndyMark FRC CAN API (C++) v2026.0.4
Loading...
Searching...
No Matches
AM_CANLidar Class Reference

ToF/Lidar sensor device. More...

#include <AM_CAN_Lidar.h>

Inheritance diagram for AM_CANLidar:
CanDevice

Public Member Functions

 AM_CANLidar (int deviceID)
 Construct a CAN lidar sensor with the given CAN ID.
AM_LidarData GetData ()
 Fetch the most recent lidar reading using the default timeout.
AM_LidarData GetData (int timeoutMs)
 Fetch lidar reading with a custom timeout applied to the CAN read.
AM_LidarDebugData GetDebugData (int timeoutMs=50)
 Retrieve the latest debug information from the sensor.
uint16_t GetPeakSignalCentiMcps () const
 Get the peak signal strength of the last debug sample.
uint16_t GetAmbientCentiMcps () const
 Get the ambient light level of the last debug sample.
bool HasDebugData () const
 Returns true if at least one debug frame has been received.
bool SetDistanceMode (AM_LidarDistanceMode mode)
 Set the VL53L1X distance mode on the device.
bool SetMeasurementTimingBudgetUs (uint32_t budgetUs)
 Set measurement timing budget on the device.
bool SetIntermeasurementPeriodMs (uint32_t periodMs)
 Set intermeasurement period on the device.
bool SetTimeoutMs (uint16_t timeoutMs)
 Set the lidar library read timeout on the device.
bool SetSigmaThreshold (uint16_t sigma)
 Set the VL53L1X sigma threshold register value.
bool SetMinSignalRate (float mcps)
 Set the minimum signal rate threshold on the device.
bool SetROISize (uint8_t width, uint8_t height)
 Set the ROI size on the device.
bool SetROICenter (uint8_t centerSpad)
 Set the ROI center SPAD on the device.
void SetUserOffsetMm (int32_t offsetMm)
 Set an additional runtime offset applied on top of the default offset.
int32_t GetUserOffsetMm () const
 Get the currently configured runtime (user) offset in millimeters.
void SetOffsetDegrees (double degrees)
void SetReportPeriod (int periodMs)
 Set periodic report period (ms) for device reports.
void ResetReportPeriod ()
 Reset device report period to default (50ms).
Public Member Functions inherited from CanDevice
 CanDevice (int deviceID, int deviceManufacturer, int deviceType)
 Construct a CAN device wrapper.
virtual ~CanDevice ()=default
 Virtual destructor.
int getDeviceId ()
 Get this device's configured CAN ID.
void RestartDevice ()
 Request a device reboot via CAN command.

Static Public Member Functions

static constexpr int32_t GetDefaultOffsetMm ()
 Get the fixed default offset in millimeters compiled into the library.

Public Attributes

AM_LidarData data

Additional Inherited Members

Protected Member Functions inherited from CanDevice
void SendCANMessage (int apiID, const uint8_t *data, int length)
 Low-level helper to transmit a CAN packet.
bool ReceiveCANMessage (int apiID, frc::CANData *, int timeoutMs)
 Receive a packet with a specific API ID, optionally waiting up to timeout.
Protected Attributes inherited from CanDevice
frc::CAN m_can
int m_deviceID
int deviceManufacturer
int deviceType

Detailed Description

ToF/Lidar sensor device.

Retrieves distance, status, flags, timestamp, and optional debug signal data from the device over CAN.

Offsets:

  • A fixed default offset (AM_LIDAR_DEFAULT_OFFSET_MM) is always applied.
  • Teams can apply an additional runtime offset via SetUserOffsetMm().
  • Total applied offset = default + user.

Positive offsets increase reported distance, negative offsets decrease it.

Constructor & Destructor Documentation

◆ AM_CANLidar()

AM_CANLidar::AM_CANLidar ( int deviceID)
explicit

Construct a CAN lidar sensor with the given CAN ID.

Parameters
deviceIDThe device's CAN ID.

Member Function Documentation

◆ GetAmbientCentiMcps()

uint16_t AM_CANLidar::GetAmbientCentiMcps ( ) const

Get the ambient light level of the last debug sample.

◆ GetData() [1/2]

AM_LidarData AM_CANLidar::GetData ( )

Fetch the most recent lidar reading using the default timeout.

Returns
A filled AM_LidarData struct.

◆ GetData() [2/2]

AM_LidarData AM_CANLidar::GetData ( int timeoutMs)

Fetch lidar reading with a custom timeout applied to the CAN read.

Parameters
timeoutMsTimeout in milliseconds for the CAN read.
Returns
A filled AM_LidarData struct.

◆ GetDebugData()

AM_LidarDebugData AM_CANLidar::GetDebugData ( int timeoutMs = 50)

Retrieve the latest debug information from the sensor.

Attempts to read a debug CAN frame. If a new frame is not available within the timeout, the most recently cached debug data is returned instead.

Parameters
timeoutMsTimeout for the CAN read.
Returns
Debug data structure containing signal diagnostics.

◆ GetDefaultOffsetMm()

constexpr int32_t AM_CANLidar::GetDefaultOffsetMm ( )
inlinestaticconstexpr

Get the fixed default offset in millimeters compiled into the library.

◆ GetPeakSignalCentiMcps()

uint16_t AM_CANLidar::GetPeakSignalCentiMcps ( ) const

Get the peak signal strength of the last debug sample.

◆ GetUserOffsetMm()

int32_t AM_CANLidar::GetUserOffsetMm ( ) const

Get the currently configured runtime (user) offset in millimeters.

◆ HasDebugData()

bool AM_CANLidar::HasDebugData ( ) const

Returns true if at least one debug frame has been received.

◆ ResetReportPeriod()

void AM_CANLidar::ResetReportPeriod ( )

Reset device report period to default (50ms).

◆ SetDistanceMode()

bool AM_CANLidar::SetDistanceMode ( AM_LidarDistanceMode mode)

Set the VL53L1X distance mode on the device.

Parameters
modeDistance mode value to send to the device firmware.
Returns
True if the request frame was queued.

◆ SetIntermeasurementPeriodMs()

bool AM_CANLidar::SetIntermeasurementPeriodMs ( uint32_t periodMs)

Set intermeasurement period on the device.

Parameters
periodMsPeriod in milliseconds.
Returns
True if the request frame was queued.

◆ SetMeasurementTimingBudgetUs()

bool AM_CANLidar::SetMeasurementTimingBudgetUs ( uint32_t budgetUs)

Set measurement timing budget on the device.

Parameters
budgetUsTiming budget in microseconds.
Returns
True if the request frame was queued.

◆ SetMinSignalRate()

bool AM_CANLidar::SetMinSignalRate ( float mcps)

Set the minimum signal rate threshold on the device.

Units are MCPS.

Parameters
mcpsMinimum signal rate in MCPS.
Returns
True if the request frame was queued.

◆ SetOffsetDegrees()

void AM_CANLidar::SetOffsetDegrees ( double degrees)

◆ SetReportPeriod()

void AM_CANLidar::SetReportPeriod ( int periodMs)

Set periodic report period (ms) for device reports.

Parameters
periodMsPeriod in milliseconds.

◆ SetROICenter()

bool AM_CANLidar::SetROICenter ( uint8_t centerSpad)

Set the ROI center SPAD on the device.

Parameters
centerSpadSPAD number to use as ROI center.
Returns
True if the request frame was queued.

◆ SetROISize()

bool AM_CANLidar::SetROISize ( uint8_t width,
uint8_t height )

Set the ROI size on the device.

Parameters
widthROI width in SPADs.
heightROI height in SPADs.
Returns
True if the request frame was queued.

◆ SetSigmaThreshold()

bool AM_CANLidar::SetSigmaThreshold ( uint16_t sigma)

Set the VL53L1X sigma threshold register value.

Parameters
sigmaRaw sigma threshold register value.
Returns
True if the request frame was queued.

◆ SetTimeoutMs()

bool AM_CANLidar::SetTimeoutMs ( uint16_t timeoutMs)

Set the lidar library read timeout on the device.

Parameters
timeoutMsTimeout in milliseconds.
Returns
True if the request frame was queued.

◆ SetUserOffsetMm()

void AM_CANLidar::SetUserOffsetMm ( int32_t offsetMm)

Set an additional runtime offset applied on top of the default offset.

Parameters
offsetMmAdditional offset in millimeters.

Total offset applied to returned readings is:

AM_LIDAR_DEFAULT_OFFSET_MM + offsetMm

Member Data Documentation

◆ data

AM_LidarData AM_CANLidar::data

Last received data cached in the object (distance includes offsets).


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