RViZ (short for ROS Visualization) is a visualization tool in ROS. It's used to visualize things like data from sensors like cameras, temperature sensors, LiDARs, Point cloud data, odometry, etc. It can also be used to show a robot model, in case we want to view the single robot in isolation from an environment. In very short, it's a powerful 3D visualization tool in ROS. Keep in mind that it's to visualize and not to simulate anything. So it can only show you stuff, it can't do things on it's own, that is: it can't create simulation outcomes like what a simulator does, it can't do anything that involves interaction between two objects. There are other tools in ROS for doing exactly that, but we'll see them in later pages.
RViZ is made on top of various open libraries and frameworks, Qt (for the application graphical user interface), OpenGL (open graphics library) and PCL (point cloud library) being notable few ones. There are a lot of dependencies for this tool. But lucky for us, all this comes to us in one single package named "rviz", that too in only one executable node, named "rviz". Let's see the RViZ GUI first, then we'll go about doing more with it. Open terminals and execute the following commands on different terminals:
roscore
rosrun rviz rviz
rviz
and it would yield the same results.After the window is spawned, it must look something like this:
RViZ Application
Complete user guide here.
All these menus are also called panels. You can check the Panels option in the menu bar and play around with arrangements a little.
Let's simulate a temperature sensor and see it's readings as a color on a square inside RViZ for this tutorial. This one is a little long, so I've divided it into stages.
Execute the following commands on different terminals (or on different tabs):
roscore
rosrun rviz rviz
Then, in the Displays panel click on Add and choose Temperature from the list (under rviz items, by display type), click ok. Make the following modifications in the Displays panel:
Then, in the Views panel, make the following modifications:
In the end, your RViZ window must look like what's shown below (in the Description photo).
Description photo
Your values in the Time panel might be different because of timing reasons. Rest everything must match.
After this, perform the following:
To verify that everything went fine, do the following:
We'll deal with actual hardware later, for now we'll just simulate one using a node. This will just be a simple publisher publishing messages of type sensor_msgs/Temperature, you can know more about it by running rosmsg info sensor_msgs/Temperature
. The procedure for it is the same as any other publisher, besides, we already made one here. There are a few key differences though:
Then make the package, open a terminal and run the following:
cd ~/ROS_workspaces/ros_ws/
catkin_make
Let's create a single file that will spawn everything. Here's a list of things that we'll do:
rosrun rviz rviz --help
).Here's a little more modified version of the launch file, this one has configurations set up as well.
Codes for launch file and source (C++) node
After all this, open a terminal and run a single command shown below. You must see the RViZ window open with a square in the middle that changes color over time based on temperature passed on the topic (observe for about 40 seconds, image shown below).
roslaunch intro_pkg1 TemperatureRViZ.launch
This is more or less how any RViZ related project is developed, fee free to explore more options about various other sensors.
Results about 40 seconds after RViZ gets launched