• Stars
    star
    747
  • Rank 60,336 (Top 2 %)
  • Language
    C++
  • Created almost 10 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C++ API wrapper for displaying shapes and meshes in Rviz

Rviz Visual Tools

C++ API wrapper for displaying shapes and meshes in Rviz via helper functions that publish markers. Useful for displaying and debugging data. For more advanced robot visualization features, see the moveit_visual_tools which builds on this class.

This package includes:

  • Rviz Panel GUI to step through your code for debugging and testing
  • Rviz-based keyboard control for stepping through application
  • Easy to use helper functions for visualizing in Rviz fast
  • Basic geometric markers for Rviz
  • More complex geometric shapes such as coordinate frames, framed boxes, planes, paths, graphs
  • Ability to quickly choose standard colors and sizes
  • Tools to ensure proper connection to Rviz before publishing visualizations
  • Shortcuts to convert between different types of points and poses - ROS msgs, Eigen, tf, etc
  • Batch publishing capabilities to reduce over throttling ROS messages
  • A tf publishing helper class
  • An interactive marker helper class

This open source project was developed at PickNik Robotics. Need professional ROS development and consulting? Contact us at [email protected] for a free consultation.

  • Build Status Travis CI
  • Build Status ROS Kinetic Buildfarm - AMD64 Xenial Debian Build for Ubuntu 16.04
  • Build Status ROS Kinetic Buildfarm - AMD64 Xenial Devel Build for Ubuntu 16.04
  • Build Status ROS Melodic Buildfarm - AMD64 Bionic Debian Build for Ubuntu 18.04
  • Build Status ROS Melodic Buildfarm - AMD64 Bionic Devel Build for Ubuntu 18.04

Install

Ubuntu Debian

sudo apt-get install ros-melodic-rviz-visual-tools

Build from Source

Clone this repository into a catkin workspace, then use the rosdep install tool to automatically download its dependencies. Depending on your current version of ROS, use:

rosdep install --from-paths src --ignore-src --rosdistro melodic

Quick Start Demo

To see random shapes generated in Rviz, first launch Rviz:

roslaunch rviz_visual_tools demo_rviz.launch

Then start demo:

roslaunch rviz_visual_tools demo.launch

Code API

See the Doxygen documentation

Usage

We'll assume you will be using these helper functions within a class. Almost all of the functions assume you are publishing transforms in the world frame (whatever you call that e.g. /odom).

Initialize

Add to your includes:

#include <rviz_visual_tools/rviz_visual_tools.h>

Add to your class's member variables:

// For visualizing things in rviz
rviz_visual_tools::RvizVisualToolsPtr visual_tools_;

In your class' constructor add:

visual_tools_.reset(new rviz_visual_tools::RvizVisualTools("base_frame","/rviz_visual_markers"));

Change the first parameter to the name of your robot's base frame, and the second parameter to whatever name you'd like to use for the corresponding Rviz marker ROS topic.

Tools

Now in your code you can easily debug your code using visual markers in Rviz

Start rviz and create a new marker using the 'Add' button at the bottom right. Choose the marker topic to be the same as the topic you specified in the constructor.

Example Code

In the following snippet we create a pose at xyz (0.1, 0.1, 0.1) and rotate the pose down 45 degrees along the Y axis. Then we publish the pose as a arrow for visualziation in Rviz. Make sure your Rviz fixed frame is the same as the one chosen in the code.

// Create pose
Eigen::Isometry3d pose;
pose = Eigen::AngleAxisd(M_PI/4, Eigen::Vector3d::UnitY()); // rotate along X axis by 45 degrees
pose.translation() = Eigen::Vector3d( 0.1, 0.1, 0.1 ); // translate x,y,z

// Publish arrow vector of pose
ROS_INFO_STREAM_NAMED("test","Publishing Arrow");
visual_tools_->publishArrow(pose, rviz_visual_tools::RED, rviz_visual_tools::LARGE);

// Don't forget to trigger the publisher!
visual_tools_->trigger();

For more example code see rviz_visual_tools_demo.cpp

Rviz GUI Usage

Publishes on the topic of /rviz_visual_tools_gui

The buttons in the Joy message correspond to the following:

1 - Next
2 - Continue
3 - Break
4 - Stop

Note: only Next is fully implemented

Mouse-Based Control

Use the Rviz panel called "RvizVisualToolsGui" to step through your program.

Keyboard-Based Control

Switch to the "KeyTool" in the top of the Rviz window and use the following keyboard commands:

  • n: next
  • c or a: continue
  • b: break
  • s: stop

API

Basic Publishing Functions

See rviz_visual_tools.h for more details and documentation on the following functions:

  • publishSphere
  • publishSpheres
  • publishArrow/publishXArrow
  • publishYArrow
  • publishZArrow
  • publishCuboid
  • publishCone
  • publishXYPlane
  • publishXZPlane
  • publishYZPlane
  • publishLine
  • publishPath
  • publishPolygon
  • publishBlock
  • publishWireframeCuboid
  • publishWireframeRectangle
  • publishAxis
  • publishAxisLabeled
  • publishCylinder
  • publishMesh
  • publishText
  • publishTest

And more...

Helper Functions

Reset function

  • deleteAllMarkers() - tells Rviz to clear out all current markers from being displayed.

All markers must be triggered after being published, by calling the trigger() function. This allows batch publishing to be achieved by only calling after several markers have been created, greatly increasing the speed of your application. You can even explicitly tell rviz_visual_tools how often to publish via the triggerEvery(NUM_MARKERS) command:

  • trigger()
  • triggerEvery(20)

Conversion functions

  • convertPose
  • convertPoint32ToPose
  • convertPoseToPoint
  • convertPoint
  • convertPoint32
  • convertFromXYZRPY
  • convertToXYZRPY

Convenience functions

  • generateRandomPose
  • generateEmptyPose
  • dRand
  • fRand
  • iRand
  • getCenterPoint
  • getVectorBetweenPoints

Frame locking

This allows the markers to be automatically updated as the base frame moves without having to republish. You can enable it via enableFrameLocking() (this is not enabled by default).

Available Colors

This package helps you quickly choose colors - feel free to send PRs with more colors as needed

BLACK,
BLUE,
BROWN,
CYAN,
DARK_GREY,
GREEN,
GREY,
LIME_GREEN,
MAGENTA,
ORANGE,
PINK,
PURPLE,
RED,
WHITE,
YELLOW,
TRANSLUCENT_LIGHT,
TRANSLUCENT,
TRANSLUCENT_DARK,
RAND,
CLEAR,
DEFAULT // i.e. 'do not change default color'

Available Marker Sizes

XXXXSMALL,
XXXSMALL,
XXSMALL,
XSMALL,
SMALL,
MEDIUM,
LARGE,
XLARGE,
XXLARGE,
XXXLARGE,
XXXXLARGE,

Interactive Marker Helper Class

This class quickly gives you basic 6dof pose interactive marker funcitonality. A demo is available:

roslaunch rviz_visual_tools demo_rviz.launch
rosrun rviz_visual_tools imarker_simple_demo

TF Visual Tools

This tool lets you easily debug Eigen transforms in Rviz. Demo use:

rviz_visual_tools::TFVisualTools tf_visualizer;
Eigen::Isometry3d world_to_shelf_transform = Eigen::Isometry3d::Identity(); // or whatever value
tf_visualizer.publishTransform(world_to_shelf_transform, "world", "shelf");

Note: this is a work in progress

Testing and Linting

To run roslint, use the following command with catkin-tools:

catkin build --no-status --no-deps --this --make-args roslint

To run catkin lint, use the following command with catkin-tools:

catkin lint -W2

Use the following command with catkin-tools to run the small amount of available tests:

catkin run_tests --no-deps --this -i

Run with clang-tidy:

run-clang-tidy-4.0.py -clang-tidy-binary=/usr/lib/llvm-4.0/bin/clang-tidy -fix -p=/home/dave/ros/current/ws_moveit/build/rviz_visual_tools .

Docker Image

Dockerhub automatically creates a Docker for this repo. To run with GUI:

# This is not the safest way however, as you then compromise the access control to X server on your host
xhost +local:root # for the lazy and reckless
docker run -it --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" davetcoleman/rviz_visual_tools:melodic
export containerId=$(docker ps -l -q)
# Close security hole:
xhost -local:root

(Optional) To build the docker image locally for this repo, run in base of package:

docker build -t davetcoleman/rviz_visual_tools:melodic .

Contribute

Please send PRs for new helper functions, fixes, etc!

When a pull request is opened, a reviewer is randomly assigned from the reviewer list using the Auto Assign Github Bot

More Repositories

1

ros_control_boilerplate

Provides a simple simulation interface and template for setting up a hardware interface for ros_control
C++
244
star
2

generate_parameter_library

Declarative ROS 2 Parameters
Python
228
star
3

roscpp_code_format

Auto formatting script for ROS C++ Style Guidelines
226
star
4

data_tamer

C++ library for Fearless Timeseries Logging
C++
196
star
5

deep_grasp_demo

Deep learning for grasp detection within MoveIt.
C++
104
star
6

abb_ros2

C++
80
star
7

