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

Update gz-sensors to use new message generation pipeline #349

Closed
wants to merge 3 commits into from

Conversation

mjcarroll
Copy link
Contributor

Allows gz-sim to take advantage of the new message generation pipeline in gazebosim/gz-msgs#339

@iche033
Copy link
Contributor

iche033 commented May 31, 2023

Got a couple of compile warnings from the generated header file which look like false positives:

In file included from /home/iche/code/gz_h_ws/build/gz-sensors8/gz_msgs_gen/gz/msgs/performance_sensor_metrics.pb.h:10,
                 from /home/iche/code/gz_h_ws/src/gz-sensors/src/Sensor.cc:24:
/home/iche/code/gz_h_ws/build/gz-sensors8/gz_msgs_gen/gz/msgs/details/performance_sensor_metrics.pb.h:402:20: warning: ‘simUpdateRate’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  402 |   sim_update_rate_ = value;
      |   ~~~~~~~~~~~~~~~~~^~~~~~~
/home/iche/code/gz_h_ws/src/gz-sensors/src/Sensor.cc:348:10: note: ‘simUpdateRate’ was declared here
  348 |   double simUpdateRate;

This fixes the warnings for me:

diff --git a/src/Sensor.cc b/src/Sensor.cc
index 242b02d..0605de1 100644
--- a/src/Sensor.cc
+++ b/src/Sensor.cc
@@ -345,8 +345,8 @@ void SensorPrivate::PublishMetrics(const std::chrono::duration<double> &_now)
   }
 
   // Computes simulation update rate and real update rate.
-  double simUpdateRate;
-  double realUpdateRate;
+  double simUpdateRate = 0.0;
+  double realUpdateRate = 0.0;
   const auto clockNow = std::chrono::steady_clock::now();
   // If lastUpdateTime == 0 means it wasn't initialized yet.
   if (this->lastUpdateTime.count() > 0)

@mjcarroll mjcarroll closed this Jul 26, 2023
@mjcarroll mjcarroll deleted the mjcarroll/message_generation_pipeline branch July 26, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants