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
2 changes: 1 addition & 1 deletion .github/agents/algo-implementer.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ Authoritative rules: `AGENTS.md`. Recipe: `roadmap/DEPLOYMENT.md`. Follow both e
- **No comments** (except license/`NOLINT`). Allman braces, brace-init.
- **Tests**: `TEST_F` on `float`, `StrictMock` only, anonymous-namespace fixture; implement EXACTLY
the spec's cases — no redundant or extra tests.
- **Embedded**: `#pragma GCC optimize` + `OPTIMIZE_FOR_SPEED` on hot paths.
- **Embedded**: no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths.
- **Terse**: no preamble/postamble, no plan restatement, no narration; don't re-read files; batch reads.
2 changes: 1 addition & 1 deletion .github/agents/planner.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Canonical rules: `AGENTS.md`. Produce plans only — no code edits.
- [ ] No heap; no recursion; tests too
- [ ] `template<typename T>` + `static_assert(std::is_floating_point_v<T>)`; `float` only
- [ ] `TEST_F` on `float` — no `TYPED_TEST`; `StrictMock` only; never plain `TEST()`
- [ ] `#pragma GCC optimize` + `OPTIMIZE_FOR_SPEED` on hot paths
- [ ] no `#pragma GCC optimize`/`optimize` attribute; `OPTIMIZE_FOR_SPEED` on hot paths
- [ ] `doc/` update planned

**Terse**: no preamble/postamble, no plan restatement; don't re-read files; batch reads.
2 changes: 1 addition & 1 deletion .github/agents/reviewer.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ End with totals + verdict: APPROVE / REQUEST CHANGES.
- [ ] `extern template` guarded by `#ifdef ROBOTICS_TOOLBOX_COVERAGE_BUILD`.

**Embedded optimizations (WARNING)**
- [ ] `#pragma GCC optimize("O3","fast-math")` after `#pragma once` in algorithm headers.
- [ ] No `#pragma GCC optimize` and no `optimize` attribute anywhere (they stop GCC inlining across the boundary).
- [ ] `OPTIMIZE_FOR_SPEED` on `Filter/Compute/Update/Solve/Step`.

**Namespaces (WARNING)**
Expand Down
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Code-file specifics: `.github/instructions/` (applyTo-scoped). Deployment recipe
Essentials (full detail in AGENTS.md):
- **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too.
- **Float-only** — generic `template<typename T>` + `static_assert(std::is_floating_point_v<T>)`; instantiate/test `float`; no Q15/Q31.
- **Embedded** — `#pragma GCC optimize("O3","fast-math")` + `OPTIMIZE_FOR_SPEED` on hot paths.
- **Embedded** — no `#pragma GCC optimize` / `optimize` attribute (they block inlining); the consumer sets optimization flags per TU; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths.
- **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase.
- **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases.
- **No exceptions** — `std::optional`/status enums; interfaces `virtual ~I() = default`.
Expand Down
12 changes: 3 additions & 9 deletions .github/instructions/robotics-cpp.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@ Use `std::numbers::pi_v<float>` — never hardcode `3.14159265f`.

## Embedded Optimizations

Every algorithm header MUST include:
Never use `#pragma GCC optimize` or the `optimize` attribute. GCC does not inline a callee whose optimization options differ from its caller's, so options set per header or per function turn every small helper on a hot path into an out-of-line call. Optimization level and floating-point flags are the consumer's, applied to whole translation units (embedded: `-O2`/`-O3` with `-ffast-math -fno-finite-math-only`).

```cpp
#pragma once
Apply `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot-path methods: `Compute()`, `Filter()`, `Calculate()`, `Solve()`, `Update()`, `Step()`. It forces inlining when `NumericalToolbox_ENABLE_OPTIMIZATIONS` is defined and expands to nothing otherwise.

#if defined(__GNUC__) || defined(__clang__)
#pragma GCC optimize("O3", "fast-math")
#endif
```

Apply `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot-path methods: `Compute()`, `Filter()`, `Calculate()`, `Solve()`, `Update()`, `Step()`.
Use `math::IsFinite` for finiteness checks: a consumer may still build with `-ffinite-math-only`.

## Naming

Expand Down
26 changes: 14 additions & 12 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ and included as `numerical/<domain>/…`.
`infra::BoundedDeque<T>::WithMaxSize<N>`, `infra::BoundedList<T>::WithMaxSize<N>`,
`std::array<T,N>`, `std::optional<T>`. Stack/static only. No recursion. **Tests too.**

## Embedded optimizations (algorithm headers)

```cpp
#pragma once
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC optimize("O3", "fast-math")
#endif
#include "numerical/math/CompilerOptimizations.hpp"
```

`OPTIMIZE_FOR_SPEED` on hot paths (`Filter/Compute/Update/Solve/Step`). Pure interfaces exempt.
## Embedded optimizations

- **No `#pragma GCC optimize` and no `optimize` attribute**, in headers or sources. GCC does not
inline a callee whose optimization options differ from its caller's, so options set per header or
per function turn every small helper on a hot path into an out-of-line call; an unscoped pragma in
a header also leaks fast-math into every including translation unit.
- The optimization level and floating-point model belong to the consumer and apply to whole
translation units. For embedded targets: `-O2` or `-O3` with `-ffast-math -fno-finite-math-only`.
- `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot paths
(`Filter/Compute/Update/Solve/Step`). Pure interfaces exempt. With
`NumericalToolbox_ENABLE_OPTIMIZATIONS` it forces inlining (`always_inline`, `hot`, `inline`);
without it, it expands to nothing.
- Use `math::IsFinite` for finiteness checks: a consumer may still build with `-ffinite-math-only`.

## Style

Expand All @@ -58,7 +60,7 @@ primitives keep their upstream namespaces (`math`, `solvers`, …) from numerica
## Kinematics & dynamics conventions

- 6-vectors are ordered **linear part first**: twists `(v; ω)`, wrenches `(f; n)`; the geometric
Jacobian has linear rows first (roadmap M6/M8). Featherstone `(ω; v)` ordering stays internal to the
Jacobian has linear rows first (upstream `math::SE3Transform`, roadmap NT53/M8). Featherstone `(ω; v)` ordering stays internal to the
recursive dynamics algorithms.
- Orientation errors use the SE(3) logarithm (`PoseError`), never angle subtraction.
- The tool frame and the base mounting offset are explicit kinematic parameters — never derived from a
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Shared numerical primitives come from numerical-toolbox-cpp via FetchContent (`n
Essentials (full detail in AGENTS.md):
- **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too.
- **Float-only** — generic `template<typename T>` + `static_assert(std::is_floating_point_v<T>)`; instantiate/test `float`; no Q15/Q31.
- **Embedded** — `#pragma GCC optimize("O3","fast-math")` + `OPTIMIZE_FOR_SPEED` on hot paths.
- **Embedded** — no `#pragma GCC optimize` / `optimize` attribute (they block inlining); the consumer sets optimization flags per TU; `OPTIMIZE_FOR_SPEED` (forced inlining) on hot paths.
- **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase.
- **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases.
- **No exceptions** — `std::optional`/status enums; interfaces `virtual ~I() = default`.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (NOT TARGET numerical.math)
FetchContent_Declare(
numerical_toolbox
GIT_REPOSITORY https://github.com/embedded-pro/numerical-toolbox-cpp.git
GIT_TAG 69ff13e719895b74b167c4742130442c6b96a857 # main
GIT_TAG 9b37e0885d31a9e444739a5cfaa3bc004aad9d37 # main
)

set(NUMERICAL_TOOLBOX_ENABLE_OPTIMIZATIONS ${ROBOTICS_TOOLBOX_ENABLE_OPTIMIZATIONS} CACHE BOOL "" FORCE)
Expand Down
Loading
Loading