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(imu_corrector): changed publication algorithm and content of /diagnostics in gyro_bias_estimator #6139

Conversation

TaikiYamada4
Copy link
Contributor

@TaikiYamada4 TaikiYamada4 commented Jan 22, 2024

Description

Change of publication algorithm

gyro_bias_estimator has been publishing /diagnostics topic through DiagnosticsUpdater.
However, there is also a publication of /diagnostics by force_update() in the timer_callback that makes extra publication.
In addition, this force_update() will be prevented if specific conditions match in timer_callback which leads to inconsistency on publication of /diagnostics.
To solve this problem, I implemented gyro_bias_estimator to publish /diagnostics only through DiagnosticsUpdater.
Plus, since the publication period set to the updater_ had been default (1.0 second), I revised it to be the same to the period of timer_callback.

Change of diagnostic content

I have modified the content of the diagnostic to satisfy the following.

  1. Removed key "gyro_bias" since it is a vague concept, and moved most of it to the message field of the /diagnostics.
  2. Keep the size of /diagnostics by setting the bias values as NaN when it is not initialized.
  3. Add key "is_updated" and "supplement" to inform whether the gyro bias is updated and why if not.

The rqt_runtime_monitor will be like this
Screenshot from 2024-01-29 15-03-24
Screenshot from 2024-01-29 15-03-16

Related links

None

Tests performed

I've test this code via rosbag replay simulation tutorial.

Notes for reviewers

I've just set the publication period of /diagnostics same to the timer callback period.
If this doesn't suit the purpose please tell me.

Interface changes

None

Effects on system behavior

  • /diagnostics from gyro_bias_estimator should be more periodical than before
  • The content of the /diagnostics will be changed as mentioned in Change of diagnostic content

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.

…utomatically.

Set the update peirod of diagnostics to be same to the timer_callback.
Changed words of the diagnostics message a bit.

Signed-off-by: TaikiYamada4 <[email protected]>
@TaikiYamada4 TaikiYamada4 added the component:localization Vehicle's position determination in its environment. (auto-assigned) label Jan 22, 2024
@TaikiYamada4 TaikiYamada4 self-assigned this Jan 22, 2024
@github-actions github-actions bot added component:sensing Data acquisition from sensors, drivers, preprocessing. (auto-assigned) and removed component:localization Vehicle's position determination in its environment. (auto-assigned) labels Jan 22, 2024
@SakodaShintaro
Copy link
Contributor

Thank you for the pull request!

(1) I think it would be good to be able to set separate values for the processing timer callback period and the diagnostics period.

(2) How about calculating the values output by the diagnostics in the timer callback and organizing them into a struct?

(3) I think it would be good if the summary statuses in the diagnostics clearly corresponded to the branches of the if statement in update_diagnostics.

(4) It would be good to execute force_update at the end of the process timer callback.

(5) Please ensure that is_bias_updated_ is not redundant by showing the exact same state as other variables, and consider removing it if it is.

TaikiYamada4 and others added 5 commits January 23, 2024 23:24
Let update_diagnostics to be simple.

Signed-off-by: TaikiYamada4 <[email protected]>
Signed-off-by: TaikiYamada4 <[email protected]>
…:TaikiYamada4/autoware.universe into feat/gyro_bias_estimator-periodical_diag

Signed-off-by: TaikiYamada4 <[email protected]>
@TaikiYamada4 TaikiYamada4 added the tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Jan 23, 2024
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

Attention: 45 lines in your changes are missing coverage. Please review.

Comparison is base (f9ed5b0) 14.58% compared to head (d34a6c9) 14.58%.
Report is 4 commits behind head on main.

Files Patch % Lines
sensing/imu_corrector/src/gyro_bias_estimator.cpp 0.00% 44 Missing ⚠️
sensing/imu_corrector/src/gyro_bias_estimator.hpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6139      +/-   ##
==========================================
- Coverage   14.58%   14.58%   -0.01%     
==========================================
  Files        1878     1879       +1     
  Lines      128023   128052      +29     
  Branches    37468    37468              
==========================================
  Hits        18673    18673              
- Misses      88376    88405      +29     
  Partials    20974    20974              
Flag Coverage Δ *Carryforward flag
differential 19.54% <0.00%> (?)
total 14.58% <ø> (+<0.01%) ⬆️ Carriedforward from f9ed5b0

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

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

TaikiYamada4 and others added 2 commits January 26, 2024 09:59
Then, there will be no duplicates of diagnostics.

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

Regarding to the reviewers feedbacks, I've made these additional changes.

  • Make the timer period and diagnostics period independent.
  • Make a struct diagnostics_info_ to put diagnostics information together. This makes the update_diagnostics function clear.
  • Added validate_gyro_bias() function since the timer_callback gets too long to read.
  • Removed is_updated_ and supplement_, and let all string information go to the summary to make things simple.

I believe this will satisfy the requirements. One minor problem is that update_diagnostics() function can be set to const in this case, however I cannot bind a const function by updater_.add("gyro_bias_validator", this, &GyroBiasEstimator::update_diagnostics); so it remains as a non -const function after all.


stat.add("estimated_gyro_bias_x", diagnostics_info_.estimated_gyro_bias_x);
stat.add("estimated_gyro_bias_y", diagnostics_info_.estimated_gyro_bias_y);
stat.add("estimated_gyro_bias_z", diagnostics_info_.estimated_gyro_bias_z);
Copy link
Contributor

Choose a reason for hiding this comment

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

To improve visibility when viewing with rqt_runtime_monitor, consider making the following two changes:

  • Use std::fixed
  • Display threshold value

