Skip to content

refactor(autoware_trajectory_follower): introduce lateral controller interface - #13547

Merged
interimadd merged 5 commits into
autowarefoundation:mainfrom
interimadd:refactor/autoware_trajectory_follower_base-introduce-lateral-controller-interface
Oct 27, 2026
Merged

interimadd merged 5 commits into
autowarefoundation:mainfrom
interimadd:refactor/autoware_trajectory_follower_base-introduce-lateral-controller-interface

Conversation

@interimadd

@interimadd interimadd commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR replaces LateralControllerBase with LateralControllerInterface. It makes the same change for the lateral controller that #13539 made for the longitudinal controller. The new interface has one function:

virtual tl::expected<LateralOutput, std::string> run(
  const InputData & input_data, const rclcpp::Time & stamp) = 0;

The old base class had three problems. The caller had to call isReady() before run(). The steering offset reached the controller through a separate function, set_steering_offset(), which the subscription callback called between two cycles. run() had no way to report a failure. With the new interface, one call gets all the data for the cycle and returns all the results.

The diff is easy to read commit by commit. Each commit makes one small change, builds, and passes the tests.

  1. pass stamp to lateral run(): MpcLateralControllerNode and PurePursuitLateralControllerNode read the clock by themselves. Now the Controller passes the time that it reads once at the start of the cycle. The longitudinal controller and control_cmd.stamp already use this value. The pure_pursuit test now gives the time of the cycle to run() and does not set a simulated clock.
  2. pass steering offset through InputData: The new field InputData::steering_offset replaces set_steering_offset(). Its type is Float32Stamped, the message type of ~/input/steering_offset_update, because the other fields of InputData also hold the received messages. The Controller keeps the latest message and puts it in InputData. MpcLateralController reads the offset from InputData. Before the first message, the offset is 0, as before.
  3. return tl::expected from lateral run() and remove isReady(): This commit folds isReady() into run(). If MpcLateralController::isReady() returns false, MpcLateralControllerNode::run() returns an error. MpcLateralController::isReady() does not change, and it still logs the condition that failed. PurePursuitLateralControllerNode::isReady() always returned true, so its run() always returns a value. The Controller logs the reason and skips the cycle. controller_node.hpp got boost/optional.hpp through the old header, so this commit includes it there directly.
  4. rename LateralControllerBase to LateralControllerInterface: This is a mechanical rename of the class, the header file, and the include guard. The class has no state and no default implementation, so it is an interface and not a base.
  5. update READMEs for LateralControllerInterface: The two READMEs now describe the new interface and the new process flow.

Related links

Parent Issue:

  • Link

Related PRs:

How was this PR tested?

After each commit that changes the code, I ran colcon build and colcon test for autoware_trajectory_follower_base, autoware_mpc_lateral_controller, autoware_pure_pursuit, autoware_pid_longitudinal_controller and autoware_trajectory_follower_node. All tests passed.

TIERIV internal Evaluator links
https://evaluation.ci.tier4.jp/evaluation/reports/946a0a1f-7474-5ece-a53b-195294a3eb65?project_id=autoware_dev
https://evaluation.ci.tier4.jp/evaluation/reports/e371500e-686b-5754-a7c0-d573f56d155a?project_id=autoware_dev
https://evaluation.ci.tier4.jp/evaluation/reports/7a316529-b6d2-5405-8db9-514b9005b1fd?project_id=autoware_dev

Notes for reviewers

Please review the PR commit by commit. Each commit is small and has one purpose.

Interface changes

None.

Effects on system behavior

None.

The Controller reads the time once at the start of the cycle and passes it, instead of MpcLateralControllerNode and PurePursuitLateralControllerNode reading the clock by themselves. The pure_pursuit test now passes the time of the cycle instead of setting a simulated clock.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>
…ough InputData

Replace set_steering_offset() with InputData::steering_offset. The Controller keeps the latest message received on ~/input/steering_offset_update and passes it in InputData, and MpcLateralController reads it from there.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>
… lateral run() and remove isReady()

run() can now report why it cannot compute the command, so isReady() is folded into it. MpcLateralControllerNode returns an error when MpcLateralController::isReady() fails, and MpcLateralController still logs which condition failed. PurePursuitLateralControllerNode always returns a value, as its isReady() always returned true. The Controller logs the reason and skips the cycle. Include boost/optional.hpp in controller_node.hpp, which got it through lateral_controller_base.hpp.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>
…Base to LateralControllerInterface

The class has only a pure virtual function and no state, so it is an interface rather than a base. Rename the header to lateral_controller_interface.hpp as well.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>
…ntrollerInterface

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>
@interimadd interimadd added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Oct 27, 2026
@github-actions github-actions Bot added type:documentation Creating or refining documentation. (auto-assigned) component:control Vehicle control algorithms and mechanisms. (auto-assigned) labels Oct 27, 2026
@github-actions

Copy link
Copy Markdown

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 38.30%. Comparing base (e4e36e8) to head (724cb79).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...e_trajectory_follower_node/src/controller_node.cpp 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13547      +/-   ##
==========================================
- Coverage   38.31%   38.30%   -0.01%     
==========================================
  Files        2034     2034              
  Lines      141865   141849      -16     
==========================================
- Hits        54349    54336      -13     
+ Misses      87516    87513       -3     
Flag Coverage Δ *Carryforward flag
full-suite 38.29% <ø> (-0.02%) ⬇️ Carriedforward from e4e36e8

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@interimadd
interimadd merged commit f135adf into autowarefoundation:main Oct 27, 2026
49 of 54 checks passed
@github-project-automation github-project-automation Bot moved this from To Triage to Done in Software Working Group Oct 27, 2026
interimadd added a commit to tier4/autoware_universe that referenced this pull request Oct 28, 2026
…interface (autowarefoundation#13547)

* refactor(autoware_trajectory_follower_base): pass stamp to lateral run()

The Controller reads the time once at the start of the cycle and passes it, instead of MpcLateralControllerNode and PurePursuitLateralControllerNode reading the clock by themselves. The pure_pursuit test now passes the time of the cycle instead of setting a simulated clock.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>

* refactor(autoware_trajectory_follower_base): pass steering offset through InputData

Replace set_steering_offset() with InputData::steering_offset. The Controller keeps the latest message received on ~/input/steering_offset_update and passes it in InputData, and MpcLateralController reads it from there.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>

* refactor(autoware_trajectory_follower_base): return tl::expected from lateral run() and remove isReady()

run() can now report why it cannot compute the command, so isReady() is folded into it. MpcLateralControllerNode returns an error when MpcLateralController::isReady() fails, and MpcLateralController still logs which condition failed. PurePursuitLateralControllerNode always returns a value, as its isReady() always returned true. The Controller logs the reason and skips the cycle. Include boost/optional.hpp in controller_node.hpp, which got it through lateral_controller_base.hpp.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>

* refactor(autoware_trajectory_follower_base): rename LateralControllerBase to LateralControllerInterface

The class has only a pure virtual function and no state, so it is an interface rather than a base. Rename the header to lateral_controller_interface.hpp as well.

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>

* docs(autoware_trajectory_follower_base): update READMEs for LateralControllerInterface

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>

---------

Signed-off-by: Takahisa.Ishikawa <takahisa.ishikawa@tier4.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:control Vehicle control algorithms and mechanisms. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants