Skip to content

Commit

Permalink
Added feedback
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde committed Aug 17, 2020
1 parent bda86f1 commit 6e099dd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions gazebo/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ transport::PublisherPtr performanceMetricsPub;

void PublishPerformanceMetrics()
{
if (!performanceMetricsPub || !performanceMetricsPub->HasConnections())
return;

physics::WorldPtr world = physics::get_world("default");

/// Outgoing run-time simulation performance metrics.
Expand Down Expand Up @@ -598,11 +601,12 @@ void PublishPerformanceMetrics()
{
double updateSimRate =
(sensor->LastMeasurementTime() - sensorsLastMeasurementTime[name]).Double();
double updateRealRate =
(world->RealTime() - worldLastMeasurementTime[name]).Double();
sensorsLastMeasurementTime[name] = sensor->LastMeasurementTime();
if (updateSimRate > 0.0)
{
double updateRealRate =
(world->RealTime() - worldLastMeasurementTime[name]).Double();

struct sensorPerformanceMetricsType emptySensorPerfomanceMetrics;
auto ret2 = sensorPerformanceMetrics.insert(
std::pair<std::string, struct sensorPerformanceMetricsType>
Expand Down Expand Up @@ -648,8 +652,7 @@ void PublishPerformanceMetrics()
}

// Publish data
if (performanceMetricsPub && performanceMetricsPub->HasConnections())
performanceMetricsPub->Publish(performanceMetricsMsg);
performanceMetricsPub->Publish(performanceMetricsMsg);
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -709,7 +712,7 @@ void Server::Run()

performanceMetricsPub =
this->dataPtr->node->Advertise<msgs::PerformanceMetrics>(
"~/performance_metrics", 100, 5);
"/gazebo/performance_metrics", 100, 5);

GZ_PROFILE_THREAD_NAME("gzserver");
// Stay on this loop until Gazebo needs to be shut down
Expand Down

0 comments on commit 6e099dd

Please sign in to comment.