How akaash-kashyap/okapilib works
Project type and purpose
• OkapiLib is an open-source, C++ robotics library built on top of the PROS V5 runtime.
• Its goal is to provide a higher-level, modular API for controlling VEX V5 robot subsystems (chassis, motors, sensors, math utilities), while exposing PROS underpinnings for low-level hardware access.
File structure
• Top-level:
– include/okapi & include/display: Public headers (API) for chassis, control, device, filter, odometry, units, utility, plus an LVGL display wrapper.
– src/api: One-to-one implementation of the public API.
– src/impl: Internal implementations and factories for controllers, devices, filters, utilities.
– src/pathfinder & include/pathfinder: Embedded motion-profile trajectory generator/follower code.
– firmware/: Linker scripts and precompiled PROS libs for target hardware.
– CMakeLists.txt, Makefile, common.mk: Build and configuration orchestrators.
– docs/ & Doxyfile: API documentation and tutorials.
– test/ & src/test/ & include/test/: Unit and integration tests for API and impl.
Key insights from README
• Emphasis on extensibility, ease-of-use at the API layer, and zero-overhead low-level control.
• SemVer versioning, CONTRIBUTING guidelines, and GitHub Pages for docs.
a. Main components
1. User Code Layer
– User’s main.cpp and PROS project code imports OkapiLib headers.
2. Okapi API Layer (include/okapi, include/display)
– Facade classes: ChassisController, Async/Iterative controllers, Device wrappers, Filters, Odometry, Units, Utility.
3. Okapi Impl Layer (src/impl)
– Factories, builder patterns, default hardware bindings (ADI, motors, sensors), controller runner, time util.
4. Pathfinder Subsystem (include/pathfinder & src/pathfinder)
– Trajectory generation, follower algorithms (tank, swerve), I/O helpers.
5. PROS Runtime & Hardware Layer (firmware/, include/pros)
– Real-time OS, low-level drivers for motor ports, sensors, controller I/O.
6. Documentation & CI
– docs/, .github/workflows, Doxygen, tests, code coverage.
b. Relationships & interactions
• User Code → Okapi API: calls high-level methods to create controllers, send move commands.
• Okapi API → Okapi Impl: API objects delegate to builders and factories in impl.
• Controllers/Filters → PROS: Impl objects call into PROS C-API (via coreProsAPI.hpp) to read sensors, set motor voltages, schedule tasks.
• Pathfinder → Okapi API & Impl: Exposed as part of API/util, used by motion profile controllers.
• Tests → API & Impl: invoke public API and mock or stub impl to verify correctness.
• CI & Docs: monitor and publish status.
c. Architectural patterns & principles
• Layered Architecture: clear separation between API, implementation, and hardware.
• Facade & Builder Patterns: controllers and chassis builders simplify complex setup.
• Dependency Injection/Mocking: implMocks and FakeIt in tests.
• Zero-overhead Abstraction: public headers inline small adapter classes.
d. Key technologies & frameworks
• CMake & Makefiles for cross-platform build.
• PROS V5 real-time OS and C++ runtime.
• LVGL for display UI.
• Conan/Eigen not used—pure C/C++ code.
• Doxygen & m.css for API docs.
• FakeIt & snowhouse for unit tests.