Voyant API 1.0.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 <optional>
12#include <voyant_frame.hpp>
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
84 std::optional<VoyantFrame> tryReceiveFrame();
85
91
102
128
142
152
162
174
188 bool refineBackgroundNoise(uint32_t iterations = 0);
189
207 bool startDiagnosticCapture(const std::string& path, bool overwrite = false);
208
214
219
226 std::string diagnosticCaptureError() const;
227
232 static void setupSignalHandling(int signal = SIGINT);
233
237 static bool isTerminated();
238
242 static void resetTerminationFlag();
243
244private:
245 CarbonClientHandleC* handle_; // opaque pointer — type defined in carbon_client_ffi.hpp
246
247 static volatile std::sig_atomic_t terminated_;
248 static void signalHandler(int);
249};
250
264
280SdlCommandParams 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.
std::string diagnosticCaptureError() const
Why the last diagnostic capture ended badly, if it did.
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...
static volatile std::sig_atomic_t terminated_
Definition carbon_client.hpp:247
SdlStatus pollSdl()
Poll for SDL command confirmation after sendSdl().
bool waitForHeartbeat()
Block until the sensor's first heartbeat arrives, or a fixed timeout elapses.
void stopDiagnosticCapture()
Request the active diagnostic capture to stop. Returns immediately; the file ends on a whole frame....
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.
std::optional< VoyantFrame > tryReceiveFrame()
Try to receive the next frame from the internal buffer.
CarbonClientHandleC * handle_
Definition carbon_client.hpp:245
CarbonClient(const CarbonConfig &config)
Construct a CarbonClient from a CarbonConfig. The config is cloned internally — it remains valid afte...
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.
bool isDiagnosticCapturing() const
Returns true while a diagnostic capture is running.
bool startDiagnosticCapture(const std::string &path, bool overwrite=false)
Begin a diagnostic capture for Voyant support: the raw peak stream is written to a ....
TimeSyncState getTimeSyncState() const
Get the latest host↔FPGA time-sync state (quality, offset, jitter).
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
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.
Configuration for the Carbon LiDAR pipeline.
Definition carbon_config.hpp:29
SdlState
Enum for sdl::set_state register.
Definition sdl_types_generated.hpp:20
Definition carbon_client_ffi.hpp:49
Definition voyant_types_ffi.hpp:350
Definition voyant_types_ffi.hpp:519
SdlStatus
Definition voyant_types_ffi.hpp:52