@@ -37,7 +37,7 @@ for both publishers and subscribers. Setting `GZ_TRANSPORT_TOPIC_STATISTICS` to
37
37
Additionally, a node on the subscriber side of a pub/sub relationship must
38
38
call ` EnableStats ` . For example:
39
39
40
- ```
40
+ ``` c++
41
41
if (!node.EnableStats(topic, true ))
42
42
{
43
43
std::cout << "Unable to enable stats\n";
@@ -54,7 +54,7 @@ It is possible to change the statistics output topic from `/statistics` to
54
54
one of your choosing by specifying a topic name when enabling topic
55
55
statistics. For example:
56
56
57
- ```
57
+ ``` c++
58
58
if (!node.EnableStats(topic, true , " /my_stats" ))
59
59
{
60
60
std::cout << "Unable to enable stats\n";
@@ -64,7 +64,7 @@ if (!node.EnableStats(topic, true, "/my_stats"))
64
64
You can also change the statistics publication rate from 1Hz by specifying
65
65
the new Hz rate after the statistic's topic name:
66
66
67
- ```
67
+ ``` c++
68
68
if (!node.EnableStats(topic, true , " /my_stats" , 100 ))
69
69
{
70
70
std::cout << "Unable to enable stats\n";
@@ -73,23 +73,39 @@ if (!node.EnableStats(topic, true, "/my_stats", 100))
73
73
74
74
### Example
75
75
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
76
89
> ** NOTE**
77
90
> It is essential to have a valid value of ` GZ_PARTITION ` environment variable
78
91
> and to have it set to the same value in all open terminals. As ` GZ_PARTITION `
79
92
> is based on hostname and username, especially Windows and Mac users might
80
93
> have problems due to spaces in their username, which are not a valid character
81
94
> 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.
89
96
90
97
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
92
108
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