Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoware_mpc_lateral_controller): add predicted trajectory acconts for input delay #8436

Conversation

kyoichi-sugahara
Copy link
Contributor

@kyoichi-sugahara kyoichi-sugahara commented Aug 10, 2024

Description

merging this PR first.

Current Implementation Issue

The MPC optimization calculation uses an initial state that accounts for input delay. However, in the current implementation, when calculating the predicted trajectory from the obtained solution, it uses the currently observed state instead of the state that considers this delay. This creates an inconsistency between the optimization calculation and the trajectory prediction.

New Visualization Option

To verify the accuracy of following the reference trajectory, I have added an option to visualize the resampled reference trajectory.

Initial Findings

  • Initial verification results suggest that the predicted trajectory considering delay follows the target path more accurately.
  • As the steering angle increases, the difference between the predicted trajectories with and without delay consideration tends to become larger.

Note: Further verification is needed to confirm these initial findings.

image

Line Color Description Coordinate Topic Name
🔵 Blue (dotted) Reference trajectory World /control/trajectory_follower/controller_node_exe/debug/resampled_reference_trajectory
⚪ White Predicted trajectory World /control/trajectory_follower/controller_node_exe/debug/predicted_trajectory_with_delay
🔴 Red Predicted trajectory (with delay consideration) World /control/trajectory_follower/lateral/predicted_trajectory

How was this PR tested?

by visualizing predicted trajectory w/wo delay and reference trajectory

2024-08-10_22.09.13.mp4

Notes for reviewers

Ideally, we should interpolate the trajectory from the current state to the state considering input delay, and then generate the predicted trajectory from this delay-considered state. Please note that the trajectory visualized in this PR generates the predicted trajectory directly from the delay-considered state without performing this interpolation.

ROS Parameter Changes

Additions and removals

Change type Parameter Name Type Default Value Description
Added debug_publish_resampled_reference_trajectory bool false Publish debug resampled reference trajectory

@github-actions github-actions bot added the component:control Vehicle control algorithms and mechanisms. (auto-assigned) label Aug 10, 2024
Copy link

github-actions bot commented Aug 10, 2024

Thank you for contributing to the Autoware project!

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

Please ensure:

@github-actions github-actions bot added type:documentation Creating or refining documentation. (auto-assigned) component:perception Advanced sensor data processing and environment understanding. (auto-assigned) component:common Common packages from the autoware-common repository. (auto-assigned) labels Aug 13, 2024
@kyoichi-sugahara kyoichi-sugahara force-pushed the feat/add_predicted_trajectory_with_delay branch from dd1943f to 09b2739 Compare August 13, 2024 01:10
@github-actions github-actions bot removed component:perception Advanced sensor data processing and environment understanding. (auto-assigned) component:common Common packages from the autoware-common repository. (auto-assigned) labels Aug 13, 2024
Comment on lines 111 to 112
predicted_trajectory = calculatePredictedTrajectory(
mpc_matrix, x0, Uex, mpc_resampled_ref_trajectory, prediction_dt, "world");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to apply the input delay to the official predicted trajectory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@takayuki5168
Based on my understanding, it's better to apply the input delay for the official predicted path. In my additional tests, I've found that when reducing steer_tau, the original predicted path tends to oscillate, whereas the predicted path that considers delay follows the reference path more closely.

However, as an answer to the question, there are no reasons other than conservative ones. The main concern is that the change could affect the validation functionality in the latter stages. Therefore, I am proposing a configuration that allows for visualization for comparison purposes.

Do you think we should adopt a path that considers input_delay as the official predicted path?

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, the control_validator and lane_departure_checker which depend on the predicted path are not used so much, so I think we do not have to be sensitive to that. This is not my strong opinion, but I feel that changing sooner is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@takayuki5168
How about adopting the predicted path that considers input delay as the official version, while keeping an option to revert to the original predicted path just in case? I've done some light verification on my end by changing vehicle parameters and trying several rosbags, and it seems fine, but it's better to be prepared.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@takayuki5168
addressed in c10f9fd

