Adding a New Control Algorithm¶
Kompass control algorithms live in kompass-core and are dispatched by the Controller component through enum-based registries (ControlClasses / ControlConfigClasses).
There are two ways to add a new algorithm, depending on where the core logic lives:
Pure Python or Python + C++ wrapper
Implement your algorithm entirely in Python by inheriting ControllerTemplate, or write a Python wrapper around an existing C++ backend by inheriting FollowerTemplate. Covers configuration, registration, single vs. multi-command (MPC-style) output, and publishing modes.
C++ implementation with nanobind bindings
Implement a high-performance path-following algorithm in C++ by extending the Follower class in kompass_cpp. Covers the C++ class hierarchy, parameter system, nanobind bindings, and the build pipeline.
Architecture at a Glance¶
Layer |
Role |
|---|---|
kompass |
ROS 2 lifecycle node ( |
kompass-core |
Algorithm Python classes, config ( |
kompass_cpp |
Performance-critical C++ implementations, exposed via nanobind |
Existing Algorithms¶
|
Algorithm |
Base Class |
Config Class |
|---|---|---|---|
|
Dynamic Window Approach |
|
|
|
Pure Pursuit |
|
|
|
Stanley Controller |
|
|
|
Deformable Virtual Zone |
|
|
|
Vision Follower (RGB) |
|
|
|
Vision Follower (RGB-D) |
|
|
Which approach to choose?¶
Python-only algorithm (e.g. a proportional controller, a vision-based follower) – use
ControllerTemplate. No C++ needed.Python wrapper for an existing C++ follower – use
FollowerTemplate. Gets path management for free from the C++ backend.New high-performance path follower from scratch – implement in C++ first (C++ guide), then wrap in Python (Python guide).