Skip to content

Commit 3e4e726

Browse files
authored
Merge pull request #391 from castacks/rfc/s4-optitrack-flatten-local
Modular AirStack 4/9: asm_optitrack extraction, local-layer flatten
2 parents 7759539 + 7980fb0 commit 3e4e726

132 files changed

Lines changed: 781 additions & 11871 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/add-unit-tests/SKILL.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Whether `colcon test` *also* picks up a package's Python tests depends on its bu
6868

6969
| Package | Build type | Python tests under `colcon test` |
7070
|---|---|---|
71-
| `natnet_ros2` | `ament_cmake` | **No** — `CMakeLists.txt` registers `ament_add_gtest` but no `ament_add_pytest_test` |
7271
| `lidar_point_cloud_filter` | `ament_python` | **Yes** — `setup.cfg` sets `testpaths = test`, so colcon's pytest runner finds them |
72+
| any `ament_cmake` package | `ament_cmake` | **No** unless `CMakeLists.txt` registers `ament_add_pytest_test` (an `ament_add_gtest` alone covers only C++) |
7373

7474
So a Python test in an `ament_cmake` package runs *only* via the root harness — which is
7575
fine, since that is what CI invokes.
@@ -89,8 +89,8 @@ Good candidates are functions/classes with **no ROS or hardware dependencies**:
8989
- Data-structure converters
9090
- Any function that takes plain Python types and returns plain Python types
9191

92-
If the code imports ROS types, stub them out at the import boundary
93-
(see `test_natnet_ros2.py` for the `sys.modules` stub pattern).
92+
If the code imports ROS types, stub them out at the import boundary with
93+
`sys.modules.setdefault(...)` before importing your module (pattern below).
9494

9595
### 2. Write the test source in the package
9696

@@ -145,7 +145,7 @@ sys.modules.setdefault("geometry_msgs.msg", MagicMock())
145145

146146
For `rclpy.node.Node` subclasses use a real dummy base class instead of a
147147
`MagicMock()` to ensure `__init_subclass__` fires and method bodies are defined
148-
(see `test_natnet_ros2.py` for the full pattern).
148+
(the asm_optitrack module's `test_natnet_ros2.py` shows the full pattern).
149149

150150
### 3. Register the package in colcon_unit_test_packages.yaml
151151

@@ -155,7 +155,6 @@ If the package isn't already listed, add it under the `robot` workspace in
155155
```yaml
156156
robot:
157157
packages:
158-
- natnet_ros2
159158
- lidar_point_cloud_filter
160159
- <your_package> # ← add here
161160
pytest_args: []
@@ -282,17 +281,18 @@ sim:
282281
| How do I run them? | `airstack test -m unit`, `cd tests && pytest -m unit`, or `pytest tests/ -m unit` |
283282
| What CI workflow runs them? | Python: `unit-tests.yml`; C++: the `build_packages` path in `system-tests.yml` — see §5 |
284283
| Do system tests (`liveliness`, etc.) run too? | No — `-m unit` filters to hermetic tests only |
285-
| Does `colcon test` also run these? | Only if the package registers them. `ament_add_gtest` covers C++; a Python test needs `ament_add_pytest_test`, which `natnet_ros2` does **not** have — its Python tests run only under the root harness |
284+
| Does `colcon test` also run these? | Only if the package registers them. `ament_add_gtest` covers C++; a Python test in an `ament_cmake` package needs `ament_add_pytest_test` — without it, its Python tests run only under the root harness |
286285
| Can I add pure C++ gtests? | Yes — `ament_add_gtest` in CMakeLists.txt |
287286

288287
## Reference Implementations
289288

290289
| Package | Python test | What it covers |
291290
|---|---|---|
292-
| `natnet_ros2` | `robot/ros_ws/src/perception/natnet_ros2/test/test_natnet_ros2.py` | `VisionPoseConverterNode._canonical_quaternion` (ROS-stubbed) |
293-
| `natnet_ros2` (C++) | `robot/ros_ws/src/perception/natnet_ros2/test/test_natnet_logic.cpp` | `build_covariance_6x6`, `negotiate()`, `INatNetClient` seam |
294291
| `lidar_point_cloud_filter` | `robot/ros_ws/src/sensors/lidar_point_cloud_filter/test/test_validation_core.py` | Pure-numpy range validation rules |
295292

293+
For an `ament_cmake` example (ROS-stubbed Python tests + gtests with a client seam), see
294+
`natnet_ros2` in the [asm_optitrack module](https://github.com/castacks/asm_optitrack).
295+
296296
Both are collected from their package `test/` dir.
297297

298298
## Files to Know

‎.agents/skills/optitrack-development/SKILL.md‎

Lines changed: 0 additions & 221 deletions
This file was deleted.

0 commit comments

Comments
 (0)