Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 6e099dd

Browse files
committed
Added feedback
Signed-off-by: ahcorde <ahcorde@gmail.com>
1 parent bda86f1 commit 6e099dd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

gazebo/Server.cc

+8-5
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ transport::PublisherPtr performanceMetricsPub;
562562

563563
void PublishPerformanceMetrics()
564564
{
565+
if (!performanceMetricsPub || !performanceMetricsPub->HasConnections())
566+
return;
567+
565568
physics::WorldPtr world = physics::get_world("default");
566569

567570
/// Outgoing run-time simulation performance metrics.
@@ -598,11 +601,12 @@ void PublishPerformanceMetrics()
598601
{
599602
double updateSimRate =
600603
(sensor->LastMeasurementTime() - sensorsLastMeasurementTime[name]).Double();
601-
double updateRealRate =
602-
(world->RealTime() - worldLastMeasurementTime[name]).Double();
603604
sensorsLastMeasurementTime[name] = sensor->LastMeasurementTime();
604605
if (updateSimRate > 0.0)
605606
{
607+
double updateRealRate =
608+
(world->RealTime() - worldLastMeasurementTime[name]).Double();
609+
606610
struct sensorPerformanceMetricsType emptySensorPerfomanceMetrics;
607611
auto ret2 = sensorPerformanceMetrics.insert(
608612
std::pair<std::string, struct sensorPerformanceMetricsType>
@@ -648,8 +652,7 @@ void PublishPerformanceMetrics()
648652
}
649653

650654
// Publish data
651-
if (performanceMetricsPub && performanceMetricsPub->HasConnections())
652-
performanceMetricsPub->Publish(performanceMetricsMsg);
655+
performanceMetricsPub->Publish(performanceMetricsMsg);
653656
}
654657

655658
/////////////////////////////////////////////////
@@ -709,7 +712,7 @@ void Server::Run()
709712

710713
performanceMetricsPub =
711714
this->dataPtr->node->Advertise<msgs::PerformanceMetrics>(
712-
"~/performance_metrics", 100, 5);
715+
"/gazebo/performance_metrics", 100, 5);
713716

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

0 commit comments

Comments
 (0)