Skip to content

Feat/using new tf manager - #6651

Merged
SteveMacenski merged 52 commits into
ros-navigation:mainfrom
nirwester:feat/using_new_tf_utils
Nov 24, 2026
Merged

SteveMacenski merged 52 commits into
ros-navigation:mainfrom
nirwester:feat/using_new_tf_utils

Conversation

@nirwester

@nirwester nirwester commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Basic Info

Info Please fill out this column
Ticket(s) this addresses #6316
Primary OS tested on Ubuntu
Robotic platform tested on Local tests and TB sim only
Does this PR contain AI generated software? Yes, reviewed
Was this PR description generated by AI software? No

Description of contribution in a few bullet points

Replaces all calls to the tf buffer with the new tf utils.

Description of documentation updates required from your changes

ros-navigation/docs.nav2.org#954

Description of how this change was tested

Only local tests and TB simulation


Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in docs.nav2.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists
  • Should this be backported to current distributions? If so, tag with backport-*.

@nirwester
nirwester force-pushed the feat/using_new_tf_utils branch from 1c3a093 to 4324cd7 Compare October 13, 2026 15:48
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.67089% with 40 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nav2_controller/plugins/feasible_path_handler.cpp 70.58% 5 Missing ⚠️
nav2_loopback_sim/src/loopback_simulator.cpp 28.57% 5 Missing ⚠️
...ree/plugins/condition/are_poses_near_condition.cpp 20.00% 4 Missing ⚠️
...ior_tree/plugins/decorator/distance_controller.cpp 69.23% 4 Missing ⚠️
.../plugins/condition/distance_traveled_condition.cpp 70.00% 3 Missing ⚠️
...avigator/src/navigators/navigate_through_poses.cpp 72.72% 3 Missing ⚠️
...2_bt_navigator/src/navigators/navigate_to_pose.cpp 76.92% 3 Missing ⚠️
nav2_controller/src/controller_server.cpp 90.47% 2 Missing ⚠️
nav2_costmap_2d/src/observation_buffer.cpp 95.83% 2 Missing ⚠️
nav2_amcl/src/amcl_node.cpp 96.87% 1 Missing ⚠️
... and 8 more
Files with missing lines Coverage Δ
...lugins/action/append_goal_pose_to_goals_action.hpp 100.00% <ø> (ø)
...r_tree/plugins/action/concatenate_paths_action.hpp 100.00% <ø> (ø)
...ins/action/extract_route_nodes_as_goals_action.hpp 100.00% <ø> (ø)
...or_tree/plugins/action/get_current_pose_action.hpp 100.00% <ø> (ø)
..._tree/plugins/action/get_next_few_goals_action.hpp 100.00% <ø> (ø)
..._tree/plugins/action/get_pose_from_path_action.hpp 100.00% <ø> (ø)
...tree/plugins/action/remove_passed_goals_action.hpp 100.00% <ø> (ø)
...tree/plugins/action/truncate_path_local_action.hpp 100.00% <ø> (ø)
...ree/plugins/condition/are_poses_near_condition.hpp 100.00% <ø> (ø)
.../plugins/condition/distance_traveled_condition.hpp 100.00% <ø> (ø)
... and 148 more

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nirwester
nirwester force-pushed the feat/using_new_tf_utils branch from 6cb8951 to 7cdbde7 Compare October 16, 2026 19:56
@nirwester
nirwester marked this pull request as ready for review October 20, 2026 12:58

@SteveMacenski SteveMacenski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think there's more details we can hide/simpify for application code

Comment thread nav2_amcl/src/amcl_node.cpp Resolved
@mergify

mergify Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

This pull request is in conflict. Could you fix it @nirwester?

@nirwester
nirwester force-pushed the feat/using_new_tf_utils branch 2 times, most recently from 0687793 to 3881d9c Compare October 23, 2026 14:47
@nirwester nirwester changed the title Feat/using new tf utils Feat/using new tf manager Oct 23, 2026
@nirwester
nirwester force-pushed the feat/using_new_tf_utils branch 4 times, most recently from ec1f47d to 3549bd1 Compare October 25, 2026 20:45

