Voyant API 0.16.0
Loading...
Searching...
No Matches
carbon_client.hpp
Go to the documentation of this file.
1// Copyright (c) 2024-2025 Voyant Photonics, Inc.
2// All rights reserved.
3
4#pragma once
5
7#include <carbon_config.hpp>
8#include <csignal>
9#include <cstdint>
10#include <memory>
13#include <voyant_types_ffi.hpp>
14
40{
41public:
48 explicit CarbonClient(const CarbonConfig& config);
49
51
52 // Non-copyable, non-movable (owns async runtime)
53 CarbonClient(const CarbonClient&) = delete;
57
62 bool start();
63
68 void stop();
69
73 bool isRunning() const;
74
85
93
99
110
136
150
160
170
182
196 bool refineBackgroundNoise(uint32_t iterations = 0);
197
213 bool startPeakDump(const std::string& path, uint64_t maxFrames = 0, uint64_t maxPeaks = 0, bool addTimestamp = false);
214
220
224 bool isPeakDumping() const;
225
230 static void setupSignalHandling(int signal = SIGINT);
231
235 static bool isTerminated();
236
240 static void resetTerminationFlag();
241
242private:
243 CarbonClientHandleC* handle_; // opaque pointer — type defined in carbon_client_ffi.hpp
244 std::unique_ptr<uint8_t[]> buffer_;
245 static constexpr size_t kBufferSize_ = 8 * 1024 * 1024; // 8MB
247
248 static volatile std::sig_atomic_t terminated_;
249 static void signalHandler(int);
250};
251
265
281SdlCommandParams makeLinescanCommand(SdlState reqState, float rampBandwidthGhz, float hfovCenterDeg = 0.0f);
SdlCommandParams makeLinescanCommand(SdlState reqState, float rampBandwidthGhz, float hfovCenterDeg=0.0f)
Build a static-line (linescan) SdlCommandParams.
SdlCommandParams toSdlCommand(const SensorState &state)
Convert a heartbeat-confirmed SensorState into a sendable SdlCommandParams.
static void resetTerminationFlag()
Resets the termination flag.
CarbonClient(CarbonClient &&)=delete
bool applyDefaultBackgroundNoise()
Apply the compiled-in default background-noise calibration for the connected box, blocking until done...
bool ensureIdleForCalibration()
Drive the sensor to Idle using the fixed background-noise calibration config, blocking until confirme...
VoyantFrameWrapper latestFrame_
Definition carbon_client.hpp:246
static volatile std::sig_atomic_t terminated_
Definition carbon_client.hpp:248
SdlStatus pollSdl()
Poll for SDL command confirmation after sendSdl().
const VoyantFrameWrapper & latestFrame() const
bool waitForHeartbeat()
Block until the sensor's first heartbeat arrives, or a fixed timeout elapses.
static bool isTerminated()
Returns true if a termination signal has been received.
SdlStatus sendSdl(const SdlCommandParams &cmd)
Send an SDL command to the sensor FPGA without blocking.
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....
CarbonClientHandleC * handle_
Definition carbon_client.hpp:243
CarbonClient(const CarbonConfig &config)
Construct a CarbonClient from a CarbonConfig. The config is cloned internally — it remains valid afte...
VoyantFrameWrapper & latestFrame()
Access the frame most recently dequeued by tryReceiveFrame().
bool isPeakDumping() const
Returns true while a peak dump is running.
bool isRunning() const
Returns true if the client is running and no shutdown has been requested.
bool start()
Start receiving and processing data.
SdlStatus sendSdlBlocking(const SdlCommandParams &cmd)
Send an SDL command and block until it is confirmed or times out.
TimeSyncState getTimeSyncState() const
Get the latest host↔FPGA time-sync state (quality, offset, jitter).
std::unique_ptr< uint8_t[]> buffer_
Definition carbon_client.hpp:244
bool refineBackgroundNoise(uint32_t iterations=0)
Refine the background-noise calibration for the connected box from a covered-window capture,...
SensorState getSensorState() const
Get the latest sensor state from the most recent heartbeat.
CarbonClient & operator=(const CarbonClient &)=delete
static constexpr size_t kBufferSize_
Definition carbon_client.hpp:245
CarbonClient(const CarbonClient &)=delete
void stop()
Stop receiving and processing data. Safe to call multiple times. Can restart with start().
CarbonClient & operator=(CarbonClient &&)=delete
static void signalHandler(int)
static void setupSignalHandling(int signal=SIGINT)
Set up OS signal handling for graceful termination.
void stopPeakDump()
Request the active peak dump to stop. Returns immediately; the file ends on a whole frame....
bool tryReceiveFrame()
Try to receive the next frame from the internal buffer.
Configuration for the Carbon LiDAR pipeline.
Definition carbon_config.hpp:29
Wrapper for VoyantFrame messages.
Definition voyant_frame_wrapper.hpp:19
SdlState
Enum for sdl::set_state register.
Definition sdl_types_generated.hpp:20
Definition carbon_client_ffi.hpp:51
Definition voyant_types_ffi.hpp:326
Definition voyant_types_ffi.hpp:344
SdlStatus
Definition voyant_types_ffi.hpp:50