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
IPS Class Reference

This util class provides an easy way to keep track of iterations per second for any body of code. More...

#include <IPS.hpp>

Public Member Functions

 IPS ()
 Construct a new IPS object.
 
 ~IPS ()
 Construct a new IPS object.
 
IPSoperator= (const IPS &OtherIPS)
 Operator equals for IPS class.
 
void Tick ()
 This method is used to update the iterations per second counter and recalculate all of the IPS metrics.
 
double GetExactIPS () const
 Accessor for the Current I P S private member. This method will return the immediate IPS since the last Tick() call. If called in a loop, this number will likely jump around greatly. If you want a 'smoother' IPS number then call the GetAverageIPS() method.
 
double GetAverageIPS () const
 Calculates the average iterations per second.
 
double GetHighestIPS () const
 Accessor for the Highest I P S private member.
 
double GetLowestIPS () const
 Accessor for the Lowest I P S private member.
 
double Get1PercentLow () const
 Accessor for the 1PercentLow I P S private member.
 
void Reset ()
 Resets all metrics and frame time history.
 

Private Member Functions

void UpdateMetrics ()
 This method is used to calculate the IPS stats. Highest, lowest, and 1 percent low IPS.
 

Private Attributes

double m_dCurrentIPS
 
double m_dHighestIPS
 
double m_dLowestIPS
 
double m_d1PercentLow
 
std::deque< double > m_dqIPSHistory
 
std::chrono::high_resolution_clock::time_point m_tLastUpdateTime
 
const long unsigned int m_nMaxMetricsHistorySize = 100
 

Detailed Description

This util class provides an easy way to keep track of iterations per second for any body of code.

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

◆ IPS()

IPS::IPS ( )
inline

Construct a new IPS 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
88 {
89 // Initialize member variables and objects.
90 m_dCurrentIPS = 0.0;
91 m_dHighestIPS = 0.0;
92 m_dLowestIPS = 9999999;
93 m_d1PercentLow = 0.0;
94 }

◆ ~IPS()

IPS::~IPS ( )
inline

Construct a new IPS 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
104 {
105 // Nothing to destroy.
106 }

Member Function Documentation

◆ UpdateMetrics()

void IPS::UpdateMetrics ( )
inlineprivate

This method is used to calculate the IPS stats. Highest, lowest, and 1 percent low IPS.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
52 {
53 // Check highest IPS.
54 if (m_dCurrentIPS > m_dHighestIPS)
55 {
56 // Update new highest.
57 m_dHighestIPS = m_dCurrentIPS;
58 }
59 // Check lowest IPS.
60 if (m_dCurrentIPS < m_dLowestIPS)
61 {
62 // Update new lowest.
63 m_dLowestIPS = m_dCurrentIPS;
64 }
65
66 // Add current IPS to history.
67 m_dqIPSHistory.emplace_back(m_dCurrentIPS);
68 // Sort the IPS history vector, this allows us to find the 1% low more easily.
69 // Throw out oldest element in deque if size is over given number.
70 if (m_dqIPSHistory.size() > m_nMaxMetricsHistorySize)
71 {
72 m_dqIPSHistory.pop_front();
73 }
74 // Get the index correlating to the IPS number that was lower than 99% of the rest of the IPS history.
75 m_d1PercentLow = *std::min_element(m_dqIPSHistory.begin(), m_dqIPSHistory.end());
76 }
Here is the caller graph for this function:

◆ operator=()

IPS & IPS::operator= ( const IPS OtherIPS)
inline

Operator equals for IPS class.

Parameters
OtherIPS- The IPS object to copy values from.
Returns
IPS& - A reference to this object.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-10
118 {
119 // Copy values from other IPS object.
120 m_dCurrentIPS = OtherIPS.m_dCurrentIPS;
121 m_dHighestIPS = OtherIPS.m_dHighestIPS;
122 m_dLowestIPS = OtherIPS.m_dLowestIPS;
123 m_d1PercentLow = OtherIPS.m_d1PercentLow;
124 m_dqIPSHistory = OtherIPS.m_dqIPSHistory;
125
126 // Return this object.
127 return *this;
128 }

◆ Tick()

void IPS::Tick ( )
inline

This method is used to update the iterations per second counter and recalculate all of the IPS metrics.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
139 {
140 // Get the current and elapsed time.
141 std::chrono::time_point tCurrentTime = std::chrono::high_resolution_clock::now();
142 long int nElapsedTimeSinceLastTick = std::chrono::duration_cast<std::chrono::microseconds>(tCurrentTime - m_tLastUpdateTime).count();
143
144 // Calculate current IPS. 1 second == 1000000 microseconds.
145 m_dCurrentIPS = 1e6 / static_cast<double>(nElapsedTimeSinceLastTick);
146
147 // Calculate IPS overall stats.
148 this->UpdateMetrics();
149
150 // Set current time to old.
151 m_tLastUpdateTime = tCurrentTime;
152 }
void UpdateMetrics()
This method is used to calculate the IPS stats. Highest, lowest, and 1 percent low IPS.
Definition IPS.hpp:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetExactIPS()

double IPS::GetExactIPS ( ) const
inline

Accessor for the Current I P S private member. This method will return the immediate IPS since the last Tick() call. If called in a loop, this number will likely jump around greatly. If you want a 'smoother' IPS number then call the GetAverageIPS() method.

Returns
double - The calculated IPS value since the last iteration.
Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
166 {
167 // Return current iterations per second.
168 return m_dCurrentIPS;
169 }
Here is the caller graph for this function:

◆ GetAverageIPS()

double IPS::GetAverageIPS ( ) const
inline

Calculates the average iterations per second.

Returns
double - The average iterations per second according to the metrics window.
Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
181 {
182 // Check if there is any history.
183 if (m_dqIPSHistory.empty())
184 {
185 // Return zero IPS average.
186 return 0.0;
187 }
188
189 // Loop through IPS history and calculate average.
190 double dSum = 0.0;
191 for (const double dVal : m_dqIPSHistory)
192 {
193 // Add FPS to total sum.
194 dSum += dVal;
195 }
196
197 // Return calculated average.
198 return dSum / static_cast<double>(m_dqIPSHistory.size());
199 }
Here is the caller graph for this function:

◆ GetHighestIPS()

double IPS::GetHighestIPS ( ) const
inline

Accessor for the Highest I P S private member.

Returns
double - The highest recorded IPS over this objects lifespan.
Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
210 {
211 // Return the highest iterations per second.
212 return m_dHighestIPS;
213 }
Here is the caller graph for this function:

◆ GetLowestIPS()

double IPS::GetLowestIPS ( ) const
inline

Accessor for the Lowest I P S private member.

Returns
double - The lowest recorded IPS over this objects lifespan.
Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
224 {
225 // Return the lowest iterations per second.
226 return m_dLowestIPS;
227 }
Here is the caller graph for this function:

◆ Get1PercentLow()

double IPS::Get1PercentLow ( ) const
inline

Accessor for the 1PercentLow I P S private member.

Returns
double - The recorded 1% low within the given metrics window size.
Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
238 {
239 // Return the 1% low for IPS.
240 return m_d1PercentLow;
241 }
Here is the caller graph for this function:

◆ Reset()

void IPS::Reset ( )
inline

Resets all metrics and frame time history.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-07
251 {
252 // Reset member variable.
253 m_dCurrentIPS = 0.0;
254 m_dHighestIPS = 0.0;
255 m_dLowestIPS = 9999999;
256 m_d1PercentLow = 0.0;
257 // Reset deque.
258 m_dqIPSHistory.clear();
259 }
Here is the caller graph for this function:

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