@SteveMacenski SteveMacenski left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I melted by brain on approving 250/285 files, so please avoid force pushing or rebasing from now until the final go at it.

Broadly speaking great, just a few small details at this point

Comment thread nav2_amcl/src/amcl_node.cpp Resolved
Comment thread nav2_bt_navigator/src/bt_navigator.cpp Resolved
Comment thread nav2_collision_monitor/src/polygon.cpp Resolved
@mergify

mergify Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

This pull request is in conflict. Could you fix it @nirwester?

Comment on lines +227 to +231
void setTime(const rclcpp::Time & time)
{
ASSERT_EQ(rcl_set_ros_time_override(tf_clock_->get_clock_handle(), time.nanoseconds()),
RCL_RET_OK);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not grokking this change. Why is this required uniquely now? Seems like maybe something AI went a little off a side tangent on

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These tests simulate elapsed time by passing future timestamps, but the manager now internally checks staleness with its own clock_->now(). This makes the test’s supplied timestamp and the manager’s current time advance together.

  • get_clock_handle accesses the underlying ROS clock.
  • rcl_set_ros_time_override sets its simulated time in nanoseconds
  • ASSERT_EQ(..., RCL_RET_OK) checks that setting the clock succeeded.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe take a look at the architecture if this can be simplified

Comment on lines +80 to +83
rclcpp::Clock::SharedPtr get_clock()
{
return tf_clock_ ? tf_clock_ : nav2::LifecycleNode::get_clock();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This lets the same test node support an optional clock controlled by the test (now done only by ClockTester).
Could also be rewritten to use the node’s normal ROS clock for both the node and manager, then use steady_clock for the test’s wait deadlines, which probably would look nicer

@SteveMacenski SteveMacenski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Via AI:

Error logs are duplicated and the details are lost. Many converted sites call with the default Log::Enabled and then log their own message without passing error_msg. You get two lines per failure, and the caller’s line no longer includes the exception text it used to. Affected sites:

  • AMCL addNewScanner and updateFilter
  • ObservationBuffer::bufferCloud (both lookups)
  • transformPathInTargetFrame
  • feasible_path_handler
  • costmap_filter

The addNewScanner message now ends with a dangling "...message notifier is in use:" and nothing after it. The consistent pattern is Log::Disabled plus &tf_error wherever the caller logs.

Comment thread nav2_amcl/src/amcl_node.cpp Resolved
@nirwester

nirwester commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

the caller’s line no longer includes the exception text it used to

The information is not lost, but it's on a different message, having the internal logger means that what previously was unified in a single message like

Failed to transform initial pose in time (<specific TF failure>)

Now often looks like a tf error + a separate contextual error.

Failed to get transform ...: <specific TF failure>

Failed to transform initial pose in time

Currently (according to AI) of 73 calls 12 only log outside (using the debug string), 18 only log inside, 43 have the double log.

If we want to avoid the double log, we could

  • switch everything to use the debug string, remove the internal logging and add the missing 18 external LOG.
  • disable logging in all the places where another msg is already being logged, then add the contextual string.

In both cases that would imply adding a lot of std::strings declarations in the codebase for the errors.

Let me know if you prefer it to stay as it is, if you prefer following one of the 2 approaches or something else.

@SteveMacenski

Copy link
Copy Markdown
Member

From our discussion

  • Remove the Log log and require the tf_error string for printing contextual errors in the application code
  • Remove the other 2 raw buffer accessors and rename the shared pointer one without shared pointer (since it is now the only one)
  • Simplify the concurrency for the static broadcaster - doxygen that it is not thread safe (also missing doxygen in general :-) )

Comment thread nav2_route/src/graph_saver.cpp Resolved
Comment thread nav2_route/src/graph_loader.cpp Resolved
Comment thread nav2_costmap_2d/src/costmap_2d_ros.cpp Resolved
Comment thread nav2_costmap_2d/src/costmap_2d_ros.cpp Outdated
Comment on lines +270 to +273
// An immediate cleanup must not cancel the executor before spin() starts.
while (!executor_->is_spinning() && get_node_base_interface()->get_context()->is_valid()) {
std::this_thread::yield();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This fixes a race conditions on the tests that can happen on rclcpp < 33.1.0: cleanup could run before the executor thread starts, so its stop request gets overwritten and the test hangs waiting for the thread to finish.
This loop waits until the executor starts before allowing cleanup, preventing that race.
Newer version of rclcpp preserve cancellation requested before spin() starts.
If you think this should be removed, as rclcpp has a fix for it already, I can remove it.

Comment thread nav2_ros_common/README.md
It also allows a central and controlled location to make future changes such as adding tracing, replacing APIs, controlling QoS profiles, or enabling advanced settings.
Thus, see the migration guide below for how to migrate from the previous versions of these objects to the new ones in this package from ROS 2 Kilted to Lyrical.

### Transform manager

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now that we're nearing the end of this PR, rewrite this as a human for expaining this object and how to use it. This reads too much like mechanical AI focusing on unimportant implementation details/arguments rather than the high level of what it is, why, and the key APIsto use.

@SteveMacenski SteveMacenski left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few small cleanup details:

Unused clock_ in six BT nodes. GetCurrentPose, RemovePassedGoals, TruncatePathLocal, DistanceTraveled, GoalReached and DistanceController still set it, but nothing uses it now.


IsGoalNearby now reads transform_tolerance_. The member is uninitialized (is_goal_nearby_condition.hpp:95) if the node never declared the parameter, for example in test fixtures. Give it a default of {0.1}; are_poses_near_condition.hpp:89 has the same problem.


How about the clock timing changes for the collision monitor that you were manipulating the clocks for? (#6651 (comment))

@SteveMacenski SteveMacenski left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only 1 open file left on my end is the README. The readme I think you just need to be more human and thoughtful in the write up. These details are the things people actually touch regularly.

You can rebase now as everything else is approved. Afterward, spend a few minutes writing a new readme by hand from scratch to describe the object, its use, and APIs at a high level. You don't need to give all the detail about the implementation to such a degree. This is a high level introduction.

Comment thread nav2_ros_common/README.md Resolved
@nirwester
nirwester force-pushed the feat/using_new_tf_utils branch from b6b0b01 to 4e44543 Compare November 24, 2026 14:19
nirwester and others added 20 commits November 24, 2026 15:14
Signed-off-by: Marco Matteo Bassa <[email protected]>
Signed-off-by: Marco Bassa <[email protected]>
Signed-off-by: Marco Bassa <[email protected]>
Signed-off-by: Marco Bassa <[email protected]>
@nirwester
nirwester force-pushed the feat/using_new_tf_utils branch from 4e44543 to 3545002 Compare November 24, 2026 15:34

@SteveMacenski SteveMacenski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One last item

Comment thread nav2_costmap_2d/src/costmap_2d_ros.cpp Outdated
// An immediate cleanup must not cancel the executor before spin() starts.
while (!executor_->is_spinning() && get_node_base_interface()->get_context()->is_valid()) {
std::this_thread::yield();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From our previous discussions: please remove this. If this is fixed now, we can remove this.

@SteveMacenski
SteveMacenski merged commit 32d3136 into ros-navigation:main Nov 24, 2026
19 checks passed
SteveMacenski pushed a commit to open-navigation/opennav_coverage that referenced this pull request Nov 27, 2026
* Pin Fields2Cover to v2.1.1 for the upstreamed fixes

Fields2Cover v2.1.1 carries the fixes and APIs this package used to work
around: HL_SWATH densification, the corridor headland and the
degenerate-polygon guard.

(cherry picked from commit 2ef1796, part of #162)
Signed-off-by: u33549 <[email protected]>

* Drop the unused multi-cell headland overload

The server only calls the Field overload; the F2CCells one had no
callers left after the headland-first decomposition rework.

(cherry picked from commit 93915e2, part of #162)
Signed-off-by: u33549 <[email protected]>

* Let Fields2Cover densify headland passes

Path::discretizeSwath now splits HL_SWATH states as well, so the local
copy that did the same is no longer needed. The step guard stays at the
call site since Fields2Cover does not clamp a zero step.

(cherry picked from commit 195b002, part of #162)
Signed-off-by: u33549 <[email protected]>

* Carve the inter-cell corridor with Fields2Cover

CorridorHL finds the borders cells really share and carves the corridor
from the smaller cell. route_headland_width is now the total corridor
width; the previous code could carve it from both cells, or miss a
partially shared border.

Also drops the sliver filter Fields2Cover no longer needs: CorridorHL already removes the zero-width pieces carving leaves, and the degenerate-polygon crash the filter guarded against is fixed upstream.

(cherry picked from commit 8ecb2f4, part of #162)
(cherry picked from commit a4f3a87, part of #162)
Signed-off-by: u33549 <[email protected]>

* Remove the unused default_max_swaths_for_global_route parameter

It has had no effect since multi-cell TSP routing moved to a per-cell
solve; the threshold it set is no longer read.

(cherry picked from commit 852e0f1, part of #162)
Signed-off-by: u33549 <[email protected]>

* Report where a swath ends in the coverage path message

With Fields2Cover v2 a straight swath is a single path state, so taking
the end from that state's start point gave every swath start == end.
Use PathState::atEnd() instead.

(cherry picked from commit af70ccf, part of #162)
Signed-off-by: u33549 <[email protected]>

* Densify GPS paths before leaving the field frame

The densification step is in meters, but it ran after the path was
converted to the GPS frame, so swath lengths were in degrees and no
state was ever split.

(cherry picked from commit e7eb93b, part of #162)
Signed-off-by: u33549 <[email protected]>

* Fix the rolling CI build against nav2 main (#163)

* Use the ROS ompl that nav2 main builds against in CI

The CI dropped ros-rolling-ompl for the system libompl-dev 1.6 because
nav2 main was once written against the older ReedsShepp API. nav2 now
builds with the ROS ompl 2.x (and links its ompl::ompl target), so keep
it and drop libompl-dev.


* Include the ament_index_cpp header the navigator uses

coverage_navigator.cpp and its test call get_package_share_directory
but relied on nav2 headers to pull it in, which nav2 main no longer
does. Include it and declare the dependency.


* Build the navigator test's tf objects with the nav2 factories

Newer tf2_ros dropped the CreateTimerROS and TransformListener
constructors the test used. nav2::create_transform_buffer and
create_transform_listener pick the right ones for the installed rclcpp.


---------

Adapted for lyrical: the navigator's ament_index_cpp include and dependency are already on lyrical, so only the CI ompl change and the navigator test's tf2 factories apply. Lyrical's CI image, distro and launch_testing shim are kept.

(cherry picked from commit eb43d10)
Signed-off-by: u33549 <[email protected]>

* Build the lyrical CI against nav2's lyrical branch

nav2 main changed its TF API in ros-navigation/navigation2#6651
(FeedbackUtils::tf became tf_manager and tf2_factories.hpp is gone), so
the navigator no longer builds against it. Lyrical follows nav2's lyrical
branch, which keeps the API this package uses.

Signed-off-by: u33549 <[email protected]>

* Set headers on generated coverage path poses (#159)

* Set headers on generated coverage path poses


* Set pose headers in the PathState converter


---------

Adapted for lyrical: keeps lyrical's existing SWATH densify check in TesttoNavPathMsg.

(cherry picked from commit c4c1225)
Signed-off-by: Bram Odrosslij <[email protected]>
Signed-off-by: u33549 <[email protected]>

---------

Signed-off-by: u33549 <[email protected]>
Signed-off-by: Bram Odrosslij <[email protected]>
Co-authored-by: Bram O <[email protected]>
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.

2 participants