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

fix(autoware_mpc_lateral_controller): fix calculation method of predicted trajectory #9048

Conversation

kyoichi-sugahara
Copy link
Contributor

@kyoichi-sugahara kyoichi-sugahara commented Oct 7, 2024

Description

fix calculation method of predicted trajectory.

As a premise, the MPC optimization result considers a first-order delay applied to the ideal steering angle calculated based on the path curvature.
The original method for calculating the predicted path was as follows:

  // update state in the world coordinate
  const auto updateState = [&](
                             const Eigen::VectorXd & state_w, const Eigen::MatrixXd & input,
                             const double dt, const double velocity) {
    const auto yaw = state_w(2);
    const auto steer = state_w(3);
    const auto desired_steer = input(0);

    Eigen::VectorXd dstate = Eigen::VectorXd::Zero(4);
    dstate(0) = velocity * std::cos(yaw);
    dstate(1) = velocity * std::sin(yaw);
    dstate(2) = velocity * std::tan(steer) / m_wheelbase;
    dstate(3) = -(steer - desired_steer) / m_steer_tau;

    // Note: don't do "return state_w + dstate * dt", which does not work due to the lazy evaluation
    // in Eigen.
    const Eigen::VectorXd next_state = state_w + dstate * dt;
    return next_state;
  };

It calculats the desired steering angle based on the MPC optimization result, and then computed the predicted steering angle at each time step. This approach inadvertently considered the first-order delay twice.
As a result, the following issue occurred:

image

the predicted path became unstable at low speeds.
In this PR, I confirmed that the problem was resolved by removing the term that considers the steering's first-order delay during the predicted path calculation.

image

Related links

Parent Issue:

  • Link

How was this PR tested?

Notes for reviewers

None.

Interface changes

None.

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

github-actions bot commented Oct 7, 2024

Thank you for contributing to the Autoware project!

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

Please ensure:

@kyoichi-sugahara kyoichi-sugahara added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Oct 7, 2024
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.67%. Comparing base (d4d40cd) to head (bac3f5b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9048      +/-   ##
==========================================
- Coverage   26.68%   26.67%   -0.01%     
==========================================
  Files        1296     1296              
  Lines       95679    95692      +13     
  Branches    39078    39081       +3     
==========================================
- Hits        25530    25527       -3     
- Misses      67494    67509      +15     
- Partials     2655     2656       +1     
Flag Coverage Δ *Carryforward flag
differential 33.11% <100.00%> (?)
total 26.67% <ø> (-0.01%) ⬇️ Carriedforward from d4d40cd

*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 merged commit c2438fd into autowarefoundation:main Oct 7, 2024
31 of 32 checks passed
@kyoichi-sugahara kyoichi-sugahara deleted the fix/calculate_predicted_trajectory branch October 7, 2024 13:08
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) tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants