|
Voyant API 0.16.0
|
Client for receiving frames from a Carbon LiDAR sensor. More...
#include <carbon_client.hpp>
Public Member Functions | |
| CarbonClient (const CarbonConfig &config) | |
| Construct a CarbonClient from a CarbonConfig. The config is cloned internally — it remains valid after this call. | |
| ~CarbonClient () | |
| CarbonClient (const CarbonClient &)=delete | |
| CarbonClient & | operator= (const CarbonClient &)=delete |
| CarbonClient (CarbonClient &&)=delete | |
| CarbonClient & | operator= (CarbonClient &&)=delete |
| bool | start () |
| Start receiving and processing data. | |
| void | stop () |
| Stop receiving and processing data. Safe to call multiple times. Can restart with start(). | |
| bool | isRunning () const |
| Returns true if the client is running and no shutdown has been requested. | |
| bool | tryReceiveFrame () |
| Try to receive the next frame from the internal buffer. | |
| VoyantFrameWrapper & | latestFrame () |
| Access the frame most recently dequeued by tryReceiveFrame(). | |
| const VoyantFrameWrapper & | latestFrame () const |
| SensorState | getSensorState () const |
| Get the latest sensor state from the most recent heartbeat. | |
| TimeSyncState | getTimeSyncState () const |
| Get the latest host↔FPGA time-sync state (quality, offset, jitter). | |
| SdlStatus | sendSdl (const SdlCommandParams &cmd) |
| Send an SDL command to the sensor FPGA without blocking. | |
| SdlStatus | pollSdl () |
| Poll for SDL command confirmation after sendSdl(). | |
| SdlStatus | sendSdlBlocking (const SdlCommandParams &cmd) |
| Send an SDL command and block until it is confirmed or times out. | |
| bool | waitForHeartbeat () |
| Block until the sensor's first heartbeat arrives, or a fixed timeout elapses. | |
| bool | ensureIdleForCalibration () |
| Drive the sensor to Idle using the fixed background-noise calibration config, blocking until confirmed. | |
| bool | applyDefaultBackgroundNoise () |
| Apply the compiled-in default background-noise calibration for the connected box, blocking until done. | |
| bool | refineBackgroundNoise (uint32_t iterations=0) |
| Refine the background-noise calibration for the connected box from a covered-window capture, blocking until done (roughly 10–20 seconds). | |
| bool | startPeakDump (const std::string &path, uint64_t maxFrames=0, uint64_t maxPeaks=0, bool addTimestamp=false) |
| Begin dumping the raw peak stream to a CSV file while the point cloud keeps running. The client must be running. | |
| void | stopPeakDump () |
| Request the active peak dump to stop. Returns immediately; the file ends on a whole frame. Poll isPeakDumping() for completion. | |
| bool | isPeakDumping () const |
| Returns true while a peak dump is running. | |
Static Public Member Functions | |
| static void | setupSignalHandling (int signal=SIGINT) |
| Set up OS signal handling for graceful termination. | |
| static bool | isTerminated () |
| Returns true if a termination signal has been received. | |
| static void | resetTerminationFlag () |
| Resets the termination flag. | |
Static Private Member Functions | |
| static void | signalHandler (int) |
Private Attributes | |
| CarbonClientHandleC * | handle_ |
| std::unique_ptr< uint8_t[]> | buffer_ |
| VoyantFrameWrapper | latestFrame_ |
Static Private Attributes | |
| static constexpr size_t | kBufferSize_ = 8 * 1024 * 1024 |
| static volatile std::sig_atomic_t | terminated_ |
Client for receiving frames from a Carbon LiDAR sensor.
Example:
|
explicit |
Construct a CarbonClient from a CarbonConfig. The config is cloned internally — it remains valid after this call.
| config | CarbonConfig with all desired settings. |
| std::runtime_error | if client creation fails. |
| CarbonClient::~CarbonClient | ( | ) |
|
delete |
|
delete |
| bool CarbonClient::applyDefaultBackgroundNoise | ( | ) |
Apply the compiled-in default background-noise calibration for the connected box, blocking until done.
Writes the built-in default mask. The sensor must be in Idle; this does not change the sensor's state. Blocks for a few seconds.
| bool CarbonClient::ensureIdleForCalibration | ( | ) |
Drive the sensor to Idle using the fixed background-noise calibration config, blocking until confirmed.
Both calibration operations require Idle on entry; this reaches it from any state.
| SensorState CarbonClient::getSensorState | ( | ) | const |
Get the latest sensor state from the most recent heartbeat.
| TimeSyncState CarbonClient::getTimeSyncState | ( | ) | const |
Get the latest host↔FPGA time-sync state (quality, offset, jitter).
Returns a snapshot — call again to get updated values. Reads SyncQuality::Unsynced until the background time-sync task records its first measurement (or if time-sync is disabled in the config).
| bool CarbonClient::isPeakDumping | ( | ) | const |
Returns true while a peak dump is running.
| bool CarbonClient::isRunning | ( | ) | const |
Returns true if the client is running and no shutdown has been requested.
|
static |
Returns true if a termination signal has been received.
| VoyantFrameWrapper & CarbonClient::latestFrame | ( | ) |
Access the frame most recently dequeued by tryReceiveFrame().
Only valid after a successful tryReceiveFrame() call.
| const VoyantFrameWrapper & CarbonClient::latestFrame | ( | ) | const |
|
delete |
|
delete |
| SdlStatus CarbonClient::pollSdl | ( | ) |
Poll for SDL command confirmation after sendSdl().
This belongs with the lower-level non-blocking sendSdl() path. For normal SDL commands, prefer sendSdlBlocking().
| bool CarbonClient::refineBackgroundNoise | ( | uint32_t | iterations = 0 | ) |
Refine the background-noise calibration for the connected box from a covered-window capture, blocking until done (roughly 10–20 seconds).
The sensor must be in Idle on entry and the window must be covered (the capture assumes background noise only). Cycles the sensor between Idle and Point Cloud internally and returns to Idle when finished. While it runs, SDL commands and peak dumps on this client are rejected; do not run a second client against the sensor.
| iterations | Refinement iterations, or 0 to use the built-in default. |
|
static |
Resets the termination flag.
| SdlStatus CarbonClient::sendSdl | ( | const SdlCommandParams & | cmd | ) |
Send an SDL command to the sensor FPGA without blocking.
This is the non-blocking path; drive pollSdl() to confirm. A PointCloud request is applied transparently as a two-step transition (settings in Idle, then PointCloud resumed), advanced by pollSdl(). For commands where blocking is acceptable, prefer sendSdlBlocking().
| cmd | SdlCommandParams configured with the desired sensor parameters. |
| SdlStatus CarbonClient::sendSdlBlocking | ( | const SdlCommandParams & | cmd | ) |
Send an SDL command and block until it is confirmed or times out.
Use this for normal SDL commands: it sends the command, applies the requested settings, and waits for the sensor to confirm. A PointCloud request is applied as a two-step transition (settings in Idle, then PointCloud); the timeout from CarbonConfig sdl.timeout_sec is enforced per command, so it can take up to roughly twice that long.
| cmd | SdlCommandParams to send. |
|
static |
Set up OS signal handling for graceful termination.
| signal | Signal to handle (default: SIGINT) |
|
staticprivate |
| bool CarbonClient::start | ( | ) |
Start receiving and processing data.
| bool CarbonClient::startPeakDump | ( | const std::string & | path, |
| uint64_t | maxFrames = 0, | ||
| uint64_t | maxPeaks = 0, | ||
| bool | addTimestamp = false ) |
Begin dumping the raw peak stream to a CSV file while the point cloud keeps running. The client must be running.
The first of maxFrames / maxPeaks to be hit ends the dump (pass 0 for unbounded). addTimestamp inserts a timestamp into the filename. The writer runs on its own thread, so this returns immediately; poll isPeakDumping() for completion.
| path | Output CSV path. |
| maxFrames | Stop after this many whole frames, or 0 for unbounded. |
| maxPeaks | Stop after this many CSV rows, or 0 for unbounded. |
| addTimestamp | Insert a timestamp into the filename. |
| void CarbonClient::stop | ( | ) |
Stop receiving and processing data. Safe to call multiple times. Can restart with start().
| void CarbonClient::stopPeakDump | ( | ) |
Request the active peak dump to stop. Returns immediately; the file ends on a whole frame. Poll isPeakDumping() for completion.
| bool CarbonClient::tryReceiveFrame | ( | ) |
Try to receive the next frame from the internal buffer.
Frames are delivered oldest-first. If the pipeline produces frames faster than the caller consumes them, the small buffer fills and the newest incoming frames are dropped.
| bool CarbonClient::waitForHeartbeat | ( | ) |
Block until the sensor's first heartbeat arrives, or a fixed timeout elapses.
SDL confirmation and both background-noise calibration operations need a heartbeat first — the box serial and the frame counter used for confirmation come from it.
|
private |
|
private |
|
staticconstexprprivate |
|
private |
|
staticprivate |