PerceptionController

Aggregator for the perception service's three features.

#include <perception_controller.hpp>

Classes

class PerceptionController

Manages the three perception-service features on a vehicle.

Lifetime is bound to the owning Vehicle. Obtain via `vehicle.GetPerceptionController()`. The returned reference is stable for the vehicle's lifetime.

Three features: - Distance Detection — proximity / ranging from attached ranging sensors. - Mapping — 2D / 3D occupancy and pose tracking. - Object Detection — labeled detections from camera frames.

Each feature is independently available: query its `IsAvailable()` to know whether a sensor is currently backing it. Callers can still call the data methods when unavailable — they return empty values.

DistanceDetector& GetDistanceDetector()

Returns the Distance Detection feature for this vehicle.

Returns: Reference to the DistanceDetector. Stable for the vehicle's lifetime.

MappingService& GetMappingService()

Returns the Mapping feature for this vehicle.

Returns: Reference to the MappingService. Stable for the vehicle's lifetime.

ObjectDetector& GetObjectDetector()

Returns the Object Detection feature for this vehicle.

Returns: Reference to the ObjectDetector. Stable for the vehicle's lifetime.

std::vector<SensorInfo> GetSensors() const

Snapshot of perception sensors currently attached to the vehicle, with the capability bits they expose.

Returned by value to avoid lifetime questions; safe to call from any thread. Order is implementation-defined but stable within a session.

Returns: Vector of SensorInfo descriptors, one per attached sensor.

bool EnableLidar(bool enable)

Enable/disable the vehicle's primary LiDAR.

No-op (returns false) if the vehicle has no controllable LiDAR.

ParameterTypeDescription
enable bool true to power the LiDAR on, false to power it off.

Returns: true if the command was accepted, false otherwise.

bool IsLidarEnabled() const

Reports the LiDAR's last-commanded power state.

Returns: true if enabled (default), false if disabled via EnableLidar().

bool ConnectRemote(const std::string& multicast_addr, uint16_t port, const std::string& iface_addr = "")

Join the multicast group and start receiving perception data.

ParameterTypeDescription
multicast_addr const std::string& Multicast group IP (e.g. "224.0.0.2"). Must
port uint16_t UDP port to bind / receive on (e.g. 14596).
iface_addr const std::string& Interface to join the group on. Empty

Returns: true on success; false if socket setup or multicast join

void Disconnect()

Stop receiving and release the socket. Safe to call from any thread.

bool IsConnected() const

True when ConnectRemote has succeeded and the receive thread is running.

Returns: false before the first ConnectRemote call or after Disconnect().

bool ReadLatestFrameRaw(void* dst, size_t dst_size) const

Copy the latest cached perception frame into `dst`.

Pure pull-mode copy. Use this when you need the raw frame payload (e.g. from an FFI bridge) and the typed feature accessors are not available.

ParameterTypeDescription
dst void* Opaque pointer to an internal frame buffer. The
dst_size size_t Size of `dst` in bytes. Must match the expected

Returns: true if a fresh frame was copied; false if no frame is

bool ReadLatestFrameRaw(std::span<std::byte> dst) const

Bounds-carrying overload of ReadLatestFrameRaw for C++ callers.

Equivalent to `ReadLatestFrameRaw(dst.data(), dst.size())`, but the span carries its own size so callers can't pass a mismatched length. Prefer this from C++; the `void*` overload remains for FFI bridges.

ParameterTypeDescription
dst std::span<std::byte> Destination buffer sized to exactly one frame.

Returns: true if a fresh frame was copied; false otherwise (same

void BindInternalModules(void* vehicle_app_module)

No-op when using remote-mode connectivity. Use ConnectRemote to establish a perception data subscription.

ParameterTypeDescription
vehicle_app_module void* Opaque pointer to an internal module handle.