Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
CameraHandler Class Reference

The CameraHandler class is responsible for managing all of the camera feeds that Autonomy_Software uses for computer vision. Whether it be a USB webcam, a MJPEG stream, or a ZED camera, this class is responsible for initializing that camera and configuring it. More...

#include <CameraHandler.h>

Public Types

enum class  ZEDCamName { ZEDCAM_START , eHeadMainCam , ZEDCAM_END }
 
enum class  BasicCamName { BASICCAM_START , eHeadGroundCam , BASICCAM_END }
 

Public Member Functions

 CameraHandler ()
 Construct a new Camera Handler Thread:: Camera Handler Thread object.
 
 ~CameraHandler ()
 Destroy the Camera Handler Thread:: Camera Handler Thread object.
 
void StartAllCameras ()
 Signals all cameras to start their threads.
 
void StartRecording ()
 Signal the RecordingHandler to start recording video feeds from the CameraHandler.
 
void StopAllCameras ()
 Signals all cameras to stop their threads.
 
void StopRecording ()
 Signal the RecordingHandler to stop recording video feeds from the CameraHandler.
 
std::shared_ptr< ZEDCameraGetZED (ZEDCamName eCameraName)
 Accessor for ZED cameras.
 
std::shared_ptr< BasicCameraGetBasicCam (BasicCamName eCameraName)
 Accessor for Basic cameras.
 

Private Attributes

std::shared_ptr< ZEDCameram_pMainCam
 
std::shared_ptr< BasicCameram_pGroundCam
 
std::unique_ptr< RecordingHandlerm_pRecordingHandler
 

Detailed Description

The CameraHandler class is responsible for managing all of the camera feeds that Autonomy_Software uses for computer vision. Whether it be a USB webcam, a MJPEG stream, or a ZED camera, this class is responsible for initializing that camera and configuring it.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17

Member Enumeration Documentation

◆ ZEDCamName

enum class CameraHandler::ZEDCamName
strong
50 {
51 ZEDCAM_START,
52 eHeadMainCam,
53 ZEDCAM_END
54 };

◆ BasicCamName

enum class CameraHandler::BasicCamName
strong
57 {
58 BASICCAM_START,
59 eHeadGroundCam,
60 BASICCAM_END
61 };

Constructor & Destructor Documentation

◆ CameraHandler()

CameraHandler::CameraHandler ( )

Construct a new Camera Handler Thread:: Camera Handler Thread object.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
26{
27 // Check if we are in simulation mode.
28 if (!constants::MODE_SIM)
29 {
30 // Initialize main ZED camera.
31 m_pMainCam = std::make_shared<ZEDCam>(constants::ZED_MAINCAM_RESOLUTIONX,
32 constants::ZED_MAINCAM_RESOLUTIONY,
33 constants::ZED_MAINCAM_FPS,
34 constants::ZED_MAINCAM_HORIZONTAL_FOV,
35 constants::ZED_MAINCAM_VERTICAL_FOV,
36 constants::ZED_MAINCAM_ENABLE_RECORDING,
37 constants::ZED_MAINCAM_EXPORT_SVO_RECORDING,
38 constants::ZED_DEFAULT_MINIMUM_DISTANCE,
39 constants::ZED_DEFAULT_MAXIMUM_DISTANCE,
40 constants::ZED_MAINCAM_USE_GPU_MAT,
41 constants::ZED_MAINCAM_USE_HALF_PRECISION_DEPTH,
42 constants::ZED_MAINCAM_FUSION_MASTER,
43 constants::ZED_MAINCAM_FRAME_RETRIEVAL_THREADS,
44 constants::ZED_MAINCAM_SERIAL);
45
46 // Always enable positional tracking.
47 m_pMainCam->EnablePositionalTracking();
48
49 // Additional setup for main ZED camera.
50 if (constants::ZED_MAINCAM_EXPORT_SPATIAL_MAP)
51 {
52 m_pMainCam->EnableSpatialMapping();
53 }
54 }
55 else
56 {
57 m_pMainCam = std::make_shared<SIMZEDCam>("ws://" + constants::SIM_IP_ADDRESS + ":" + std::to_string(constants::SIM_WEBSOCKET_PORT),
58 constants::ZED_MAINCAM_RESOLUTIONX,
59 constants::ZED_MAINCAM_RESOLUTIONY,
60 constants::ZED_MAINCAM_FPS,
61 constants::ZED_MAINCAM_HORIZONTAL_FOV,
62 constants::ZED_MAINCAM_VERTICAL_FOV,
63 constants::ZED_MAINCAM_ENABLE_RECORDING,
64 constants::ZED_MAINCAM_FRAME_RETRIEVAL_THREADS,
65 constants::ZED_MAINCAM_SERIAL);
66 }
67
68 // Initialize ground eye.
69 m_pGroundCam = std::make_shared<BasicCam>(constants::BASICCAM_GROUNDCAM_INDEX,
70 constants::BASICCAM_GROUNDCAM_RESOLUTIONX,
71 constants::BASICCAM_GROUNDCAM_RESOLUTIONY,
72 constants::BASICCAM_GROUNDCAM_FPS,
73 constants::BASICCAM_GROUNDCAM_PIXELTYPE,
74 constants::BASICCAM_GROUNDCAM_HORIZONTAL_FOV,
75 constants::BASICCAM_GROUNDCAM_VERTICAL_FOV,
76 constants::BASICCAM_GROUNDCAM_ENABLE_RECORDING,
77 constants::BASICCAM_GROUNDCAM_FRAME_RETRIEVAL_THREADS);
78
79 // Initialize recording handler for cameras.
80 m_pRecordingHandler = std::make_unique<RecordingHandler>(RecordingHandler::RecordingMode::eCameraHandler);
81}

