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_pose_covariance_modifier): add new node to early fuse gnss and ndt poses #6570

Conversation

meliketanrikulu
Copy link
Contributor

@meliketanrikulu meliketanrikulu commented Mar 7, 2024

Description

Closes:

Related discussion:

This PR was created to use NDT and GNSS together in localization. In order for EKF to work properly, the covariance values of the given inputs must be provided correctly as input. In Default AW, NDT covariance values are provided with default values. GNSS, on the other hand, provides its own error in a healthy way.

This PR also suggests that we drive with reference to the trusted source (GNSS), which can reliably calculate the error. It aims to drive with GNSS alone when the GNSS error is low, to use NDT-GNSS together when the GNSS error increases, and to use only NDT alone when the GNSS error goes beyond acceptable limits.

Without this package

Only NDT pose is used in localization. GNSS pose is only used for initialization.

graph TD
    ndt_scan_matcher["ndt_scan_matcher"] --> |"/localization/pose_estimator/pose_with_covariance"| ekf_localizer["ekf_localizer"]

classDef cl_node fill:#FFF2CC,stroke-width:3px,stroke:#D6B656;

class ndt_scan_matcher cl_node;
class ekf_localizer cl_node;
Loading

With this package

Both NDT and GNSS poses are used in localization, depending on the standard deviation values coming from the GNSS
system.

Here is a flowchart depicting the process and the predefined thresholds:

graph TD
    gnss_poser["gnss_poser"] --> |"/sensing/gnss/\npose_with_covariance"| pose_covariance_modifier_node
    ndt_scan_matcher["ndt_scan_matcher"] --> |"/localization/pose_estimator/ndt_scan_matcher/\npose_with_covariance"| pose_covariance_modifier_node

    subgraph pose_covariance_modifier_node ["Pose Covariance Modifier Node"]
        pc1{{"gnss_pose_yaw\nstddev"}}
        pc1 -->|"<= 0.3 rad"| pc2{{"gnss_pose_z\nstddev"}}
        pc2 -->|"<= 0.1 m"| pc3{{"gnss_pose_xy\nstddev"}}
        pc2 -->|"> 0.1 m"| ndt_pose("NDT Pose")
        pc3 -->|"<= 0.1 m"| gnss_pose("GNSS Pose")
        pc3 -->|"0.1 m < x <= 0.2 m"| gnss_ndt_pose("`Both GNSS and NDT Pose
        (_with modified covariance_)`")
        pc3 -->|"> 0.2 m"| ndt_pose
        pc1 -->|"> 0.3 rad"| ndt_pose
    end

    pose_covariance_modifier_node -->|"/localization/pose_estimator/pose_with_covariance"| ekf_localizer["ekf_localizer"]

classDef cl_node fill:#FFF2CC,stroke-width:3px,stroke:#D6B656;
classDef cl_conditional fill:#FFE6CC,stroke-width:3px,stroke:#D79B00;
classDef cl_output fill:#D5E8D4,stroke-width:3px,stroke:#82B366;

class gnss_poser cl_node;
class ndt_scan_matcher cl_node;
class ekf_localizer cl_node;
class pose_covariance_modifier_node cl_node;

class pc1 cl_conditional;
class pc2 cl_conditional;
class pc3 cl_conditional;

class ndt_pose cl_output;
class gnss_pose cl_output;
class gnss_ndt_pose cl_output;
Loading

How and when are the NDT covariance values overwritten?

Mode Outputs, Covariance
GNSS Only GNSS, Unmodified
GNSS + NDT GNSS: Unmodified, NDT: Interpolated
NDT Only NDT, Unmodified

NDT covariance values overwritten only for the GNSS + NDT mode.

This enables a smooth transition between GNSS Only and NDT Only modes.

In this mode, both NDT and GNSS poses are published from this node.

Assumptions

  • Incoming NDT poses have a fixed covariance value.
  • Covariance provided by GNSS is reliable.

NDT covariance calculation

Goal
  • As the gnss_std_dev increases within its bounds, ndt_std_dev should proportionally decrease within its own bounds.

To achieve this, we first linearly interpolate:

  • Base value: gnss_std_dev

  • Base range: [threshold_gnss_stddev_xy_bound_lower, threshold_gnss_stddev_xy_bound_upper]

  • Target range: [ndt_std_dev_bound_lower, ndt_std_dev_bound_upper]

  • Target value: ndt_std_dev_target

  • Final value = ndt_std_dev_bound_lower + ndt_std_dev_bound_upper - ndt_std_dev_target (to get the inverse)

Illustration

range to range lerp animation

Tests performed

The testing steps are shown in the video below:

Installation

  1. Download and unpack a test map files.
  • You can also download the map manually.
gdown --id 1Xx4H6qou_Z764_vXpQTYsh6gio4aOJ8C -O ~/autoware_data/  
unzip -d ~/autoware_data/ ~/autoware_data/autoware_map.zip
  • You can install this map for testing challenging environments for NDT.
  1. Download the test rosbag files.
gdown --id 1E88tbUZcpVKzoQOOiQ7Jvcsx-IcgrS4H -O ~/autoware_data/  
unzip -d ~/autoware_data/ ~/autoware_data/rosbag2_2024_04_17-18_36_41.zip

Prepare Autoware to test PR:

  1. Checkout autoware.universe :
cd ~/autoware/src/universe/autoware.universe/
git remote add autoware.universe https://github.com/meliketanrikulu/autoware.universe.git
git remote update
git checkout feat/add_autoware_pose_covariance_modifier_node
  1. Checkout autoware_launch (Added only to test PR. Not required for PR to work):
cd ~/autoware/src/launcher/autoware_launch/
git remote add autoware_launch https://github.com/meliketanrikulu/autoware_launch.git
git remote update
git checkout pr_test-6570
  1. Compile new package:
cd ~/autoware
colcon build --symlink-install --packages-select autoware_pose_covariance_modifier_node autoware_launch

Parameter settings:

  1. Set use_autoware_pose_covariance_modifier param to true.
    <arg name="use_autoware_pose_covariance_modifier" default="true"/>
  1. Set enable_debug_topics parameter to true.
  enable_debug_topics: true

Launch Autoware:

  1. Run autoware :
source ~/autoware/install/setup.bash
ros2 launch autoware_launch autoware_pose_cov_modifier_logging_simulator.launch.xml map_path:=$HOME/autoware_data/autoware_map
  1. Run bag file.
source ~/autoware/install/setup.bash 

# Run this to observe results for all data
ros2 bag play ~/autoware_data/rosbag2_2024_04_17-18_36_41/rosbag2_2024_04_17-18_36_41_0.db3 

# If you want to observe switch moments between NDT and GNSS run this
ros2 bag play ~/autoware_data/rosbag2_2024_04_17-18_36_41/rosbag2_2024_04_17-18_36_41_0.db3  --start-offset 300

Check Out The Results:

Test Video

Note

Explanations for the video:

  • Test environments: In the video, PR is tested in two different environments. One of these is the environment where NDT does not work well. The other is the environment where GNSS does not work well.
  • What do we want to see: We see that the default autoware begins to break down in an environment where NDT does not work well. However, since driving is done with GNSS when using PR, it is possible to drive easily in these environments. Likewise, when the GNSS error increases in the second environment, driving is switched to NDT, so it does not cause any disruption in the current system.
  • Ground Truth: In this video, the output of the GNSS/INS sensor and its error in x,y,z are visualized. It can be considered ground truth in places where the error is low.

Check Out Debug Topics

  • Follow up which poses are used as a pose source:
    ros2 topic echo /localization/autoware_pose_covariance_modifier/selected_pose_type
  • Follow up debug topics:
    ros2 topic echo /autoware_pose_covariance_modifier/output/gnss_position_stddev
    ros2 topic echo /autoware_pose_covariance_modifier/output/ndt_position_stddev
  • Instead of this you can follow up these values on plotjuggler screen .
    Below you can see the results when you start using ndt while using gnss:
    photoedit drawio

Notes for reviewers

Interface changes

Effects on system behavior

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.

  • The PR follows the pull request guidelines.
  • The PR has been properly tested.
  • The PR has been reviewed by the code owners.

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.
  • The PR is ready for merge.

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

@github-actions github-actions bot added type:documentation Creating or refining documentation. (auto-assigned) component:localization Vehicle's position determination in its environment. (auto-assigned) component:launch Launch files, scripts and initialization tools. (auto-assigned) labels Mar 7, 2024
@xmfcx xmfcx marked this pull request as draft March 7, 2024 16:49
@xmfcx xmfcx added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Mar 7, 2024
Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 90 lines in your changes are missing coverage. Please review.

Project coverage is 0.00%. Comparing base (b6d7477) to head (bf40cca).
Report is 2 commits behind head on main.

Files Patch % Lines
...variance_modifier/src/pose_covariance_modifier.cpp 0.00% 90 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #6570       +/-   ##
==========================================
- Coverage   15.41%   0.00%   -15.42%     
==========================================
  Files        1904       1     -1903     
  Lines      132758      90   -132668     
  Branches    42265       0    -42265     
==========================================
- Hits        20468       0    -20468     
+ Misses      89541      90    -89451     
+ Partials    22749       0    -22749     
Flag Coverage Δ
differential 0.00% <0.00%> (?)
total ?

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

@meliketanrikulu meliketanrikulu force-pushed the feat/add_autoware_pose_covariance_modifier_node branch 3 times, most recently from 0247d7b to 3e35850 Compare March 13, 2024 18:01
@meliketanrikulu meliketanrikulu marked this pull request as ready for review March 13, 2024 18:25
@meliketanrikulu meliketanrikulu force-pushed the feat/add_autoware_pose_covariance_modifier_node branch from 7641a96 to 3c75cff Compare March 13, 2024 18:39
@meliketanrikulu
Copy link
Contributor Author

Its ready for the review. Could you check. I would be happy if you give feedback.

@xmfcx
Copy link
Contributor

xmfcx commented Mar 13, 2024

@xmfcx xmfcx marked this pull request as draft March 13, 2024 18:46
@TaikiYamada4
Copy link
Contributor

@meliketanrikulu
Thank you for your contribution!
However, I want this package to follow the architecture written in the Autoware documents.
We want to keep this structure in shape, and I'm afraid to say that it is not acceptable for me to put a node between the ndt_scan_matcher (Pose Estimator) and ekf_localizer (Kinematics Fusion Filter). To say things short, I think it is rather better to create a new pose_estimator that realize your proposal.

I understand that plugging in a simple node between NDT and EKF is more efficient implementation-wise, but a bit of architecture change can grow to a chaos. So could you please try to create a node that fit this architecture?

@meliketanrikulu meliketanrikulu force-pushed the feat/add_autoware_pose_covariance_modifier_node branch 3 times, most recently from 73644b5 to bb868cc Compare March 14, 2024 10:26
M. Fatih Cırıt and others added 19 commits May 8, 2024 14:56
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: Melike Tanrıkulu <melike@leodrive.ai>
Signed-off-by: Melike Tanrıkulu <melike@leodrive.ai>
Signed-off-by: Melike Tanrıkulu <melike@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
@xmfcx xmfcx force-pushed the feat/add_autoware_pose_covariance_modifier_node branch from 9091768 to 2efbb92 Compare May 8, 2024 11:56
@xmfcx
Copy link
Contributor

xmfcx commented May 8, 2024

Rebased it to latest main. @TaikiYamada4 I've applied your suggestions.

#6570 (comment) See this for the final test results.

If you are fine with it, we can merge it.

@xmfcx xmfcx enabled auto-merge (squash) May 8, 2024 12:51
M. Fatih Cırıt and others added 2 commits May 8, 2024 21:08
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: Melike Tanrıkulu <melike@leodrive.ai>
@meliketanrikulu meliketanrikulu force-pushed the feat/add_autoware_pose_covariance_modifier_node branch from 36d17b6 to bf40cca Compare May 8, 2024 21:16
Copy link
Contributor

@TaikiYamada4 TaikiYamada4 left a comment

Choose a reason for hiding this comment

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

@meliketanrikulu @xmfcx
Thank you for accommodating my revision requests for so long!
Looks good to me!

@xmfcx xmfcx merged commit baeeab5 into autowarefoundation:main May 9, 2024
26 of 28 checks passed
vividf pushed a commit to vividf/autoware.universe that referenced this pull request May 16, 2024
…nss and ndt poses (autowarefoundation#6570)

Signed-off-by: Melike Tanrıkulu <melike@leodrive.ai>
Co-authored-by: M. Fatih Cırıt <mfc@leodrive.ai>
Signed-off-by: vividf <yihsiang.fang@tier4.jp>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request Jun 3, 2024
…nss and ndt poses (autowarefoundation#6570)

Signed-off-by: Melike Tanrıkulu <melike@leodrive.ai>
Co-authored-by: M. Fatih Cırıt <mfc@leodrive.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:launch Launch files, scripts and initialization tools. (auto-assigned) component:localization Vehicle's position determination in its environment. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) tag:pr-agent Mark to enable PR-Agent for automated reviews. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned)
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants