Skip to content

fix(protective_stop_machine): build pstop_c and common as packages - #212

Open
skyegalaxy wants to merge 4 commits into
mainfrom
skyegalaxy/self-contained-machine-package
Open

skyegalaxy wants to merge 4 commits into
mainfrom
skyegalaxy/self-contained-machine-package

Conversation

@skyegalaxy

Copy link
Copy Markdown
Member

protective_stop_machine compiled pstop_c and the aux-channel schema straight from ../../pstop_c and ../../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 makes pstop_c and common packages of their own, which the machine package finds with find_package.

  • pstop_c becomes a plain CMake package that installs libpstop.a and libtransport_udp.a (position-independent), its headers under include/pstop_c/, and an exported pstop_cConfig.cmake. Its sources don't change.
  • pstop_c's tests and their Unity download build only with BUILD_TESTING, which stays on by default.
  • common/ becomes pstop_common, a header-only package installing pstop_aux_channel.h. The firmware still includes common/ directly and is unaffected.
  • protective_stop_machine links both privately and lists them as build_depends; they're linked in, so nothing is needed from them at run time. scripts/coverage.sh adds ../pstop_c and ../common to colcon's base paths.

Tested on ROS 2 Jazzy: colcon builds all four packages and the 77 tests pass, pstop_test and pstop_requirements_test pass, and protective_stop_machine builds on its own against the installed packages.

Migration Guide

colcon workspaces that clone this repo now also build pstop_c and pstop_common, since pstop_c/COLCON_IGNORE is gone. Pass -DBUILD_TESTING=OFF to skip pstop_c's tests and their Unity download.

Skyler Medeiros added 4 commits December 2, 2026 12:37
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>

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Looks safe to merge · Merge confidence 5/5

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

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +23 to +24
<build_depend>pstop_c</build_depend>
<build_depend>pstop_common</build_depend>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant