$ show ACDSLab/MPPI-Generic
This repository is a C++/CUDA header-only library implementing Model Predictive Path Integral (MPPI) control, a sampling-based trajectory optimization method for real-time robotic control. It provides multiple controller variants including Vanilla MPPI, Tube-MPPI, Robust-MPPI, and Colored-MPPI, each designed to handle different robustness and noise characteristics. The architecture uses CRTP (Curiously Recurring Template Pattern) to achieve device-side polymorphism without virtual functions, enabling efficient GPU execution. The library includes a broad set of dynamics models (cartpole, double integrator, quadrotor, dubins car, autorally neural network models, racer dubins with elevation and suspension) and corresponding cost functions, along with Gaussian, colored noise, and log-normal sampling distributions. It also integrates DDP and CCM feedback controllers, and provides utilities for neural network inference (LSTM, FNN) and texture-based costmap queries on GPU. Typical use cases are autonomous racing and off-road vehicle control, where the library's GPU acceleration allows thousands of trajectory rollouts to be evaluated in real-time. The codebase is well-structured with extensive tests using Google Test and Google Mock, covering kernel correctness, dynamics, cost functions, and full controller pipelines. It includes real-time control loop abstractions (BasePlant, BufferedPlant) and supports integration with ROS via state interpolation and parameter updates. The library is research-grade, citing Williams et al. 2017 and including implementations of concepts like robust free-energy bounds and colored noise shaping. While the overall architecture is sound and many components are reusable, the codebase shows signs of research-driven growth: some modules contain commented-out code, skipped tests, and conditional compilation flags. Manual CUDA memory management and complex template hierarchies increase the learning curve. Despite this, the library is actively maintained and offers high-quality reusable patterns for GPU-accelerated control, making it a strong reference for MPPI implementations in robotics.
The LLM identified 3 files worth highlighting for reuse:
A reusable CUDA texture wrapper that manages 2D texture objects for cost maps, elevation maps, or any gridded spatial data on the GPU. It abstracts texture creation, binding, and coordinate transforms (world-to-pixel, normalized vs. map coordinates), providing simple CPU and GPU value access methods. This component can be extracted and used in any CUDA-based robotics application that requires fast bilinear interpolation of spatial data without manual texture management.
Provides the `HANDLE_ERROR` and `HANDLE_CURAND_ERROR` macros for concise CUDA error checking in both host and device code. It wraps `cudaGetLastError` and `cudaGetErrorString`, printing file/line information on failure. This file is a drop-in utility for any CUDA project that wants robust error reporting with minimal boilerplate.
A templated LSTM forward-pass helper for GPU, supporting variable hidden size, input size, and optional shared memory usage. It manages LSTM weight matrices (input-to-hidden, hidden-to-hidden, bias) and provides a `forward` method that launches CUDA kernels for the LSTM cell computation. The design is self-contained and parameterized by `USE_SHARED`, making it adaptable to different memory hierarchies. This component can be extracted into any CUDA-based project requiring LSTM inference with minimal dependencies.