Comment on lines 117 to 120
auto predicted_trajectory_frenet = calculatePredictedTrajectory(
mpc_matrix, x0, Uex, mpc_resampled_ref_trajectory, prediction_dt, "frenet");
predicted_trajectory_frenet.header.stamp = m_clock->now();
predicted_trajectory_frenet.header.frame_id = "map";
m_debug_frenet_predicted_trajectory_pub->publish(predicted_trajectory_frenet);
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like considering the input delay will have more accuracy. Any reason not to consider the input delay here?

@kyoichi-sugahara kyoichi-sugahara force-pushed the feat/add_predicted_trajectory_with_delay branch from 09b2739 to c10f9fd Compare August 15, 2024 04:40
@kyoichi-sugahara kyoichi-sugahara added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Aug 15, 2024
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.

Project coverage is 24.95%. Comparing base (301e36b) to head (17a4b8a).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...ontrol/autoware_mpc_lateral_controller/src/mpc.cpp 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8436      +/-   ##
==========================================
- Coverage   25.02%   24.95%   -0.08%     
==========================================
  Files        1322     1325       +3     
  Lines       98047    98438     +391     
  Branches    37795    37896     +101     
==========================================
+ Hits        24536    24562      +26     
- Misses      71020    71382     +362     
- Partials     2491     2494       +3     
Flag Coverage Δ *Carryforward flag
differential 33.87% <90.47%> (?)
total 25.02% <ø> (+<0.01%) ⬆️ Carriedforward from 301e36b

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

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

@kyoichi-sugahara kyoichi-sugahara force-pushed the feat/add_predicted_trajectory_with_delay branch from c10f9fd to 7386c3c Compare August 16, 2024 13:25
@kyoichi-sugahara kyoichi-sugahara marked this pull request as draft September 2, 2024 08:55
@kyoichi-sugahara kyoichi-sugahara force-pushed the feat/add_predicted_trajectory_with_delay branch 3 times, most recently from f021f03 to febc057 Compare September 2, 2024 09:27
kyoichi-sugahara and others added 9 commits September 6, 2024 11:18
The code changes add a new publisher for the debug predicted trajectory with delay.

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
…ajectories and small refactoring

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
…autowarefoundation#8497)

Signed-off-by: Ryohsuke Mitsudome <ryohsuke.mitsudome@tier4.jp>
Co-authored-by: Yi-Hsiang Fang (Vivid) <146902905+vividf@users.noreply.github.com>
…th in README (autowarefoundation#8496)

Signed-off-by: Ryohsuke Mitsudome <ryohsuke.mitsudome@tier4.jp>
Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
…ajectories

This commit enables the debug publishing of predicted trajectory and resampled reference trajectory for debugging purposes. It also includes small refactoring changes.

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
Signed-off-by: Kyoichi Sugahara <kyoichi.sugahara@tier4.jp>
@kyoichi-sugahara kyoichi-sugahara force-pushed the feat/add_predicted_trajectory_with_delay branch from 272ba06 to 17a4b8a Compare September 6, 2024 02:20
@kyoichi-sugahara kyoichi-sugahara marked this pull request as ready for review September 6, 2024 06:10
@kyoichi-sugahara kyoichi-sugahara merged commit 67d9b8e into autowarefoundation:main Sep 6, 2024
33 of 34 checks passed
@kyoichi-sugahara kyoichi-sugahara deleted the feat/add_predicted_trajectory_with_delay branch September 6, 2024 06:45
emuemuJP pushed a commit to arayabrain/autoware.universe.origin that referenced this pull request Sep 10, 2024
…ts for input delay (autowarefoundation#8436)

* feat: enable delayed initial state for predicted trajectory

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

* feat: enable debug publishing of predicted and resampled reference trajectories

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

---------

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>
Signed-off-by: emuemuJP <k.matsumoto.0807@gmail.com>
kyoichi-sugahara added a commit to tier4/autoware.universe that referenced this pull request Dec 19, 2024
…ts for input delay (autowarefoundation#8436)

* feat: enable delayed initial state for predicted trajectory

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>


* feat: enable debug publishing of predicted and resampled reference trajectories

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@tier4.jp>

---------

Signed-off-by: kyoichi-sugahara <kyoichi.sugahara@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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants