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
Camera< T > Class Template Referenceabstract

This interface class serves as a base for all other classes that will implement and interface with a type of camera. More...

#include <Camera.hpp>

Inheritance diagram for Camera< T >:
Collaboration diagram for Camera< T >:

Classes

struct  Pose
 Defines a simple struct to hold pose data. More...
 

Public Member Functions

 Camera (const int nPropResolutionX, const int nPropResolutionY, const int nPropFramesPerSecond, const PIXEL_FORMATS ePropPixelFormat, const double dPropHorizontalFOV, const double dPropVerticalFOV, const bool bEnableRecordingFlag, const int nNumFrameRetrievalThreads=5)
 Construct a new Camera object.
 
virtual ~Camera ()
 Destroy the Camera object.
 
void SetEnableRecordingFlag (const bool bEnableRecordingFlag)
 Mutator for the Enable Recording Flag private member.
 
void SetCameraPoseOffset (const Pose &stPoseOffset)
 Mutator for the Camera Pose Offset private member.
 
void SetCameraPoseOffset (const double dPosX, const double dPosY, const double dPosZ, const double dQX, const double dQY, const double dQZ, const double dQW)
 Mutator for the Camera Pose Offset private member.
 
cv::Size GetPropResolution () const
 Accessor for the Prop Resolution private member.
 
int GetPropFramesPerSecond () const
 Accessor for the Prop Frames Per Second private member.
 
PIXEL_FORMATS GetPropPixelFormat () const
 Accessor for the Prop Pixel Format private member.
 
double GetPropHorizontalFOV () const
 Accessor for the Prop Horizontal F O V private member.
 
double GetPropVerticalFOV () const
 Accessor for the Prop Vertical F O V private member.
 
bool GetEnableRecordingFlag () const
 Accessor for the Enable Recording Flag private member.
 
Pose GetCameraPoseOffset () const
 Accessor for the Camera Pose Offset private member.
 
virtual bool GetCameraIsOpen ()=0
 Accessor for the Camera Is Open private member.
 
- Public Member Functions inherited from AutonomyThread< void >
 AutonomyThread ()
 Construct a new Autonomy Thread object.
 
virtual ~AutonomyThread ()
 Destroy the Autonomy Thread object. If the parent object or main thread is destroyed or exited while this thread is still running, a race condition will occur. Stopping and joining the thread here insures that the main program can't exit if the user forgot to stop and join the thread.
 
void Start ()
 When this method is called, it starts a new thread that runs the code within the ThreadedContinuousCode method. This is the users main code that will run the important and continuous code for the class.
 
void RequestStop ()
 Signals threads to stop executing user code, terminate. DOES NOT JOIN. This method will not force the thread to exit, if the user code is not written properly and contains WHILE statement or any other long-executing or blocking code, then the thread will not exit until the next iteration.
 
void Join ()
 Waits for thread to finish executing and then closes thread. This method will block the calling code until thread is finished.
 
bool Joinable () const
 Check if the code within the thread and all pools created by it are finished executing and the thread is ready to be closed.
 
AutonomyThreadState GetThreadState () const
 Accessor for the Threads State private member.
 
std::string GetThreadUUID () const
 Accessor for the Thread U U I D private member.
 
IPSGetIPS ()
 Accessor for the Frame I P S private member.
 
void SetMainThreadPriority (AutonomyThreadPriority ePriority)
 Set the OS priority for the main continuous thread.
 
void SetPoolThreadPriority (AutonomyThreadPriority ePriority)
 Set the OS priority for the highly parallelized pool threads.
 

Protected Member Functions

virtual std::future< bool > RequestFrameCopy (T &tFrame)=0
 
- Protected Member Functions inherited from AutonomyThread< void >
void RunPool (const unsigned int nNumTasksToQueue, const unsigned int nNumThreads=2, const bool bForceStopCurrentThreads=false)
 When this method is called, it starts/adds tasks to a thread pool that runs nNumTasksToQueue copies of the code within the PooledLinearCode() method using nNumThreads number of threads. This is meant to be used as an internal utility of the child class to further improve parallelization. Default value for nNumThreads is 2.
 
void RunDetachedPool (const unsigned int nNumTasksToQueue, const unsigned int nNumThreads=2, const bool bForceStopCurrentThreads=false)
 When this method is called, it starts a thread pool full of threads that don't return std::futures (like a placeholder for the thread return type). This means the thread will not have a return type and there is no way to determine if the thread has finished other than calling the Join() method. Only use this if you want to 'set and forget'. It will be faster as it doesn't return futures. Runs PooledLinearCode() method code. This is meant to be used as an internal utility of the child class to further improve parallelization.
 
void ParallelizeLoop (const int nNumThreads, const N tTotalIterations, F &&tLoopFunction)
 Given a ref-qualified looping function and an arbitrary number of iterations, this method will divide up the loop and run each section in a thread pool. This function must not return anything. This method will block until the loop has completed.
 
void ClearPoolQueue ()
 Clears any tasks waiting to be ran in the queue, tasks currently running will remain running.
 
void JoinPool ()
 Waits for pool to finish executing tasks. This method will block the calling code until thread is finished.
 
bool PoolJoinable () const
 Check if the internal pool threads are done executing code and the queue is empty.
 
void SetMainThreadIPSLimit (int nMaxIterationsPerSecond=0)
 Mutator for the Main Thread Max I P S private member.
 
int GetPoolNumOfThreads ()
 Accessor for the Pool Num Of Threads private member.
 
int GetPoolQueueLength ()
 Accessor for the Pool Queue Size private member.
 
std::vector< void > GetPoolResults ()
 Accessor for the Pool Results private member. The action of getting results will destroy and remove them from this object. This method blocks if the thread is not finished, so no need to call JoinPool() before getting results.
 
int GetMainThreadMaxIPS () const
 Accessor for the Main Thread Max I P S private member.
 

Protected Attributes

int m_nPropResolutionX
 
int m_nPropResolutionY
 
int m_nPropFramesPerSecond
 
int m_nNumFrameRetrievalThreads
 
PIXEL_FORMATS m_ePropPixelFormat
 
double m_dPropHorizontalFOV
 
double m_dPropVerticalFOV
 
Pose m_stCameraPoseOffset
 
std::atomic_bool m_bEnableRecordingFlag
 
std::queue< containers::FrameFetchContainer< T > > m_qFrameCopySchedule
 
std::shared_mutex m_muPoolScheduleMutex
 
std::shared_mutex m_muFrameCopyMutex
 
- Protected Attributes inherited from AutonomyThread< void >
IPS m_IPS
 

Additional Inherited Members

- Public Types inherited from AutonomyThread< void >
enum  AutonomyThreadState
 
enum  AutonomyThreadPriority
 

Detailed Description

template<class T>
class Camera< T >

This interface class serves as a base for all other classes that will implement and interface with a type of camera.

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

Constructor & Destructor Documentation

◆ Camera()

template<class T >
Camera< T >::Camera ( const int  nPropResolutionX,
const int  nPropResolutionY,
const int  nPropFramesPerSecond,
const PIXEL_FORMATS  ePropPixelFormat,
const double  dPropHorizontalFOV,
const double  dPropVerticalFOV,
const bool  bEnableRecordingFlag,
const int  nNumFrameRetrievalThreads = 5 
)
inline

Construct a new Camera object.

Parameters
nPropResolutionX- X res of camera.
nPropResolutionY- Y res of camera.
nPropFramesPerSecond- FPS camera is running at.
ePropPixelFormat- The pixel layout/format of the image.
dPropHorizontalFOV- The horizontal field of view.
dPropVerticalFOV- The vertical field of view.
bEnableRecordingFlag- Whether or not this camera should be recorded.
Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-18
85 {
86 // Initialize member variables.
87 m_nPropResolutionX = nPropResolutionX;
88 m_nPropResolutionY = nPropResolutionY;
89 m_nPropFramesPerSecond = nPropFramesPerSecond;
90 m_ePropPixelFormat = ePropPixelFormat;
91 m_dPropHorizontalFOV = dPropHorizontalFOV;
92 m_dPropVerticalFOV = dPropVerticalFOV;
93 m_bEnableRecordingFlag = bEnableRecordingFlag;
94 m_nNumFrameRetrievalThreads = nNumFrameRetrievalThreads;
95 m_stCameraPoseOffset = Pose{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0};
96 }

◆ ~Camera()

template<class T >
virtual Camera< T >::~Camera ( )
inlinevirtual

Destroy the Camera object.

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

Member Function Documentation

◆ SetEnableRecordingFlag()

template<class T >
void Camera< T >::SetEnableRecordingFlag ( const bool  bEnableRecordingFlag)
inline

Mutator for the Enable Recording Flag private member.

Parameters
bEnableRecordingFlag- Whether or not recording should be enabled for this camera.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-12-26
115{ m_bEnableRecordingFlag = bEnableRecordingFlag; }

◆ SetCameraPoseOffset() [1/2]

template<class T >
void Camera< T >::SetCameraPoseOffset ( const Pose stPoseOffset)
inline

Mutator for the Camera Pose Offset private member.

Parameters
stPoseOffset- The pose offset of the camera from the rover center.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2026-01-09
125{ m_stCameraPoseOffset = stPoseOffset; }

◆ SetCameraPoseOffset() [2/2]

template<class T >
void Camera< T >::SetCameraPoseOffset ( const double  dPosX,
const double  dPosY,
const double  dPosZ,
const double  dQX,
const double  dQY,
const double  dQZ,
const double  dQW 
)
inline

Mutator for the Camera Pose Offset private member.

Parameters
dPosX- The X position of the camera offset.
dPosY- The Y position of the camera offset.
dPosZ- The Z position of the camera offset.
dQX- The X component of the quaternion rotation.
dQY- The Y component of the quaternion rotation.
dQZ- The Z component of the quaternion rotation.
dQW- The W component of the quaternion rotation.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2026-01-09
142 {
143 // Update member variable.
144 m_stCameraPoseOffset.dPosX = dPosX;
145 m_stCameraPoseOffset.dPosY = dPosY;
146 m_stCameraPoseOffset.dPosZ = dPosZ;
147 m_stCameraPoseOffset.dQX = dQX;
148 m_stCameraPoseOffset.dQY = dQY;
149 m_stCameraPoseOffset.dQZ = dQZ;
150 m_stCameraPoseOffset.dQW = dQW;
151 }

◆ GetPropResolution()

template<class T >
cv::Size Camera< T >::GetPropResolution ( ) const
inline

Accessor for the Prop Resolution private member.

Returns
cv::Size - The resolution of the camera stored in OpenCV's cv::Size.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-19
161{ return cv::Size(m_nPropResolutionX, m_nPropResolutionY); }
Size2i Size

◆ GetPropFramesPerSecond()

template<class T >
int Camera< T >::GetPropFramesPerSecond ( ) const
inline

Accessor for the Prop Frames Per Second private member.

Returns
int - The FPS of the camera.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-19
171{ return m_nPropFramesPerSecond; }

◆ GetPropPixelFormat()

template<class T >
PIXEL_FORMATS Camera< T >::GetPropPixelFormat ( ) const
inline

Accessor for the Prop Pixel Format private member.

Returns
PIXEL_FORMATS - The layout/pixel format of the image returned from the camera.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-19
182{ return m_ePropPixelFormat; }

◆ GetPropHorizontalFOV()

template<class T >
double Camera< T >::GetPropHorizontalFOV ( ) const
inline

Accessor for the Prop Horizontal F O V private member.

Returns
double - The horizontal field of view of the camera.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-19
192{ return m_dPropHorizontalFOV; }

◆ GetPropVerticalFOV()

template<class T >
double Camera< T >::GetPropVerticalFOV ( ) const
inline

Accessor for the Prop Vertical F O V private member.

Returns
double - The vertical field of view of the camera.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-19
202{ return m_dPropVerticalFOV; }

◆ GetEnableRecordingFlag()

template<class T >
bool Camera< T >::GetEnableRecordingFlag ( ) const
inline

Accessor for the Enable Recording Flag private member.

Returns
true - Recording for this camera has been requested/flagged.
false - This camera should not be recorded.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-12-26
213{ return m_bEnableRecordingFlag; }

◆ GetCameraPoseOffset()

template<class T >
Pose Camera< T >::GetCameraPoseOffset ( ) const
inline

Accessor for the Camera Pose Offset private member.

Returns
Pose - The pose offset of the camera from the rover center.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2026-01-09
223{ return m_stCameraPoseOffset; }

◆ GetCameraIsOpen()

template<class T >
virtual bool Camera< T >::GetCameraIsOpen ( )
pure virtual

Accessor for the Camera Is Open private member.

Returns
true - The camera is currently open.
false - The camera is not currently open.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-12-25

Implemented in BasicCam, SIMBasicCam, SIMZEDCam, and ZEDCam.

◆ RequestFrameCopy()

template<class T >
virtual std::future< bool > Camera< T >::RequestFrameCopy ( T &  tFrame)
protectedpure virtual

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