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

refactor(pid_longitudinal_controller): use common elevetation angle calculation #5090

Merged

Conversation

takayuki5168
Copy link
Contributor

@takayuki5168 takayuki5168 commented Sep 23, 2023

Description

use tier4_autoware_utils::calcElevationAngle instead of an internally defined function.

NOTE:
The sign of slope_angle will be opposite to the existing one.
This is because the sign of calcElevationAngle in pid_longitudinal_controller and tier4_autoware_utils are different due to how the dz is calculated. "calcElevationAngle in pid_longitudinal_controller" is wrong.

  • calcElevationAngle in pid_longitudinal_controller (wrong)
    double calcElevationAngle(const TrajectoryPoint & p_from, const TrajectoryPoint & p_to)
    {
    const double dx = p_from.pose.position.x - p_to.pose.position.x;
    const double dy = p_from.pose.position.y - p_to.pose.position.y;
    const double dz = p_from.pose.position.z - p_to.pose.position.z;
    const double dxy = std::max(std::hypot(dx, dy), std::numeric_limits<double>::epsilon());
    const double pitch = std::atan2(dz, dxy);
    return pitch;
    }
  • calcElevationAngle in tier4_autoware_utils (correct)
    double calcElevationAngle(
    const geometry_msgs::msg::Point & p_from, const geometry_msgs::msg::Point & p_to)
    {
    const double dz = p_to.z - p_from.z;
    const double dist_2d = calcDistance2d(p_from, p_to);
    return std::atan2(dz, dist_2d);
    }

The sign of acceleration calculated by slope_angle will not change. Therefore, the behavior of slope compensation will not change.
This is handled by the following change of this PR.
image

Tests performed

unit test
psim

Effects on system behavior

nothing

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.

After all checkboxes are checked, anyone who has write access can merge the PR.

…alculation

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
@github-actions github-actions bot added the component:control Vehicle control algorithms and mechanisms. (auto-assigned) label Sep 23, 2023
@takayuki5168 takayuki5168 marked this pull request as ready for review September 23, 2023 16:04
@takayuki5168 takayuki5168 added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Sep 23, 2023
@codecov
Copy link

codecov bot commented Sep 23, 2023

Codecov Report

Patch coverage: 71.42% and project coverage change: -0.02% ⚠️

Comparison is base (9402bb5) 15.77% compared to head (5271bfb) 15.76%.
Report is 102 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5090      +/-   ##
==========================================
- Coverage   15.77%   15.76%   -0.02%     
==========================================
  Files        1584     1584              
  Lines      109568   109542      -26     
  Branches    33728    33722       -6     
==========================================
- Hits        17286    17265      -21     
  Misses      73656    73656              
+ Partials    18626    18621       -5     
Flag Coverage Δ *Carryforward flag
differential 41.62% <71.42%> (?)
total 15.75% <ø> (-0.02%) ⬇️ Carriedforward from 2267824

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

Files Changed Coverage Δ
...dinal_controller/longitudinal_controller_utils.hpp 35.00% <ø> (ø)
...nal_controller/src/pid_longitudinal_controller.cpp 39.71% <0.00%> (ø)
...roller/test/test_longitudinal_controller_utils.cpp 51.20% <ø> (-1.75%) ⬇️
...l_controller/src/longitudinal_controller_utils.cpp 80.32% <83.33%> (-2.75%) ⬇️

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

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
Copy link
Contributor

@TakaHoribe TakaHoribe left a comment

Choose a reason for hiding this comment

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

LGTM.

Note: This includes the fix for the definition inconsistency of pitch_from_ego and pitch_from_trajectory.

@takayuki5168 takayuki5168 merged commit 7b1999a into autowarefoundation:main Sep 25, 2023
@takayuki5168 takayuki5168 deleted the chore/use-common-elevetaion-angle branch September 25, 2023 01:51
takayuki5168 added a commit to tier4/autoware.universe that referenced this pull request Sep 25, 2023
…alculation (autowarefoundation#5090)

* refactor(pid_longitudinal_controller): use common elevetation angle calculation

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

* update

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

---------

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
maxime-clem pushed a commit to maxime-clem/autoware.universe that referenced this pull request Oct 2, 2023
…alculation (autowarefoundation#5090)

* refactor(pid_longitudinal_controller): use common elevetation angle calculation

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

* update

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

---------

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants