Repository navigation
fix(protective_stop_machine): build pstop_c and common as packages - #212
skyegalaxy wants to merge 4 commits into
Conversation
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
…instead of ../../ sources Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
There was a problem hiding this comment.
Graphify review 
No issues reported · Low impact
What this review covered
- We didn't review 9 files that aren't source code, such as docs, config, images, or generated or third-party code.
- 1 of 1 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 5 functions depend on this change
- 85 of 85 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed dde603a
There was a problem hiding this comment.
Beyond the inline findings, I also checked whether the installed pstop_c::transport_udp can still find the pstop headers once only its INSTALL_INTERFACE path is left. It can: both pstop/include/ and transport/include/ install into include/pstop_c.
Extended reasoning...
The two inline findings are about colcon/rosdep not finding the new packages, and about -Werror/-fanalyzer now running in package builds. Separately, transport_udp's install include path was checked against the install(DIRECTORY) rule in pstop_c/CMakeLists.txt, which puts both header trees under include/pstop_c.
| <build_depend>pstop_c</build_depend> | ||
| <build_depend>pstop_common</build_depend> |
There was a problem hiding this comment.
🔴 Following the documented build steps now fails. The new pstop_c and pstop_common dependencies sit outside ros2/, so colcon and rosdep cannot find them there. With colcon's default base path, cd ros2 && colcon build --packages-up-to protective_stop_machine never sees ../pstop_c or ../common, and find_package(pstop_c) fails. rosdep install --from-paths ros2/ also cannot resolve the pstop_c key. Fix: make every documented ros2-only command pass --base-paths . ../pstop_c ../common (or run from the repo root), as scripts/coverage.sh now does, which covers the 3 sites listed. Same pattern at 3 sites (docs/index.md:117, docs/guides/quickstart.md:170, docs/safety/coverage_report.md:130).
Why this was flagged
An operator follows docs/index.md:117 (cd ../ros2 && colcon build --packages-up-to protective_stop_machine) or docs/safety/coverage_report.md:130 (cd ros2 then the same colcon build). colcon finds packages by searching its base path, which defaults to the current directory (ros2/). pstop_c/package.xml and common/package.xml live in sibling top-level directories, so neither package is discovered. ros2/protective_stop_machine/CMakeLists.txt:16 then fails at configure time with find_package(pstop_c REQUIRED). docs/guides/quickstart.md:170 runs rosdep install -iy --from-paths ros2/. The new build_depend entries for pstop_c and pstop_common are neither in that path nor rosdep keys, so rosdep stops with a 'Cannot locate rosdep definition' error. On the base branch all three commands worked, because the ROS package compiled ../../pstop_c and ../../common directly. The PR updated scripts/coverage.sh:87 to add --base-paths . ../pstop_c ../common, but left the documented commands unchanged.
Verification: ros2/protective_stop_machine/CMakeLists.txt now calls find_package(pstop_c REQUIRED). pstop_c and pstop_common sit at the top level of the repo, next to ros2/, not inside it. docs/index.md:117 and docs/safety/coverage_report.md:128-130 use colcon's default base path (ros2/), so configure fails at find_package(pstop_c REQUIRED). On the base branch, building from ros2/ worked.
| @@ -41,79 +43,84 @@ add_library(pstop | |||
|
|
|||
| target_compile_options(pstop PRIVATE -Wall -Wextra -Werror -fanalyzer) | |||
There was a problem hiding this comment.
🔴 ROS 2 and Debian package builds of the machine now fail if the distro's compiler reports any warning in pstop_c. The base built the same sources without -Werror. pstop keeps -Wall -Wextra -Werror -fanalyzer, and every colcon/bloom build now compiles it through this file. pstop_c's own CI (pstop_c_build.yml) only checks it with ubuntu-latest's gcc. Fix: keep -Werror and -fanalyzer only for pstop_c's own CI, for example behind an option that defaults OFF and that pstop_c_build.yml turns on, and apply the same gate to the test targets.
Why this was flagged
The trigger is any compiler that reports a new or false-positive warning or analyzer diagnostic in pstop_c. Examples are gcc 11 in the ros:humble container used by .github/workflows/coverage.yml and in the humble leg of ros2_build.yml, a newer gcc on a later distro, or the ROS buildfarm. On the base, ros2/protective_stop_machine/CMakeLists.txt compiled pstop_c/pstop/src/pstop/*.c directly with only add_compile_options(-Wall -Wextra). A warning there was just a warning. After this change, colcon build, action-ros-ci and bloom's Debian build all configure pstop_c/CMakeLists.txt. That applies target_compile_options(pstop PRIVATE -Wall -Wextra -Werror -fanalyzer) at pstop_c/pstop/CMakeLists.txt:44, so any such warning stops pstop_c. protective_stop_machine then cannot build. Nothing guards against this, because pstop_c_build.yml runs only plain cmake on ubuntu-latest and never uses the ROS distro compilers.
Verification: Trigger: a colcon, bloom or Debian build of the stack on a GCC that reports any warning or analyzer diagnostic in pstop_c. pstop_c/pstop/CMakeLists.txt:44 keeps target_compile_options(pstop PRIVATE -Wall -Wextra -Werror -fanalyzer). On the base, ros2/protective_stop_machine/CMakeLists.txt compiled these sources with only add_compile_options(-Wall -Wextra), so a warning stayed a warning.
protective_stop_machinecompiledpstop_cand the aux-channel schema straight from../../pstop_cand../../common, so it only built inside a full checkout of this repo. Building it as an apt package, which builds each package from its own directory alone, could not find them. This makespstop_candcommonpackages of their own, which the machine package finds withfind_package.pstop_cbecomes a plain CMake package that installslibpstop.aandlibtransport_udp.a(position-independent), its headers underinclude/pstop_c/, and an exportedpstop_cConfig.cmake. Its sources don't change.pstop_c's tests and their Unity download build only withBUILD_TESTING, which stays on by default.common/becomespstop_common, a header-only package installingpstop_aux_channel.h. The firmware still includescommon/directly and is unaffected.protective_stop_machinelinks both privately and lists them asbuild_depends; they're linked in, so nothing is needed from them at run time.scripts/coverage.shadds../pstop_cand../commonto colcon's base paths.Tested on ROS 2 Jazzy: colcon builds all four packages and the 77 tests pass,
pstop_testandpstop_requirements_testpass, andprotective_stop_machinebuilds on its own against the installed packages.Migration Guide
colcon workspaces that clone this repo now also build
pstop_candpstop_common, sincepstop_c/COLCON_IGNOREis gone. Pass-DBUILD_TESTING=OFFto skippstop_c's tests and their Unity download.