pick_ik

Inverse Kinematics solver for MoveIt
C++
68
star
8

topic_based_ros2_control

ros2_control hardware interface that uses topics to command the robot and publish its state
C++
58
star
9

tf_visual_tools

Manually manipulate TFs in ROS using this Rviz plugin.
C++
51
star
10

ros2_robotiq_gripper

C++
48
star
11

RSL

ROS Support Library
C++
46
star
12

rosparam_shortcuts

Quickly load variables from rosparam with good command line error checking.
C++
38
star
13

descartes_capability

Drop-in capability for MoveIt's move_group that uses Descartes
C++
37
star
14

ros_testing_templates

C++
28
star
15

tf_keyboard_cal

Allows manual control of a TF through the keyboard or interactive markers
C++
27
star
16

quick-ros-install

Instant install script for ROS
Shell
25
star
17

ros2_package_template

A ROS2 package cookiecutter template
C++
22
star
18

moveit_studio_ur_ws

Workspace containing example MoveIt Studio configuration packages.
C++
21
star
19

UR10e_welding_demo

C++
21
star
20

crac_build_system

The unified Catin / ROSBuild / Ament / Colcon build system
Shell
21
star
21

snowbot_operating_system

The weather outside is frightful
C++
18
star
22

moveit_sim_controller

A simulation interface for a hardware interface for ros_control, and loads default joint values from SRDF
C++
14
star
23

ik_benchmarking

Utilities for IK solver benchmarking with MoveIt 2
C++
13
star
24

moveit_shelf_picking

Benchmarking suite for dual arm manipulation
C++
12
star
25

ros2_epick_gripper

ROS2 driver for the Robotiq EPick gripper.
C++
11
star
26

ROStoROS2

A living documentation of automate-able and manual steps for porting ROS packages to ROS2
10
star
27

moveit_studio_sdk

MoveIt Studio SDK
Python
9
star
28

trackjoint

C++
9
star
29

ros_reflexxes

Reflexxes Type II provides acceleration-limited trajectory smoothing
C++
9
star
30

ruckig_traj_smoothing

A jerk-limited trajectory smoothing plugin
8
star
31

graph_msgs

ROS messages for publishing graphs of different data types
CMake
8
star
32

launch_param_builder

Python library for loading parameters in launch files
Python
8
star
33

moveit_boilerplate

Basic functionality for easily building applications on MoveIt! in C++
C++
6
star
34

stretch_moveit_plugins

Package for the inverse kinematics solver for stretch from Hello Robot Inc.
C++
5
star
35

tool_changing

MoveGroup capability to dynamically change end-effectors
C++
4
star
36

test_examples

Examples of different test techniques (integration, unit, gtest, dependency injection...)
Python
4
star
37

moveit_studio_example_behaviors

C++
4
star
38

CMakeGuidelines

Collection of useful cmake tips
4
star
39

moveit_differential_ik_plugin

A plugin to provide differential kinematics. Used in admittance control.
C++
4
star
40

pronto

C++
4
star
41

light_painting_demo

C++
3
star
42

cpp_polyfills

Vendored Pollyfills for C++
C++
3
star
43

ocs2_robotic_assets

CMake
2
star
44

rqt2_setup

2
star
45

Moveit2_Tutorials

test deployment of moveit 2 tutorials
HTML
2
star
46

cartesian_msgs-release

1
star
47

moveit_sim_controller-release

1
star
48

ros_control_boilerplate-release

1
star
49

cirs_girona_cala_viuda

ROS2 version of girona cala viuda dataset
Python
1
star
50

picknik_controllers

PickNik's ros2_controllers
C++
1
star
51

rviz_visual_tools-release

1
star
52

rosparam_shortcuts-release

1
star
53

tf_keyboard_cal-release

1
star
54

rqt2_demo_nodes

Python
1
star
55

picknik_accessories

Various accessories used for studio configuration packages
CMake
1
star
56

moveit_studio_kortex_ws

C++
1
star
57

moveit_camera_survey

Code for survey of RGB-D cameras for manipulation
Dockerfile
1
star
58

picknik_ur5_moveit_config

CMake
1
star
59

beta_moveit_website

Demo site for major changes to moveit.ros.org. Found at http://moveit_beta.picknik.ai/
JavaScript
1
star
60

robot_on_rails

MoveIt Studio package for a UR robot on a linear rail
C++
1
star
61

c3pzero

Python
1
star
62

picknik_ament_copyright

Python
1
star
63

boost_sml

State Machine Library ROS Package
C++
1
star
64

cartesian_msgs

Experimental messages for sending Cartesian commands to a robot.
CMake
1
star