◆ ~CameraHandler()

CameraHandler::~CameraHandler ( )

Destroy the Camera Handler Thread:: Camera Handler Thread object.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
91{
92 // Signal and wait for cameras to stop.
93 this->StopAllCameras();
94}
void StopAllCameras()
Signals all cameras to stop their threads.
Definition CameraHandler.cpp:132
Here is the call graph for this function:

Member Function Documentation

◆ StartAllCameras()

void CameraHandler::StartAllCameras ( )

Signals all cameras to start their threads.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-09
104{
105 // Start ZED cams.
106 m_pMainCam->Start();
107
108 // Start basic cams.
109 // m_pGroundCam->Start();
110}
Here is the caller graph for this function:

◆ StartRecording()

void CameraHandler::StartRecording ( )

Signal the RecordingHandler to start recording video feeds from the CameraHandler.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-12-31
120{
121 // Start recording handler.
122 m_pRecordingHandler->Start();
123}
Here is the caller graph for this function:

◆ StopAllCameras()

void CameraHandler::StopAllCameras ( )

Signals all cameras to stop their threads.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-03
133{
134 // Stop recording handler.
135 m_pRecordingHandler->RequestStop();
136 m_pRecordingHandler->Join();
137
138 // Stop ZED cams.
139 m_pMainCam->RequestStop();
140 m_pMainCam->Join();
141
142 // Stop basic cams.
143 // m_pGroundCam->RequestStop();
144 // m_pGroundCam->Join();
145}
Here is the caller graph for this function:

◆ StopRecording()

void CameraHandler::StopRecording ( )

Signal the RecordingHandler to stop recording video feeds from the CameraHandler.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-01-01
155{
156 // Stop recording handler.
157 m_pRecordingHandler->RequestStop();
158 m_pRecordingHandler->Join();
159}

◆ GetZED()

std::shared_ptr< ZEDCamera > CameraHandler::GetZED ( ZEDCamName  eCameraName)

Accessor for ZED cameras.

Parameters
eCameraName- The name of the camera to retrieve. An enum defined in and specific to this class.
Returns
std::shared_ptr<ZEDCamera> - A pointer to the zed camera pertaining to the given name.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-01
171{
172 // Determine which camera should be returned.
173 switch (eCameraName)
174 {
175 case ZEDCamName::eHeadMainCam: return m_pMainCam; break; // Return the ZEDCam in the autonomy head.
176 default: return m_pMainCam; break;
177 }
178}
Here is the caller graph for this function:

◆ GetBasicCam()

std::shared_ptr< BasicCamera > CameraHandler::GetBasicCam ( BasicCamName  eCameraName)

Accessor for Basic cameras.

Parameters
eCameraName- The name of the camera to retrieve. An enum defined in and specific to this class.
Returns
std::shared_ptr<BasicCamera> - A pointer to the basic camera pertaining to the given name.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-01
190{
191 // Determine which camera should be returned.
192 switch (eCameraName)
193 {
194 case BasicCamName::eHeadGroundCam: return m_pGroundCam; break; // Return the ground fisheye cam in the autonomy head.
195 default: return m_pGroundCam; break;
196 }
197}
Here is the caller graph for this function:

The documentation for this class was generated from the following files: