Skip to content

Add PlotJuggler bridge example - #783

Open
azeey wants to merge 5 commits into
gazebosim:gz-transport15from
azeey:plotjuggler
Open

Add PlotJuggler bridge example#783
azeey wants to merge 5 commits into
gazebosim:gz-transport15from
azeey:plotjuggler

Conversation

@azeey

@azeey azeey commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

🎉 New feature

Summary

Adds bridge from Gazebo to PlotJuggler that allows plotting any numerical topic from Gazebo. The bridge creates a generic subscriber, converts the protobuf data to json and republishes it over zeromq, which is a supported input source in PlotJuggler.

I was contemplating whether we should add this as subcommand of gz, maybe gz plot_juggler_bridge. How does that sound?

Here's a plot of magnetometer sensor data

image

Test it

Included in the README

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Generated-by: Gemini 2.5 Pro

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

Addisu Z. Taddese added 5 commits January 16, 2026 10:33
Generated-By: Gemini 2.5 Pro
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Generated-By: Gemini 2.5 Pro

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Generated-By: Gemini 2.5 Pro
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development Jan 19, 2026
@caguero

caguero commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

This is so cool! Taking a look...


// Convert the message to a JSON string
std::string msgJsonString;
google::protobuf::json::PrintOptions options;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting a compilation error on Ubuntu Noble with libprotobuf-dev 3.21.12-8.2ubuntu0.2. I'm guessing this isn't available here. I do see an alternative always_print_primitive_fields.

/home/caguero/jetty_ws/src/gz-transport/example/plotjuggler/gz_pj_bridge.cc:102:23: error: ‘google::protobuf::json’ has not been declared
  102 |     google::protobuf::json::PrintOptions options;
      |                       ^~~~
/home/caguero/jetty_ws/src/gz-transport/example/plotjuggler/gz_pj_bridge.cc:103:5: error: ‘options’ was not declared in this scope; did you mean ‘optind’?
  103 |     options.always_print_fields_with_no_presence = true;

}

// Get a timestamp
double timestamp = std::chrono::duration<double>(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp doesn't seem used.

std::chrono::system_clock::now().time_since_epoch())
.count();

// Create the final JSON payload for PlotJuggler

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the commented block?

std::cout << "[+] Subscribed: " << topic << " [" << msgType << "]"
<< std::endl;
this->subscribedTopics.insert(topic);
this->topicToType[topic] = msgType;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a potential race condition accessing this->topicToType from this function and from OnMessage().


public: void Run()
{
while (true)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to replace this infinite loop with a while (running) { ... }, where running is declared as an std::atomic<bool>. We can install a signal handler (that will set running to false and allow graceful shutdown.

pub(ctx, ZMQ_PUB)
{
// Bind ZMQ to port 9872
this->pub.bind("tcp://*:9872");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to make this port configurable from the command line.

project(gz_pj_bridge)

set(CMAKE_CXX_STANDARD 17)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add set(CMAKE_CXX_STANDARD_REQUIRED ON) to force c++17 standard or error otherwise?

}
}

private: gz::transport::Node node;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add some doxygen doc and our ///////////////////////////////////////////////// delimiters for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants