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

populate the covariance fields using the noise models #333

Merged
merged 5 commits into from
Aug 23, 2023

Conversation

ejalaa12
Copy link
Contributor

🎉 New feature

This PR fills the imu covariance field

Summary

This PR depends on this one: gazebosim/gz-msgs#333

The published imu message is missing the covariance fields for linear_acceleration, angular_velocity and orientation_covariance. Those can be very useful when bridging between gz and ros.

Note: a Pr on ros_gz to update the convertion to ros is coming

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

src/ImuSensor.cc Outdated Show resolved Hide resolved
@@ -255,6 +256,41 @@ bool ImuSensor::Update(const std::chrono::steady_clock::duration &_now)
frame->set_key("frame_id");
frame->add_value(this->FrameId());

// Populate covariance
for (int i = 0; i < 9; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

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

number 9 as a const ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a problem, but wouldn't that be less easy to read ?

const int matrix_3x3_size = 9;
for (int i = 0; i < matrix_3x3_size; ++i)
...

@azeey
Copy link
Contributor

azeey commented Apr 10, 2023

@ejalaa12 Have you had a chance to look at the PR reviews?

@ejalaa12
Copy link
Contributor Author

@ejalaa12 Have you had a chance to look at the PR reviews?

@azeey Sorry for the long time to answer, was busy on other projects.
I just accepted/answered to the review.

Btw, this branch is out-of-date. I could do a rebase on the most recent gz-sensors7 branch, if that is ok with you.

@azeey
Copy link
Contributor

azeey commented Apr 11, 2023

@ejalaa12 Have you had a chance to look at the PR reviews?

@azeey Sorry for the long time to answer, was busy on other projects. I just accepted/answered to the review.

No problem.

Btw, this branch is out-of-date. I could do a rebase on the most recent gz-sensors7 branch, if that is ok with you.

Since we do squash merged, you can just hit the "Update branch" button to merge from gz-sensors7. I don't recommend rebasing since it usually causes github comments to disappear from the context of their files after the rebase.

@ejalaa12
Copy link
Contributor Author

Awesome !
Just did the update branch :)

@azeey azeey added the needs upstream release Blocked by a release of an upstream library label Apr 11, 2023
@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 31, 2023
@ejalaa12
Copy link
Contributor Author

ejalaa12 commented Aug 4, 2023

@mjcarroll I'm thinking that since this PR was merged on main, how should we handler it here? Shall we target main also ? That might explain why the CI is not passing no?

@iche033
Copy link
Contributor

iche033 commented Aug 7, 2023

yes can you retarget the changes to main, thanks.

@ejalaa12 ejalaa12 changed the base branch from gz-sensors7 to main August 9, 2023 07:40
@ejalaa12
Copy link
Contributor Author

ejalaa12 commented Aug 9, 2023

We did two merge of gz-sensors7 into this PR, which introduce some commits that are not on main yet.
I can clean this up by rebasing only my changes onto main and then doing a force-push if that's ok for you @iche033

@ejalaa12 ejalaa12 force-pushed the gz-sensors7 branch 2 times, most recently from 9824009 to c99f13d Compare August 9, 2023 08:01
@ejalaa12
Copy link
Contributor Author

ejalaa12 commented Aug 9, 2023

I tried just removing the latest branch merge.
Now the DCO is failing because one of the previous merge-commit does not contain a 'sign-off' message.
I'll wait for your confirmation on which method you prefer (rebase only relevant commis on top of main VS leaving it as it is)

@azeey
Copy link
Contributor

azeey commented Aug 9, 2023

I think doing git rebase --signoff main (assuming main is up-to-date) would help.

ejalaa12 and others added 2 commits August 10, 2023 13:02
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alaa El Jawad <[email protected]>
@ejalaa12
Copy link
Contributor Author

@azeey thanks, I know that you preferred to avoid rebasing so that's why I was waiting for this :).
Done !

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

looks good to me! Just some minor comments.

src/ImuSensor.cc Outdated Show resolved Hide resolved
src/ImuSensor.cc Show resolved Hide resolved
Signed-off-by: Alaa El Jawad <[email protected]>
@ejalaa12
Copy link
Contributor Author

@iche033 thanks for the feedback, I just addressed them in my last commit

src/ImuSensor.cc Outdated
return static_cast<float>(gaussian->StdDev() * gaussian->StdDev());
}
}
return 0.001f;
Copy link
Contributor

Choose a reason for hiding this comment

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

is 0.001f a good default value to return? or 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's good question. I'm not entirely sure here.
According to ros imu message definition:

  • if the covariance is known it should be filled in
  • if the covariance is unknown we should set it to 0
  • if we're missing an estimate for one of those values, we should set it to -1.

In this case, I guess 0 is a good default, that is if we want to follow ros conventions in gz-sensors as well.

Copy link
Contributor

@iche033 iche033 Aug 16, 2023

Choose a reason for hiding this comment

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

ok let's keep it consistent with ROS and set it to 0 here. Can you also do that for the orientation_covariance below?

Copy link
Contributor

Choose a reason for hiding this comment

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

Friendly ping @ejalaa12, I would like to get this in for Harmonic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey sorry for the late reply.
I just updated the PR and set the default to 0.
Concerning the orientation_covariance, setting it 0. It is important to note that this implies (according ros convention) the noise is always unknown, while in fact, we are just not applying any.
This is fine for robot_localization for example (a small offset will be added), but I wonder what this will do for other localization nodes... Thankfully, this will not break anything as the behavior would be unchanged with this PR :)

On a different tangent, should we consider applying noise to the orientation values (probably a separate PR). That would mean addind a new SensorNoiseType

Copy link
Contributor

Choose a reason for hiding this comment

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

Noising up orientation can be tricky as an IMU isn't really directly measuring that, but instead running it through some sort of filter. You end up with things that aren't linear and uncorrelated in a tidy way. I think we can open a ticket to follow up on that though, if you would like.

@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Merging #333 (996893c) into main (83f0e1f) will increase coverage by 0.11%.
The diff coverage is 100.00%.

❗ Current head 996893c differs from pull request most recent head de0e49b. Consider uploading reports for the commit de0e49b to get more accurate results

@@            Coverage Diff             @@
##             main     #333      +/-   ##
==========================================
+ Coverage   72.62%   72.74%   +0.11%     
==========================================
  Files          36       36              
  Lines        4947     4968      +21     
==========================================
+ Hits         3593     3614      +21     
  Misses       1354     1354              
Files Changed Coverage Δ
src/ImuSensor.cc 86.84% <100.00%> (+1.63%) ⬆️

@mjcarroll mjcarroll merged commit 67e0dea into gazebosim:main Aug 23, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🌱 garden Ignition Garden needs upstream release Blocked by a release of an upstream library
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants