Autonomy Software Binder

Central engineering reference and operations manual for the MRDT Autonomy Software.

View the Project on GitHub MissouriMRDT/Autonomy_Software

Return to RoveSoDocs Guides for Today, Tomorrow, and Forever.

Camera Handler

The CameraHandler class (src/handlers/CameraHandler.h & CameraHandler.cpp) manages camera hardware lifecycle, initializes camera worker threads, provides centralized access to video feeds, and controls asynchronous video recording.


1. Primary Responsibilities

  1. Hardware Detection and Configuration: Detects, instantiates, and starts camera objects based on compilation flags (BUILD_SIM_MODE) and configuration settings (MODE_REAR_ZED).
  2. Global Feed Registry: Exposes thread-safe getters (GetZED(), GetBasicCam()) accessible via globals::g_pCameraHandler to allow detector handlers to retrieve shared pointers to active camera streams.
  3. Simulation Abstraction: Automatically instantiates SIMZEDCam (WebRTC / LibDataChannel) when BUILD_SIM_MODE is enabled, or physical ZEDCam (ZED SDK 4.x) when running on physical hardware.
  4. Recording Coordination: Spawns an internal RecordingHandler instance to write raw camera feeds to disk without blocking computer vision processing.

2. Managed Cameras

The handler manages cameras designated by ZEDCamName and BasicCamName enumerations:


3. Concurrency and Integration


4. Usage Example

// Startup sequence (in main.cpp)
globals::g_pCameraHandler = new CameraHandler();
globals::g_pCameraHandler->StartAllCameras();
globals::g_pCameraHandler->StartRecording();

// Accessing cameras in downstream modules:
std::shared_ptr<ZEDCamera> pMainCam = globals::g_pCameraHandler->GetZED(CameraHandler::ZEDCamName::eHeadMainCam);

// Asynchronously request color frame and point cloud
cv::Mat cvFrame;
cv::Mat cvPointCloud;
std::future<bool> fuFrame = pMainCam->RequestFrameCopy(cvFrame);
std::future<bool> fuCloud = pMainCam->RequestPointCloudCopy(cvPointCloud);

if (fuFrame.get() && fuCloud.get())
{
    // Execute computer vision and 3D geolocation
}