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.
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(); }
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(); }
Open rviz and subscribe to MarkerArray topic "/visualization_marker_array".
The final result should look like:
More Java examples including those provided above can be found in jros2rviztools, jros1rviztools repositories.