Skip to content

fix(app): add autoware module (imu_corrector)#687

Open
nokosaaan wants to merge 19 commits into
mainfrom
imu_corrector
Open

fix(app): add autoware module (imu_corrector)#687
nokosaaan wants to merge 19 commits into
mainfrom
imu_corrector

Conversation

@nokosaaan
Copy link
Copy Markdown
Contributor

@nokosaaan nokosaaan commented Apr 27, 2026

Description

I added the imu_corrector module.
Basically, I added it in the same format as imu_driver and vehicle_velocity_converter, but since I could only find test code for gyro_bias_estimator and not for imu_corrector_core, I added tests to verify the correctness of the input and output as a substitute, similar to imu_driver.

Related links

https://github.com/autowarefoundation/autoware_universe/tree/main/sensing/autoware_imu_corrector/src

How was this PR tested?

You should add the path to the Cargo.toml file you want to unit test to the members section of the workspace in the root directory's Cargo.toml (at /awkernel/Cargo.toml)
imu_corrector.log

Notes for reviewers

Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
@nokosaaan nokosaaan changed the title Imu corrector fix(test): add teat_autoware module (imu_corrector) Apr 27, 2026
@nokosaaan nokosaaan requested a review from Copilot April 27, 2026 12:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new optional test_autoware test application to the userland runtime and introduces Autoware-related test crates (including an imu_corrector implementation and unit tests) under applications/tests/test_autoware.

Changes:

  • Wire a new test_autoware feature into userland and call test_autoware::run() when enabled.
  • Add a new applications/tests/test_autoware crate plus subcrates for imu_driver, imu_corrector, and vehicle_velocity_converter.
  • Implement unit-test-style validation for message conversions / corrections in the new subcrates.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
userland/src/lib.rs Adds feature-gated call to test_autoware::run() from the main runtime entrypoint.
userland/Cargo.toml Adds optional dependency + feature flag for test_autoware.
applications/tests/test_autoware/src/lib.rs Introduces test_autoware crate entrypoint (run()), currently empty.
applications/tests/test_autoware/Cargo.toml Defines the test_autoware crate dependencies (currently missing imu_corrector).
applications/tests/test_autoware/imu_driver/src/lib.rs Adds imu_driver parsing/generation logic plus unit tests.
applications/tests/test_autoware/imu_driver/Cargo.toml Declares the imu_driver crate.
applications/tests/test_autoware/imu_corrector/src/lib.rs Adds imu_corrector logic (bias/covariance/TF handling) plus unit tests.
applications/tests/test_autoware/imu_corrector/Cargo.toml Declares the imu_corrector crate and its dependencies.
applications/tests/test_autoware/vehicle_velocity_converter/src/lib.rs Adds vehicle_velocity_converter conversion + covariance logic plus unit tests.
applications/tests/test_autoware/vehicle_velocity_converter/Cargo.toml Declares the vehicle_velocity_converter crate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread applications/tests/test_autoware/imu_corrector/src/lib.rs Outdated
Comment thread applications/tests/test_autoware/imu_corrector/Cargo.toml Outdated
Comment thread applications/autoware/Cargo.toml
Comment thread applications/autoware/src/lib.rs
Comment thread applications/tests/test_autoware/imu_corrector/src/lib.rs Outdated
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/tier4/awkernel_sync/commits/HEAD
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/ytakano/acpi/commits/HEAD
    • Triggering command: /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo test -p imu_corrector (http block)

If you need me to access, download, or install something from one of these locations, you can either:

nokosaaan and others added 2 commits April 27, 2026 22:03
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nokosaaan nokosaaan marked this pull request as ready for review April 27, 2026 13:08
@nokosaaan nokosaaan requested a review from kobayu858 April 27, 2026 13:08
nokosaaan added 3 commits May 11, 2026 09:56
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
@kobayu858
Copy link
Copy Markdown
Contributor

This PR will be reviewed after #681 is merged.

@kobayu858 kobayu858 marked this pull request as draft May 15, 2026 07:42
…rector

Co-authored-by: Copilot <copilot@github.com>
@nokosaaan nokosaaan changed the title fix(test): add teat_autoware module (imu_corrector) fix(app): add autoware module (imu_corrector) May 20, 2026
@nokosaaan nokosaaan marked this pull request as ready for review May 20, 2026 05:26
Comment thread applications/autoware/imu_corrector/src/lib.rs
Comment thread applications/autoware/imu_driver/src/lib.rs Outdated
Comment thread applications/autoware/imu_corrector/Cargo.toml Outdated
@@ -0,0 +1,488 @@
// Ported from the following versions of the original C++ code:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

correct_for_dynamic_bias and correct_for_scale are not implemented in this port.

Since these are present in the original C++ implementation, could you add a comment in ImuCorrectorConfig explaining why they are omitted and marking them as TODO for future support?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I fixed it and added TODO comment.

Comment thread applications/autoware/imu_corrector/src/lib.rs
pub fn to_imu_msg(&self) -> ImuMsg {
ImuMsg {
header: self.header.clone(),
orientation: self.orientation.clone(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In ImuWithCovariance::from_imu_msg, the orientation from the original IMU message is copied as-is:

orientation: imu_msg.orientation.clone(),

However, the original C++ implementation intentionally does not copy orientation into the output message after the frame transform:

sensor_msgs::msg::Imu imu_msg_base_link;
imu_msg_base_link.linear_acceleration = transform_vector3(...);
imu_msg_base_link.angular_velocity = transform_vector3(...);
// ← no assignment to orientation

Please add a comment explaining why you chose this setting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If orientation isn't being used in the first place, wouldn't it make sense to just remove it? Is there a clear reason to keep it around? Either way, I don't think the current code will ever actually be used as-is in the future. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I included the orientation field in the ros_bag used for evaluation because it contained that data, and I assumed that if there was an input, that value would naturally be included in the output. However, as you pointed out, orientation is not actually included in the actual processing, so I plan to remove it as a member of the struct.

Comment thread applications/autoware/imu_corrector/src/lib.rs
Comment thread applications/autoware/imu_corrector/src/lib.rs Outdated
Comment thread applications/autoware/imu_corrector/src/lib.rs Outdated
nokosaaan added 2 commits May 21, 2026 02:30
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
nokosaaan added 6 commits May 21, 2026 20:28
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
Signed-off-by: nokosaaan <nishimura.r.019@ms.saitama-u.ac.jp>
}
}

fn to_nalgebra_vector3(&self, vec: &Vector3) -> NVector3<f64> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

to_nalgebra_vector3, to_imu_vector3, and to_nalgebra_quaternion all perform pure type conversions without using any fields of self, so there is no need for them to be &self instance methods.
Additionally, identical implementations exist in ImuCorrector, creating a risk of the two diverging if only one is updated in the future.
Please consider refactoring — for example, by extracting these as free functions or implementing the standard From/Into traits.

}

impl MockTransformListener {
pub fn new() -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add an implementation for the Default trait.

}

impl ImuCorrector<MockTransformListener> {
pub fn new() -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add an implementation for the Default trait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants