From 4c963a239129490c3493608dd9d742a323f9c911 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Thu, 12 Sep 2024 19:35:45 +0200 Subject: [PATCH 1/2] Windows fixes for statistics tutorial Signed-off-by: Jose Luis Rivero --- tutorials/23_topic_statistics.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tutorials/23_topic_statistics.md b/tutorials/23_topic_statistics.md index 1f24806f..37293687 100644 --- a/tutorials/23_topic_statistics.md +++ b/tutorials/23_topic_statistics.md @@ -37,7 +37,7 @@ for both publishers and subscribers. Setting `GZ_TRANSPORT_TOPIC_STATISTICS` to Additionally, a node on the subscriber side of a pub/sub relationship must call `EnableStats`. For example: -``` +```c++ if (!node.EnableStats(topic, true)) { std::cout << "Unable to enable stats\n"; @@ -54,7 +54,7 @@ It is possible to change the statistics output topic from `/statistics` to one of your choosing by specifying a topic name when enabling topic statistics. For example: -``` +```c++ if (!node.EnableStats(topic, true, "/my_stats")) { std::cout << "Unable to enable stats\n"; @@ -64,7 +64,7 @@ if (!node.EnableStats(topic, true, "/my_stats")) You can also change the statistics publication rate from 1Hz by specifying the new Hz rate after the statistic's topic name: -``` +```c++ if (!node.EnableStats(topic, true, "/my_stats", 100)) { std::cout << "Unable to enable stats\n"; @@ -73,9 +73,23 @@ if (!node.EnableStats(topic, true, "/my_stats", 100)) ### Example -If you have the Gazebo Transport sources with the example programs built, -then you can test topic statistics by following these steps. +For running the example, build the binaries in the example directory: + +``` +git clone https://github.com/gazebosim/gz-transport -b gz-transport14 +cd gz-transport/example +cmake -S . -B build +cmake --build build --config release --parallel +``` + +#### Executing on Linux or Mac 1. Terminal 1: `GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/publisher` 1. Terminal 2: `GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/subscriber_stats` 1. Terminal 3: `GZ_TRANSPORT_TOPIC_STATISTICS=1 gz topic -et /statistics` + +#### Executing on Windows + +1. Terminal 1: `set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && example\build\release\publisher.exe` +1. Terminal 2: `set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && example\build\subscriber_stats.exe` +1. Terminal 3: `set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && gz topic -et /statistics` From cf8d745e93cd8e8185f5e9e6ee9cb97979f88fd9 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Fri, 13 Sep 2024 11:30:54 +0200 Subject: [PATCH 2/2] Do not use cmake --config for single configuration generators Signed-off-by: Jose Luis Rivero --- tutorials/23_topic_statistics.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tutorials/23_topic_statistics.md b/tutorials/23_topic_statistics.md index 37293687..ce40afa5 100644 --- a/tutorials/23_topic_statistics.md +++ b/tutorials/23_topic_statistics.md @@ -79,6 +79,9 @@ For running the example, build the binaries in the example directory: git clone https://github.com/gazebosim/gz-transport -b gz-transport14 cd gz-transport/example cmake -S . -B build +# For UNIX +cmake --build build --parallel +# For Windows cmake --build build --config release --parallel ```