jrosrviztools
CONTENT

Overview

jrosrviztools is a Java module which allows to interact with RViz in ROS (Robot Operating System).

It allows you to publish different kind of visualization information into RViz, among it text, geometric shapes (cube, cylinder etc), points etc.

It is inspired by rviz_visual_tools C++ library. It neither requires you to install rviz_visual_tools nor ROS itself. jrosrviztools is not a JNI wrapper and is completely Java based.

It is based on jrosclient module which is a Java client for ROS.

Supported ROS versions

ROS2

ROS1

Requirements

Usage examples

Publishing CUBE marker with a text

ROS2

Required Java dependencies:

Code:

        var clientFactory = new JRos2ClientFactory();
        var rvizToolsFactory = new JRos2RvizToolsFactory();
        try (var client = clientFactory.createClient();
                var rvizTools =
                        rvizToolsFactory.createJRosRvizTools(
                                client, "map", "/visualization_marker_array")) {
            rvizTools.publishText(
                    Color.RED, Scales.XLARGE, new Pose(new Point(0, 0, 1)), "Hello from Java");
            rvizTools.publishMarkers(Color.RED, Scales.XLARGE, MarkerType.CUBE, new Point(1, 0, 2));
            System.out.println("Press Enter to stop...");
            System.in.read();
        }

ROS1

Required Java dependencies:

        var clientFactory = new JRos1ClientFactory();
        var rvizToolsFactory = new JRos1RvizToolsFactory();
        try (var client = clientFactory.createClient("http://127.0.0.1:11311/");
                var rvizTools =
                        rvizToolsFactory.createRvizTools(
                                client, "map", "/visualization_marker_array")) {
            rvizTools.publishText(
                    Color.RED, Scales.XLARGE, new Pose(new Point(0, 0, 1)), "Hello from Java");
            rvizTools.publishMarkers(
                    Color.RED, Scales.XLARGE, MarkerType.SPHERE, new Point(1, 0, 1));
            System.out.println("Press Enter to stop...");
            System.in.read();
        }

Final result

Open rviz and subscribe to MarkerArray topic "/visualization_marker_array".

The final result should look like:

More examples

More Java examples including those provided above can be found in jros2rviztools, jros1rviztools repositories.

Documentation

Links

Free Web Hosting