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.
While AutonomyThread oversees single persistent background worker loops, the Autonomy Software also requires mechanisms to execute parallelized burst workloads across multiple CPU cores without thread allocation latency.
BS::thread_poolThe codebase utilizes the Barak Shoshany C++ Thread Pool library (BS::thread_pool), included under external/threadpool/include/BS_thread_pool.hpp.
BS::pr::lowest to BS::pr::highest) to ensure time-critical computations bypass routine jobs.AutonomyThreadEvery class derived from AutonomyThread<T> contains an embedded BS::thread_pool. It exposes several protected methods for dispatching parallel work:
RunPool(int nTasks, int nThreads, AutonomyThreadPriority ePriority): Submits nTasks to execute PooledLinearCode(). It returns a vector of std::future<T>, allowing the caller to collect return values via GetPoolResults().RunDetachedPool(int nTasks, int nThreads, AutonomyThreadPriority ePriority): Submits nTasks as fire-and-forget executions, bypassing future synchronization for minimal latency.SubmitTaskToPool(Func&& task, Args&&... args): Queues an arbitrary lambda or function pointer to the pool, returning an std::future representing its eventual completion.SubmitDetachedTaskToPool(Func&& task, Args&&... args): Queues an arbitrary function without allocating a future object.ParallelizeLoop)Splits large iterative loops across available CPU cores:
// Distributes 10,000 iterations across 4 worker threads
this->ParallelizeLoop(4, 10000, [this](const int nStart, const int nEnd) {
for (int i = nStart; i < nEnd; ++i)
{
ProcessDataPoint(i);
}
});
The primary consumer of thread pooling in the software is camera buffer distribution (ZEDCam.cpp and BasicCam.cpp):
TagDetector, ObjectDetector, SimpleWebServer video streamer) require independent copies of the frame matrix.