For example, it looks like the following

void GyroBiasEstimator::update_diagnostics(diagnostic_updater::DiagnosticStatusWrapper & stat)
{
  auto f = [](const double & value) {
    std::stringstream ss;
    ss << std::fixed << value;
    return ss.str();
  };

  stat.summary(diagnostics_info_.level, diagnostics_info_.summary_message);
  stat.add("gyro_bias_x_for_imu_corrector", f(diagnostics_info_.gyro_bias_x_for_imu_corrector));
  stat.add("gyro_bias_y_for_imu_corrector", f(diagnostics_info_.gyro_bias_y_for_imu_corrector));
  stat.add("gyro_bias_z_for_imu_corrector", f(diagnostics_info_.gyro_bias_z_for_imu_corrector));

  stat.add("estimated_gyro_bias_x", f(diagnostics_info_.estimated_gyro_bias_x));
  stat.add("estimated_gyro_bias_y", f(diagnostics_info_.estimated_gyro_bias_y));
  stat.add("estimated_gyro_bias_z", f(diagnostics_info_.estimated_gyro_bias_z));

  stat.add("gyro_bias_threshold", f(gyro_bias_threshold_));
}

When I tried to keep it within the character limit, I ended up with a very short function name :(

If you have any opposing opinions, please let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the comment!
I followed your recommendation and add the following commit. 👍

@SakodaShintaro SakodaShintaro self-requested a review January 29, 2024 01:38
Copy link
Contributor

@SakodaShintaro SakodaShintaro 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

@github-actions github-actions bot added the type:documentation Creating or refining documentation. (auto-assigned) label Jan 29, 2024
@TaikiYamada4 TaikiYamada4 enabled auto-merge (squash) January 29, 2024 07:21
@TaikiYamada4 TaikiYamada4 merged commit 2f761e1 into autowarefoundation:main Jan 29, 2024
20 of 25 checks passed
kyoichi-sugahara pushed a commit to kyoichi-sugahara/autoware.universe that referenced this pull request Jan 29, 2024
…agnostics in gyro_bias_estimator (autowarefoundation#6139)

* Let diagnostics be updated even if expections occur in timer_callback

Signed-off-by: TaikiYamada4 <[email protected]>

* Fixed the summary message to be "Not updated" when the gyro bias is not updated.
Fixed typo.

Signed-off-by: TaikiYamada4 <[email protected]>

* Removed force_update() since updater_ originaly updates diagnostics automatically.
Set the update peirod of diagnostics to be same to the timer_callback.
Changed words of the diagnostics message a bit.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Let the period of diagnostics publication independent to timer.
Let update_diagnostics to be simple.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Fixed typo

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Added setPeriod after force_update to reset the timer of updater_.
Then, there will be no duplicates of diagnostics.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Set diagnostics values to have the same precision
Added gyro_bias_threshold_ to the diagnostics

Signed-off-by: TaikiYamada4 <[email protected]>

* Updated README.md to match the paramters in gyro_bias_estimator

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

---------

Signed-off-by: TaikiYamada4 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@TaikiYamada4 TaikiYamada4 deleted the feat/gyro_bias_estimator-periodical_diag branch January 30, 2024 01:10
TaikiYamada4 added a commit to tier4/autoware.universe that referenced this pull request Jan 30, 2024
…agnostics in gyro_bias_estimator (autowarefoundation#6139)

* Let diagnostics be updated even if expections occur in timer_callback

Signed-off-by: TaikiYamada4 <[email protected]>

* Fixed the summary message to be "Not updated" when the gyro bias is not updated.
Fixed typo.

Signed-off-by: TaikiYamada4 <[email protected]>

* Removed force_update() since updater_ originaly updates diagnostics automatically.
Set the update peirod of diagnostics to be same to the timer_callback.
Changed words of the diagnostics message a bit.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Let the period of diagnostics publication independent to timer.
Let update_diagnostics to be simple.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Fixed typo

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Added setPeriod after force_update to reset the timer of updater_.
Then, there will be no duplicates of diagnostics.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Set diagnostics values to have the same precision
Added gyro_bias_threshold_ to the diagnostics

Signed-off-by: TaikiYamada4 <[email protected]>

* Updated README.md to match the paramters in gyro_bias_estimator

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

---------

Signed-off-by: TaikiYamada4 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request Jun 3, 2024
…agnostics in gyro_bias_estimator (autowarefoundation#6139)

* Let diagnostics be updated even if expections occur in timer_callback

Signed-off-by: TaikiYamada4 <[email protected]>

* Fixed the summary message to be "Not updated" when the gyro bias is not updated.
Fixed typo.

Signed-off-by: TaikiYamada4 <[email protected]>

* Removed force_update() since updater_ originaly updates diagnostics automatically.
Set the update peirod of diagnostics to be same to the timer_callback.
Changed words of the diagnostics message a bit.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Let the period of diagnostics publication independent to timer.
Let update_diagnostics to be simple.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Fixed typo

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Added setPeriod after force_update to reset the timer of updater_.
Then, there will be no duplicates of diagnostics.

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

* Set diagnostics values to have the same precision
Added gyro_bias_threshold_ to the diagnostics

Signed-off-by: TaikiYamada4 <[email protected]>

* Updated README.md to match the paramters in gyro_bias_estimator

Signed-off-by: TaikiYamada4 <[email protected]>

* style(pre-commit): autofix

---------

Signed-off-by: TaikiYamada4 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:sensing Data acquisition from sensors, drivers, preprocessing. (auto-assigned) tag:run-build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants