Skip to content

Feature: Add noise to Localization, Velocity status and IMU #1577

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

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

TauTheLepton
Copy link
Contributor

@TauTheLepton TauTheLepton commented Apr 15, 2025

Description

Abstract

This pull request aims to add noise to the topics:

  • /vehicle/status/velocity_status
  • /sensing/imu/imu_data
  • /localization/pose_estimator/pose_with_covariance

Note

This pull request may seem to be big, but the majority of the PR are tests and appending the parameters file.
For details on what part of this PR is not changing any functionality or actual simulator code, please see the table below.

What How many lines changed
Normal distribution tests +358
IMU sensor tests +510
Parameters file +191
SUM +1059

Background

Details

Publisher noise framework refactoring

The concealer noise framework has been slightly refactored in order to make it easier to implement additional randomizers.

The struct Error defined in NormalDistribution<nav_msgs::msg::Odometry> has been moved outside the NormalDistribution<nav_msgs::msg::Odometry> and renamed to NormalDistributionError, so that it could be used in other NormalDistribution specializations.
It has also been converted to template so that other real types supported by std::normal_distribution could be used.

Additionally, a member active has been added, so that the randomization of data could be turned off (this is opt-in, default is always active).

NormalDistributionBase base struct has been implemented in order to provide common functionality for all normal NormalDistribution specializations. It provides seed and engine members and a constructor that initializes them. The seed is obtained from the appropriate seed ROS parameter, and engine is initialized using the seed.

Thanks to the NormalDistributionBase, NormalDistribution specializations only have to define what randomization errors they contain, how they are initialized and how they are applied.

What is more, the Publisher::randomize member has been declared mutable, because its internal state changes (the random number generator engine) and this should not block developers from creating const Publishers.

Concealer noise

The NormalDistribution<nav_msgs::msg::Odometry> has been adjusted to the changes mentioned above.

The noise adding framework from concealer::Publisher has been used implementing additional concealer noise, that is noise applied to topics

  • /vehicle/status/velocity_status
  • /localization/pose_estimator/pose_with_covariance

For this reason, the NormalDistribution<autoware_vehicle_msgs::msg::VelocityReport> and NormalDistribution<geometry_msgs::msg::PoseWithCovarianceStamped> have been implemented and used in AutowareUniverse class.

Additionally, the unit tests for new NormalDistribution specializations have been implemented.

Simple sensor simulator noise

Noise adding framework from concealer::Publisher has been used implementing simple sensor simulator noise, that is the noise applied to topic

  • /sensing/imu/imu_data

Applying noise to this topic has been slightly more complicated, because the sensor already had some noise implementation.
The older noise implementation is incompatible with the normal distribution noise framework fromconcealer::Publisher.
For this reason, and the fact we want to keep the simulator backward compatible - the new noise adding method has been added "on top" of the old implementation with a switch enabling to choose which implementation should be used.

This means the original implementation is used by default and only when user specifies the parameter /sensing/imu/imu_data.override_legacy_configuration to be true the legacy method is switched off and the new method is switched on (part of this process involves calculating new covariance matrices, because they depend on the new noise parameters).

Additionally, unit tests (testing only the noise application correctness) for ImuSensor with both noise configurations (legacy and new) have been implemented.

Parameters

Finally, all parameters used for implemented noise have been listed in the scenario test runner parameters file.

References

INTERNAL LINK
No regressions confirmed

Destructive Changes

None

Known Limitations

None

…ionError and make it a template to accept multiple floating point types

Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
The previous noise mechanism is not in use

This required accessing Publisher::randomize to obtain normal distribution error standard deviations

Signed-off-by: Mateusz Palczuk <[email protected]>
Test applying noise using legacy parameters - simulation_api_schema

Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
@TauTheLepton TauTheLepton self-assigned this Apr 15, 2025
Copy link

Checklist for reviewers ☑️

All references to "You" in the following text refer to the code reviewer.

  • Is this pull request written in a way that is easy to read from a third-party perspective?
  • Is there sufficient information (background, purpose, specification, algorithm description, list of disruptive changes, and migration guide) in the description of this pull request?
  • If this pull request contains a destructive change, does this pull request contain the migration guide?
  • Labels of this pull request are valid?
  • All unit tests/integration tests are included in this pull request? If you think adding test cases is unnecessary, please describe why and cross out this line.
  • The documentation for this pull request is enough? If you think adding documents for this pull request is unnecessary, please describe why and cross out this line.

Signed-off-by: Mateusz Palczuk <[email protected]>
@TauTheLepton TauTheLepton added feature New feature or request waiting for CI bump minor If this pull request merged, bump minor version of the scenario_simulator_v2 labels Apr 16, 2025
@TauTheLepton TauTheLepton changed the title Feature: Publisher Noise Feature: Add noise to Localization, Velocity status and IMU Apr 16, 2025
@TauTheLepton
Copy link
Contributor Author

No regressions confirmed here.

Copy link

Failure optional scenarios

Note

This is an experimental check and does not block merging the pull-request.
But, please be aware that this may indicate a regression.

scenario failed: execution_time_test
      <failure type="SimulationFailure" message="CustomCommandAction typed &quot;exitFailure&quot; was triggered by the named Conditions {&quot;update time checker&quot;, &quot;avoid startup&quot;}: {&quot;update time checker&quot;: Is the /simulation/interpreter/execution_time/update (= 0.005168999999999999983568699236) is greaterThan 0.005?}, {&quot;avoid startup&quot;: Is the simulation time (= 9.449999999999999289457264239900) is greaterThan 1.000000000000000000000000000000?}" />

Skip the randomization process altogether instead of disabling all errors and performing other operations that achieve nothing

Signed-off-by: Mateusz Palczuk <[email protected]>
… non-mutable

Adjust ImuSensor + ImuSensorBase update member functions to non-const - similar to other sensors

Signed-off-by: Mateusz Palczuk <[email protected]>
@TauTheLepton
Copy link
Contributor Author

@yamacir-kit

I have applied the changes requested.

While doing this, I have realized that the deactivation of IMU sensor randomization - when legacy configuration is used - is done inefficiently, so I have improved this by skipping the whole randomization altogether.

For details, please see the commit dce11aa.

Copy link

Failure optional scenarios

Note

This is an experimental check and does not block merging the pull-request.
But, please be aware that this may indicate a regression.

scenario failed: execution_time_test
      <failure type="SimulationFailure" message="CustomCommandAction typed &quot;exitFailure&quot; was triggered by the named Conditions {&quot;update time checker&quot;, &quot;avoid startup&quot;}: {&quot;update time checker&quot;: Is the /simulation/interpreter/execution_time/update (= 0.007413000000000000318245430009) is greaterThan 0.005?}, {&quot;avoid startup&quot;: Is the simulation time (= 12.300000000000039790393202565610) is greaterThan 1.000000000000000000000000000000?}" />

TauTheLepton and others added 4 commits May 27, 2025 16:28
Ensure variances (diagonal) are not 0.0, or otherwise Autoware localization gets confused (only when simulate_localization:=false)

Signed-off-by: Mateusz Palczuk <[email protected]>
This reverts commit c729976.

Signed-off-by: Mateusz Palczuk <[email protected]>
…in legacy configuration

This was done so that covariance matrices are calculated to be non-zero (their diagonal). Otherwise the Autoware gets confused and Ego starts shaking in RViz.

Signed-off-by: Mateusz Palczuk <[email protected]>
@TauTheLepton
Copy link
Contributor Author

TauTheLepton commented Jun 9, 2025

@yamacir-kit
I have changed the default new IMU noise values to match the default legacy IMU noise values.
I have performed regression tests with no regressions confirmed (one regression detected automatically, and the same scenario passed locally).

@TauTheLepton TauTheLepton requested a review from yamacir-kit June 9, 2025 09:12
@TauTheLepton TauTheLepton force-pushed the feature/publisher-noise branch from fa7b459 to c3fc045 Compare June 16, 2025 09:38
@TauTheLepton TauTheLepton force-pushed the feature/publisher-noise branch from c3fc045 to 2d3fb38 Compare June 16, 2025 09:38
@TauTheLepton
Copy link
Contributor Author

No regressions confirmed here

Copy link

Failure optional scenarios

Note

This is an experimental check and does not block merging the pull-request.
But, please be aware that this may indicate a regression.

scenario failed: execution_time_test
      <failure type="SimulationFailure" message="CustomCommandAction typed &quot;exitFailure&quot; was triggered by the named Conditions {&quot;update time checker&quot;, &quot;avoid startup&quot;}: {&quot;update time checker&quot;: Is the /simulation/interpreter/execution_time/update (= 0.005033000000000000147271084217) is greaterThan 0.005?}, {&quot;avoid startup&quot;: Is the simulation time (= 8.649999999999987920773492078297) is greaterThan 1.000000000000000000000000000000?}" />

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor If this pull request merged, bump minor version of the scenario_simulator_v2 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants