Skip to content

Commit d74c520

Browse files
authored
Windows fixes for statistics tutorial (#533)
* Windows fixes for statistics tutorial --------- Signed-off-by: Jose Luis Rivero <[email protected]>
1 parent 8e27a44 commit d74c520

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

tutorials/23_topic_statistics.md

+30-14
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ for both publishers and subscribers. Setting `GZ_TRANSPORT_TOPIC_STATISTICS` to
3737
Additionally, a node on the subscriber side of a pub/sub relationship must
3838
call `EnableStats`. For example:
3939

40-
```
40+
```c++
4141
if (!node.EnableStats(topic, true))
4242
{
4343
std::cout << "Unable to enable stats\n";
@@ -54,7 +54,7 @@ It is possible to change the statistics output topic from `/statistics` to
5454
one of your choosing by specifying a topic name when enabling topic
5555
statistics. For example:
5656

57-
```
57+
```c++
5858
if (!node.EnableStats(topic, true, "/my_stats"))
5959
{
6060
std::cout << "Unable to enable stats\n";
@@ -64,7 +64,7 @@ if (!node.EnableStats(topic, true, "/my_stats"))
6464
You can also change the statistics publication rate from 1Hz by specifying
6565
the new Hz rate after the statistic's topic name:
6666

67-
```
67+
```c++
6868
if (!node.EnableStats(topic, true, "/my_stats", 100))
6969
{
7070
std::cout << "Unable to enable stats\n";
@@ -73,23 +73,39 @@ if (!node.EnableStats(topic, true, "/my_stats", 100))
7373

7474
### Example
7575

76+
For running the example, build the binaries in the example directory:
77+
78+
```
79+
git clone https://github.com/gazebosim/gz-transport -b gz-transport14
80+
cd gz-transport/example
81+
cmake -S . -B build
82+
# For UNIX
83+
cmake --build build --parallel
84+
# For Windows
85+
cmake --build build --config release --parallel
86+
```
87+
88+
#### Executing
7689
> **NOTE**
7790
> It is essential to have a valid value of `GZ_PARTITION` environment variable
7891
> and to have it set to the same value in all open terminals. As `GZ_PARTITION`
7992
> is based on hostname and username, especially Windows and Mac users might
8093
> have problems due to spaces in their username, which are not a valid character
8194
> in `GZ_PARTITION`. gz-transport prints error `Invalid partition name` in such
82-
> case. To resolve that, set `GZ_PARTITION` explicitly to a valid value:
83-
> ```bash
84-
> # Linux and Mac
85-
> export GZ_PARTITION=test
86-
> # Windows
87-
> set GZ_PARTITION=test
88-
> ```
95+
> case. To resolve that, set `GZ_PARTITION` explicitly to a valid value.
8996
9097
If you have the Gazebo Transport sources with the example programs built,
91-
then you can test topic statistics by following these steps.
98+
then you can test topic statistics by following these steps depending on the
99+
platform:
100+
101+
##### Linux or Mac
102+
103+
1. Terminal 1: `GZ_PARTITION=test GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/publisher`
104+
1. Terminal 2: `GZ_PARTITION=test GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/subscriber_stats`
105+
1. Terminal 3: `GZ_PARTITION=test GZ_TRANSPORT_TOPIC_STATISTICS=1 gz topic -et /statistics`
106+
107+
##### Windows
92108

93-
1. Terminal 1: `GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/publisher`
94-
1. Terminal 2: `GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/subscriber_stats`
95-
1. Terminal 3: `GZ_TRANSPORT_TOPIC_STATISTICS=1 gz topic -et /statistics`
109+
1. Terminal 1: `set "GZ_PARTITION=test" && set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && example\build\release\publisher.exe`
110+
1. Terminal 2: `set "GZ_PARTITION=test" && set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && example\build\subscriber_stats.exe`
111+
1. Terminal 3: `set "GZ_PARTITION=test" && set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && gz topic -et /statistics`

0 commit comments

Comments
 (0)