Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ scripts/format.sh
It pins clang-format 18; a different major version formats differently and CI
will reject the result.

## Compile-time limits

motionkit uses fixed-size storage to keep its core algorithms allocation-free.
The following public limits are intentionally fixed and cannot currently be
overridden through CMake:

| Constant | Defining header | Limit |
|---|---|---:|
| `kMaxPathKnots` | `motionkit/core/cartesian.hpp` | 65 |
| `kMaxWaypoints` | `motionkit/core/cartesian.hpp` | 16 |
| `kMaxObstacles` | `motionkit/core/collision.hpp` | 32 |

## Use it downstream

```cmake
Expand Down
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ FetchContent_MakeAvailable(googletest)

include(GoogleTest)

add_test(NAME readme_limits
COMMAND ${CMAKE_COMMAND}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/check_readme_limits.cmake)
set_tests_properties(readme_limits PROPERTIES LABELS unit)

add_executable(motionkit_tests
test_vec3.cpp
test_so3.cpp
Expand Down
19 changes: 19 additions & 0 deletions tests/check_readme_limits.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
file(READ "${PROJECT_SOURCE_DIR}/README.md" readme)

function(check_limit name header)
file(READ "${PROJECT_SOURCE_DIR}/include/${header}" declaration)
string(REGEX MATCH "${name} = ([0-9]+)" match "${declaration}")
if(NOT match)
message(FATAL_ERROR "Could not find ${name} in ${header}")
endif()
set(value "${CMAKE_MATCH_1}")
string(FIND "${readme}" "| `${name}` | `${header}` | ${value} |" documented)
if(documented EQUAL -1)
message(FATAL_ERROR
"README limit for ${name} does not match ${header} (${value})")
endif()
endfunction()

check_limit(kMaxPathKnots motionkit/core/cartesian.hpp)
check_limit(kMaxWaypoints motionkit/core/cartesian.hpp)
check_limit(kMaxObstacles motionkit/core/collision.hpp)
Loading