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

Publish performance sensor metrics. #146

Merged
merged 7 commits into from
Aug 19, 2021

Conversation

francocipollone
Copy link
Contributor

@francocipollone francocipollone commented Jul 21, 2021

Signed-off-by: Franco Cipollone franco.c@ekumenlabs.com

🎉 New feature

Related to gazebosim/gz-sim#557

Summary

message PerformanceSensorMetrics
{
  /// \brief Sensor name
  string name                 = 1;

  /// \brief The update rate of the sensor in real time.
  double real_update_rate     = 2;

  /// \brief The update rate of the sensor in simulation time.
  double sim_update_rate      = 3;

  /// \brief The nominal update rate defined to the sensor.
  double nominal_update_rate  = 4;

  /// \brief If the sensor is a camera then this field should be filled
  /// with average fps in real time.
  Double fps                  = 5;
}
  • ignition::sensors::Sensor provides an API to let the subclasses to publish a custom message or change the way the metrics are computed. For example, CameraSensor's PublishMetrics implementation should also fill the fps field of the message.

Test it

It can be tested using an ignition simulation:

the sensors in the .sdf must enable this behavior by doing:
<enable_metrics>true</enable_metrics>

Then we can do:

ign gazebo sensors.sdf

and then verify the messages being published:

ign topic --list
/air_pressure
/air_pressure/performance_metrics
/altimeter
/altimeter/performance_metrics
/clock
/gazebo/resource_paths
/gui/camera/pose
/gui/record_video/stats
/imu
/imu/performance_metrics
/magnetometer
/magnetometer/performance_metrics
...

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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

Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
@francocipollone
Copy link
Contributor Author

It is ready for review @chapulina 😃 !, let me know if I should ask someone else for a review.

@chapulina chapulina added the needs upstream release Blocked by a release of an upstream library label Aug 2, 2021
@chapulina chapulina mentioned this pull request Aug 6, 2021
7 tasks
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Works for me, I just have various minor comments.

include/ignition/sensors/Sensor.hh Outdated Show resolved Hide resolved
src/Sensor.cc Outdated Show resolved Hide resolved
src/Sensor.cc Show resolved Hide resolved
src/Sensor.cc Outdated Show resolved Hide resolved
src/Sensor.cc Outdated Show resolved Hide resolved
src/Sensor.cc Outdated Show resolved Hide resolved
src/Sensor.cc Outdated Show resolved Hide resolved
src/Sensor.cc Show resolved Hide resolved
src/Sensor.cc Outdated
double simUpdateRate;
double realUpdateRate;
const auto clockNow = std::chrono::steady_clock::now();
if(this->lastUpdateTime > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why can't it be zero?

Copy link
Contributor Author

@francocipollone francocipollone Aug 12, 2021

Choose a reason for hiding this comment

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

If it is zero then this variable wasn't initialized(first iteration) yet so the calculus below is pointless.

@codecov
Copy link

codecov bot commented Aug 9, 2021

Codecov Report

Merging #146 (db8a8f5) into ign-sensors3 (ca0dab3) will increase coverage by 0.02%.
The diff coverage is 78.94%.

Impacted file tree graph

@@               Coverage Diff                @@
##           ign-sensors3     #146      +/-   ##
================================================
+ Coverage         77.14%   77.17%   +0.02%     
================================================
  Files                23       23              
  Lines              2306     2344      +38     
================================================
+ Hits               1779     1809      +30     
- Misses              527      535       +8     
Impacted Files Coverage Δ
src/Sensor.cc 88.97% <78.94%> (-4.29%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca0dab3...db8a8f5. Read the comment docs.

src/Sensor.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Works great! Let's bump the required libSDFormat version on CMakeLists once the 9.6.0 release is out: https://build.osrfoundation.org/job/sdformat9-debbuilder/

I made this quick PR to enable metrics on some Gazebo demos: gazebosim/gz-sim#982

src/Sensor_TEST.cc Show resolved Hide resolved
@francocipollone francocipollone force-pushed the francocipollone/performance_metrics branch 2 times, most recently from 1a6355e to 1b3c6f7 Compare August 19, 2021 14:08
francocipollone and others added 4 commits August 19, 2021 11:09
Co-authored-by: Louise Poubel <louise@openrobotics.org>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Co-authored-by: Louise Poubel <louise@openrobotics.org>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
This reverts commit a90110c.

Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
@chapulina chapulina enabled auto-merge (squash) August 19, 2021 22:05
@chapulina chapulina merged commit e181d3e into ign-sensors3 Aug 19, 2021
@chapulina chapulina deleted the francocipollone/performance_metrics branch August 19, 2021 22:23
@chapulina chapulina removed the needs upstream release Blocked by a release of an upstream library label Aug 20, 2021
@chapulina chapulina mentioned this pull request Aug 30, 2021
7 tasks
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-01-10/1228/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel performance Runtime performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants