Repository navigation
Fields2Cover v2 migration and fixes (Main - Rolling) - #110
SteveMacenski merged 30 commits into
Conversation
Fields2Cover v2 changed several build-time integration details. Update both packages' CMake so they build against v2 regardless of how F2C is installed (source under /usr/local or the ROS apt package ros-humble-fields2cover under /opt/ros): - Link GDAL explicitly (GDAL::GDAL). v2's exported target no longer propagates GDAL as an interface dependency, so consumers that emit OGR symbols inline must link it themselves. - Resolve tinyxml2 in opennav_row_coverage via tinyxml2_vendor + find_package(TinyXML2); the system libtinyxml2-dev ships no CMake config. - Select the Fields2Cover target by name: source installs expose 'Fields2Cover', the ROS/apt package exposes 'Fields2Cover::Fields2Cover'. - Mark Fields2Cover headers as SYSTEM includes so their own warnings (e.g. -Wshadow in objectives/rp_obj/*) do not break this -Werror build when F2C lives outside the default system include path.
Pin to the v2.0.0 release tag (built from source) instead of the v1.2.1-devel branch, for reproducible CI matching the migrated version.
Use the single-argument get_package_share_directory overload, the only one present on humble, jazzy and rolling. Locally silence the deprecation warning rolling emits so -Werror does not fail the build; its replacement get_package_share_path() is unavailable on humble/jazzy.
Rolling removed the ament_target_dependencies macro, so link the dependency targets directly via target_link_libraries; this also works on jazzy, which still exports the same targets. The library PUBLIC-links its dependencies so they propagate transitively to the executable and tests. Also declare the new nav2_ros_common dependency required by the nav2 headers.
rclcpp::spin_some(node) was deprecated in rolling. Drive the node with a SingleThreadedExecutor instead, which is portable across jazzy and rolling.
Upgrade actions/checkout from the deprecated v2 to v4 in both workflows, and add opennav_row_coverage to the lint package list. CI stays rolling-only, matching the upstream main branch.
Rolling has left Ubuntu Noble (24.04) for its released form Lyrical on Ubuntu 26.04 (resolute): the noble ros-rolling-* packages are frozen and rosdep no longer maps rolling keys to noble, which broke every nav2 source-build dependency. Switch the Test workflow to the Lyrical/resolute setup-ros-docker image, where the apt repo is consistent and rosdep resolves source-build deps automatically; the manual apt step is removed. Lyrical is a fresh distro, so a couple of packages are not in its apt repo yet and are built from source via deps.repos: - ortools_vendor (a Fields2Cover dependency) - slam_toolbox (pulled in by nav2_bringup)
…h access The final getNext() call after iteration (idx_ == max_idx_) read swaths[idx_] one element past the end. This was a latent out-of-bounds read that older libstdc++ tolerated silently, but GCC 15's hardened standard library (_GLIBCXX_ASSERTIONS) on Lyrical/Ubuntu 26.04 now aborts on it, failing the test_utils TestPathComponentsIterator test. Return a nullptr swath past the end and guard the turn access against turns.size(), which also avoids the unsigned underflow of max_idx_ - 1 when there are no swaths.
Rolling and its released form Lyrical (Ubuntu 26.04) removed the
ament_target_dependencies() macro, so opennav_coverage_bt and
opennav_coverage_navigator no longer configured. Mirror the approach
already used by opennav_coverage: keep the package-name list for
ament_export_dependencies(), add a dep_targets list of the modern imported
targets, and link them with target_link_libraries().
Targets use the canonical nav2 names: pkg::pkg for regular packages
(rclcpp::rclcpp, nav2_util::nav2_util_core,
nav2_behavior_tree::nav2_behavior_tree, nav2_core::nav2_core,
nav2_ros_common::nav2_ros_common, behaviortree_cpp::behaviortree_cpp) and
${pkg_TARGETS} for interface/message packages. These targets are also
exported on jazzy, so the packages keep building there too.
opennav_coverage_navigator additionally gains find_package(pluginlib): it
includes pluginlib/class_list_macros.hpp and calls
pluginlib_export_plugin_description_file() directly, which previously came
in only transitively through ament_target_dependencies.
nav2_bt_navigator stays in the exported dependency list but is not linked,
because no source file includes its headers. Tests link the plugin
libraries together with ${dep_targets} for the same reason.
Two issues surface on Ubuntu 26.04 (Lyrical / nav2 main), both under the package's own -Werror: - ament_index_cpp::get_package_share_directory() is deprecated on rolling/lyrical in favour of get_package_share_path(), but that replacement does not exist on jazzy. Switching APIs would break jazzy, so keep a single cross-distro code path and silence the deprecation locally with a GCC diagnostic pragma around the two call sites (the navigator source and the test). Behaviour is unchanged. - The test's plugin_lib_names listed nav2_is_path_valid_condition_bt_node, which nav2 main removed (the IsPathValid condition became a ValidatePath action; the coverage behavior trees use neither). The stale name made BehaviorTree.CPP throw "Could not load library: libnav2_is_path_valid_condition_bt_node.so" at test runtime. Drop the entry; the remaining plugins all exist in nav2 main.
The Test workflow targets ROS Rolling's released form Lyrical on Ubuntu 26.04 (resolute), where the apt repo is consistent and rosdep works. navigation2 main and Fields2Cover are not released as binaries there, so they are built from source via deps.repos. action-ros-ci is replaced with explicit steps because the build needs a source patch applied between vcs import and colcon build, which the action does not allow. deps.repos -- pull what is missing from / too old in the Lyrical apt repo: - ortools_vendor @ main (not tag 9.9.0): USE_SCIP=OFF drops the SCIP build whose bundled tinycthread does not compile under GCC 15, and forwards CMAKE_POLICY_VERSION_MINIMUM into the OR-Tools sub-build. - behaviortree_cpp @ master: nav2 main uses its wakeUpSignal() getter, which no release provides yet (Lyrical ships 4.9.0). - slam_toolbox @ ros2: not in the Lyrical rosdistro at all. Workflow steps mirror the proven lyrical-full dev container: - libompl-dev installed explicitly for nav2_smac_planner (rosdep cannot resolve the 'ompl' key on Lyrical). - strip -Werror from nav2_common so nav2 main's new GCC-15 warnings do not fail the build; our opennav packages keep their own -Werror. - remove any apt behaviortree_cpp 4.9.0 that would shadow the source master. - CMAKE_POLICY_VERSION_MINIMUM=3.5 for CMake 4 on Ubuntu 26.04.
Two adjustments so the manual Lyrical build reproduces the dev container: - Drop ros-lyrical-ompl after rosdep. rosdep resolves the 'ompl' key to ros-lyrical-ompl 2.0.1, which installs into /opt/ros/lyrical and shadows the system libompl-dev 1.6.0. OMPL 2.0.1 renamed/removed the ReedsShepp API (ReedsSheppStateSpace::ReedsSheppPath, reedsShepp()) that nav2 main's nav2_smac_planner is written against, so it failed to compile. Removing it lets find_package(ompl) fall back to libompl-dev 1.6.0 -- the API nav2 main expects, and what the dev container already uses. - Pin CC/CXX to gcc-15/g++-15 (Ubuntu 26.04's default, 15.2.0 in the dev container) so CI uses the same toolchain we validate locally and rosdep cannot silently pull gcc-16.
…very opennav_coverage_demo declared its test dependency with the legacy tests_require, which modern setuptools (Python 3.14) drops, emitting "Unknown distribution option: 'tests_require'". colcon selects its Python testing step from the parsed test dependencies, so with tests_require gone it fell back to the unittest runner, which collected 0 tests and returned exit code 5 (NO TESTS RAN), failing colcon test. Declaring the dependency under extras_require['test'] is the modern, setuptools-preserved equivalent, so colcon detects pytest and runs the package's ament_lint tests (copyright, flake8, pep257), which pass.
Each run rebuilt nav2, Fields2Cover, ortools_vendor, slam_toolbox and behaviortree_cpp from source (~1h), which is slow and exposed a flaky parallel-build race in ortools_vendor (gurobi.pb.h generated late under -j, intermittently "No such file or directory"). Move the vcs-imported third-party sources into src/deps and cache them together with build/ and install/, keyed on deps.repos. On a cache hit the import and the -Werror patch are skipped so the restored sources keep their mtimes and colcon reuses the prebuilt deps; only opennav_coverage (checked out separately) rebuilds. The cache is saved via actions/cache/save only after a successful build, so a broken or partial build (e.g. a raced ortools_vendor) is never cached. First run is a miss (full build, may still need a rerun to get past the race); every run after that restores the cache and finishes in minutes.
main now uses Fields2Cover v2 (v2.0.0) built from source via deps.repos; F2C has no binary on Lyrical so rosdep cannot resolve the fields2cover key there. Drop the stale 'v2.0.0 not supported' note, document the vcs import flow, and point older distros to their v1.2.1 refs / F2C v2 branches.
The first build on a fresh runner has no cache yet, so it builds the heavy third-party deps from source and can hit the intermittent ortools_vendor parallel-build race (gurobi.pb.h). Re-running until one build succeeds seeds the colcon cache (saved only on success); subsequent runs restore it and skip the rebuild, so the race cannot recur.
SteveMacenski
left a comment
There was a problem hiding this comment.
I don't understand what's happeningi n the test.yml file from a quick glance, but I think alot about it should be reverted. It looks like AI was pointed at it and added a ton of things that should be removed. Lets keep this simple.
I'm also creating a lyrical branch if you want to have this target lyrical since it seems like you did that already! We can have Lyrical support V2 out of the box
Co-authored-by: Steve Macenski <[email protected]>
|
Let me kno wwhen you want me to look again |
Sure, if there are any improvements that need to be made to |
backward_ros is a build dependency of several nav2 packages. On a cold rolling/resolute (26.04) build the rosdep step (run with '|| true') can leave it unresolved, so nav2_common's find_package(backward_ros) fails. Installing it explicitly alongside the other system deps makes the build deterministic. Verified in the rolling-full dev container: 54-package broad-scope build plus 272 tests, 0 failures.
|
There is okey i guess. You can merge. |
|
@SteveMacenski I plan to start integrating the new features introduced with f2cv2 soon. Is there a different repository or any issues you’d recommend I look into, or would you prefer that I focus on this one? |
|
If you want to work on F2C integrations for Nav2, this would be the place! if you wanted to contribute to other Nav2 projects, then Nav2's home repo is probably the right place to look :-) Check out the issue tracker for any other projects w.r.t. this https://github.com/open-navigation/opennav_coverage/issues |
|
I’ll be working on the F2C integration for a while longer. When I looked at other projects, this seemed more reasonable in terms of cost-benefit, but CI/CD and local tests are taking too long. Isn’t there a way to use the packages we installed from source as binaries? |
|
Yes in Jazzy, Kilted, Humble, etc :- ) |
|
I know they have it, but what about in Rolling? |
|
Nav2 does not and will not have rolling binaries anytime soon |
|
alright :( |
|
But local builds should be fast- just build once and you should have it for the duration of all your testing. You should never need to recompile Nav2 |
|
I use devcontainer on my local machine so I don't have to keep changing the operating system; even though I cache the builds, whenever I make changes in Dockerfile, it has to rebuild from scratch. It's probably a skill issue on my part. |
|
Mount you workspace locally to a directory so the build artifacts persist between builds so its not internal to the container, at the very least |
|
I’d break into logical chunks. 25x 5 line PRs is more annoying but 1x 2,000 line one is intractable. Use your best judgement. Keep them under ~3 features though |
|
All right, I'll try to balance things out. |
|
Ooo cool! |
|
While using it in my own project, I found some bugs, and I need to fix them across all distros. Do I need to open a separate PR for each one, or is there an easier way? For now, I'll enable it for all distros so it can be fixed quickly, but it would be good for me to learn about any future ones, if there are any. |
|
Depends on how complicated the bugs are, but they should definitely be separated from exposing new features. |




Summary
Brings the full
opennav_coveragestack to Fields2Cover v2 (verified againstv2.0.0) onmain, and fixes a number of build, runtime, and CI issues uncovered along the way. All breaking F2C API usage is updated and the build/CI is reworked so the whole package set — includingopennav_coverage_btandopennav_coverage_navigator— builds and passes tests on ROS 2 Rolling (released as Lyrical on Ubuntu 26.04). The coverage pipeline itself has no intended behavioral change.Motivation
Fields2Cover v2 introduced several breaking API changes: encapsulated data models (private members + accessors), renamed methods, and a restructured robot model. This brings the coverage server stack up to date with the current F2C release on the rolling/Lyrical distribution — and fixes the issues that surfaced when building and testing the full stack there.
Changes — Fields2Cover v2 API
Each commit is scoped to one migration area (shared with the humble/jazzy PRs):
types.hppLineStringtypedefF2CRobotpublic fields → setters/getters (setWidth/setCovWidth/setMinTurningRadius/setMaxDiffCurv,getWidth/getCovWidth); same in both dynamic-parameter callbacksBruteForce::step_anglefield →setStepAngle()PathPlanning::searchBestPath→planPath;turn_point_distfield →TurningBase::setDiscretization()F2CFieldcoord_sys/fieldmembers →getCRS()/getField()utils.hppPath::states→operator[]/size()/back()(now private)LineString::StartPoint()/EndPoint()→ camelCasestartPoint()/endPoint()generateRandFieldargument order (swapped in v2) andPathState::typenow defaulting toSWATHHeadland and route generators required no source changes (their APIs are unchanged in v2).
Fixes
PathComponentsIterator::getNextso iterating path components no longer reads past the end of the swath collection.opennav_coverage_demoreported as failing with no tests run: its test dependency was declared with the legacytests_require, which modern setuptools drops; colcon then fell back to the unittest runner, collected 0 tests, and exited with code 5. Declaring it viaextras_require={'test': ['pytest']}makes colcon discover and run the package'sament_linttests (copyright, flake8, pep257).rclcpp::spin_some→SingleThreadedExecutorin the viz test; bothget_package_share_directoryoverloads are deprecated on Rolling butget_package_share_pathdoes not exist on Jazzy, so the single-arg call is kept and wrapped in a-Wdeprecated-declarationspragma for one cross-distro code path.Changes — build system
ament_target_dependencies→target_link_libraries: this macro was removed on Rolling, soopennav_coverage,opennav_coverage_bt,opennav_coverage_navigatorand their tests now link modern namespaced targets (pkg::pkg,${pkg_TARGETS}for message packages,nav2_util::nav2_util_core,nav2_ros_common::nav2_ros_common, etc.).GDAL::GDALexplicitly — v2's CMake target no longer propagates GDAL as an interface dependency.opennav_row_coverageviatinyxml2_vendor+find_package(TinyXML2)(the systemlibtinyxml2-devships no CMake config).Fields2Coverfor source installs,Fields2Cover::Fields2Coverfor the packaged target) and mark F2C headers asSYSTEMso their own-Wshadowwarnings do not break this-Werrorbuild.Changes — CI (detailed)
The
Testworkflow is rebuilt to run on Lyrical with a manual colcon pipeline:setup-ros-docker ... resolute-ros-lyrical(Ubuntu 26.04). ROS Rolling has been released as Lyrical there, where the apt repo is consistent androsdepworks — unlike rolling-on-Noble, where rosdep cannot resolve rolling keys..github/deps.repos), since nav2 and F2C are not published as binaries on Lyrical:navigation2→mainFields2Cover→v2.0.0ortools_vendor→main(setsUSE_SCIP=OFF, avoiding the SCIP/tinycthread GCC-15 failure)slam_toolbox→ros2behaviortree_cpp→master(nav2mainuses its unreleasedwakeUpSignal()getter)action-ros-ci, because nav2mainneeds a source patch applied betweenvcs importandcolcon build:-Werrorfromnav2_common'snav2_package.cmake(nav2mainis not-Werror-clean under GCC 15: deprecatedstd::atomic_loadonshared_ptr, etc.). Our own opennav packages keep their-Werror.rosdepcan't provide here:libompl-dev(fornav2_smac_planner'sfind_package(ompl)), GDAL/Eigen/GEOS/tinyxml2,tinyxml2-vendor, Cyclone DDS.ros-lyrical-behaviortree-cpp— the binary 4.9.0 would shadow the source-builtmasterin the shared include tree.ros-lyrical-ompl— rosdep resolves theomplkey to 2.0.1, whose ReedsShepp API differs (ReedsSheppStateSpace::ReedsSheppPath/reedsShepp()renamed), breakingnav2_smac_planner. Removing it falls back to systemlibompl-dev1.6.0, the API nav2mainexpects.CMAKE_POLICY_VERSION_MINIMUM=3.5— Ubuntu 26.04 ships CMake 4, which hard-errors on dependencies declaringcmake_minimum_required(VERSION < 3.5)(e.g. the zlib bundled by OR-Tools); this also propagates into nested FetchContent/ExternalProject sub-builds.CC/CXX) so the CI toolchain matches the dev container and rosdep cannot transitively pull GCC 16.src/depsand cached together withbuild/andinstall/, keyed ondeps.repos. They build from source once (~1 h) and are reused on every subsequent run (CI then finishes in minutes), which also removes a flaky OR-Tools parallel-build race (gurobi.pb.hgenerated late under-j). The cache is saved only after a successful build, so a broken/partial build is never cached; on a hit, the import and-Werrorpatch are skipped so restored sources keep their mtimes.nav2_bt_navigator nav2_behavior_treeplus allopennav_*packages; the test step runs theopennav_*suites..github/lint.ymlalso bumpsactions/checkoutto v4 and addsopennav_row_coverageto the lint matrix.Validation
Notes
mainnow uses F2C v2 from source (F2C has no binary on Lyrical, so rosdep cannot resolve thefields2coverkey there).jazzybranch (PR Migrate to Fields2Cover v2 (Jazzy) #109) — nav2main'sLoopRateusesbehaviortree_cpp'swakeUpSignal(), which is ahead of thebehaviortree_cppbinary Jazzy ships ('class BT::Tree' has no member named 'wakeUpSignal'), as discussed in Migrate to Fields2Cover v2 (Humble) #105.tinycthread.h/ conflictingpthread_once_t) is gone becauseortools_vendor'smainsetsUSE_SCIP=OFF;slam_toolboxandortools_vendorare built from source as they have no Lyrical binary; and CMake 4's hard error on old minimums is handled viaCMAKE_POLICY_VERSION_MINIMUM=3.5. Building the full nav2 stack from source on Lyrical is what surfaced (and now verifies) the broad-scope build.CI caveats — interim approach
This CI gets a fully green broad-scope build on Lyrical today, but it is a pragmatic interim approach and may not be sustainable long-term. I want to be upfront about why (continuing from #105):
main,slam_toolbox,ortools_vendor,behaviortree_cpp). This is heavy and slow, and tightly couples our CI to the current state of those upstreams.navigation2 main,behaviortree_cpp master,ortools_vendor main) because that is what nav2mainrequires right now. These are not reproducible — an upstream change can break our CI with no change on our side.ros-lyrical-ompl2.0.1,ros-lyrical-behaviortree-cpp4.9.0) and falls back to system/source versions. This is a workaround for upstream version skew on Lyrical, not a real fix, and will likely need revisiting as the Lyrical ecosystem stabilizes.I went this route to unblock the migration and get a verifiable green build; would like to hear your guidance on how you'd like CI maintained here.