Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows fixes for statistics tutorial #533

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions tutorials/23_topic_statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand All @@ -73,23 +73,39 @@ if (!node.EnableStats(topic, true, "/my_stats", 100))

### Example

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
azeey marked this conversation as resolved.
Show resolved Hide resolved
```

#### Executing
> **NOTE**
> It is essential to have a valid value of `GZ_PARTITION` environment variable
> and to have it set to the same value in all open terminals. As `GZ_PARTITION`
> is based on hostname and username, especially Windows and Mac users might
> have problems due to spaces in their username, which are not a valid character
> in `GZ_PARTITION`. gz-transport prints error `Invalid partition name` in such
> case. To resolve that, set `GZ_PARTITION` explicitly to a valid value:
> ```bash
> # Linux and Mac
> export GZ_PARTITION=test
> # Windows
> set GZ_PARTITION=test
> ```
> case. To resolve that, set `GZ_PARTITION` explicitly to a valid value.

If you have the Gazebo Transport sources with the example programs built,
then you can test topic statistics by following these steps.
then you can test topic statistics by following these steps depending on the
platform:

##### Linux or Mac

1. Terminal 1: `GZ_PARTITION=test GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/publisher`
1. Terminal 2: `GZ_PARTITION=test GZ_TRANSPORT_TOPIC_STATISTICS=1 ./example/build/subscriber_stats`
1. Terminal 3: `GZ_PARTITION=test GZ_TRANSPORT_TOPIC_STATISTICS=1 gz topic -et /statistics`

##### Windows

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`
1. Terminal 1: `set "GZ_PARTITION=test" && set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && example\build\release\publisher.exe`
1. Terminal 2: `set "GZ_PARTITION=test" && set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && example\build\subscriber_stats.exe`
1. Terminal 3: `set "GZ_PARTITION=test" && set "GZ_TRANSPORT_TOPIC_STATISTICS=1" && gz topic -et /statistics`