Ex: SDL Command
Reconfigure a Carbon sensor at runtime with C++.
This example demonstrates how to send a Software Defined LiDAR (SDL) command to a Carbon sensor. SDL commands change the sensor’s operating state, field of view, frame rate, and waveform parameters at runtime — no restart required.
What You’ll Learn
- How to build an
SdlCommandParamsfrom the current sensor state - How to apply settings with the recommended blocking path (
sendSdlBlocking) - How the non-blocking
sendSdl/pollSdlpath fits an event loop
Prerequisites
- Voyant SDK installed (see Installation)
- A Carbon sensor, or the bundled
carbon_simulatorrunning locally (pass--sim)
Example Code
View the complete example on GitHub: sdl_command.cpp
Key Concepts
Building the Command
Wait for a heartbeat, then build the command from the sensor’s current read-back with toSdlCommand() and override only the fields you want to change:
SdlCommandParams cmd = toSdlCommand(state);
cmd.req_state = static_cast<uint8_t>(SdlState::PointCloud);
cmd.hfov_deg = 60.0f;
cmd.hfov_center_deg = 0.0f; // steering not yet supported — keep at 0
cmd.frame_rate_fps = 10.0f;
cmd.ramp_bandwidth_ghz = 6.0f;
// ramp_length is firmware-fixed (16.384 µs) and read-back only; the build ignores it.
Applying It (Blocking)
sendSdlBlocking() sends the command and waits for the sensor to confirm. It returns an SdlStatus — SdlStatus::Applied on success:
SdlStatus status = client.sendSdlBlocking(cmd);
if (status != SdlStatus::Applied)
{
std::cerr << "SDL command failed: SdlStatus(" << static_cast<int>(status) << ")" << std::endl;
return 1;
}
Non-blocking Alternative
For event loops that must keep processing frames while a command is in flight, sendSdl() starts the command and pollSdl() drives it to completion. Poll until the status is no longer SdlStatus::Pending. The blocking path is recommended for normal use.
Building and Running
# Build the examples
mkdir build && cd build
cmake ..
make
# Run against a real sensor
./bin/sdl_command
# Or run against a local carbon_simulator
./bin/sdl_command --sim
Expected Output
Sending SDL command...
SDL command applied successfully.
Frame 1: Header{message type:2, device id:CAR-000, frame idx:41, ...}
Frame 2: Header{message type:2, device id:CAR-000, frame idx:42, ...}
...
Next Steps
- Live Client — inspect the frames your new configuration produces
- API Documentation — full
CarbonClientand SDL reference