In this post, we will see what Rviz is all about and how to use it.
We are going to use a ROS1 installation for this, but you don’t need to install ROS, as we will use the ROS Development Studio (ROSDS), an online platform that provides access to ROS1 or ROS2 computers and other powerful ROS tools within a browser!
Once you have cloned the project, open it up and give it a moment to finish loading.
Step 2: Bring up a TurtleBot2 simulation
Head to the Simulations menu and launch one of the pre-configured simulations:
Select “Simulations from the main menu”.
Under “World”, select “Empty to World”.
Under “Robot”, select TurtleBot2.
Click “Start Simulation”.
You should now have something like this:
That’s a TutleBot2 facing a wall.
Step 3: Launch the rviz program and use it to “spy” on the TurtleBot
We need two more tools here.
Minimize the Gazebo window.
From the Tools menu, pick “Shell” and “Graphical Tools”. Arrange them side-by-side for better visibility.
On the Shell tool, run the following command:
rosrun rviz rviz
You should now have something like this:
Maximize the Rviz window and:
Double-click the Title bar to bring the window into full focus. Ensure you can clearly see the “Add” button lablled 3 below.
Change the “Fixed frame” to “base_link”.
Click “Add” to add a visualization.
Select “Camera”
Click okay.
Semi-finally, select a topic for the Camera visualization. You should see the brick wall in full color now!
Finally, pick another Shell from the Tools menu and run the following command to cause the robot to rotate. You should see the wall in the Camera disappear and appear again as the front camera position changes.
# Just type rostopic pub /cmd_vel and then press TAB-TAB to complete message structure.
# Then change angular.z to 1.0
user:~$ rostopic pub /cmd_vel geometry_msgs/Twist "linear:
x: 0.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.0"
Interesting, isn’t it? You can try and play with other visualization tools and see how they work.
Now’s let review the theory briefly.
Step 4: So, what’s Rviz?
We have just seen Rviz in action. So what exactly is this amazing tool?
Short for ROS Visualization. It’s a 3-dimensional visualization tool for ROS.
It helps to visualize what the robot seeing and doing.
And that’s it. It’s more practical than theory 🙂 .
Extra: Video
Prefer to watch a video demonstrating the steps above? We have one for you below!
Related Resources and Further Learning
If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:
Did you like this post? Do you have questions about what is explained? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.
If you want to learn about other ROS topics, please let us know in the comments area and we will do a video or post about it
Gazebo is a leader in robot simulation. It is a tool relied upon by hundreds of thousands of users and developers around the world.
Perhaps you have heard “Gazebo simulation” many times, but you don’t know exactly what it is or how it works. In this post, you will learn what a Gazebo simulation is by practicing, as it pertains to ROS development.
You don’t need a ROS installation for this, as we will use the ROS Development Studio (ROSDS), an online platform that provides access to ROS1 & ROS2 computers and other powerful ROS tools within a browser!
Action first before the theory! Grab a copy of the project used for this post using the link below. If you don’t have an account on the ROSDS, you will be guided to create one.
Once you have cloned the project, open it up and give it a moment to finish loading.
If you want to know how to install Gazebo in an existing ROS environment on your local computer, then please follow this tutorial:
[irp posts=”8194″ name=”All about Gazebo ROS (Gazebo 9)”]
Step 2: Bring up a Gazebo simulation
From the ROSDS Tools menu, pick the Shell and Gazebo tools. Yeah, we have a tool so named:). Place the tools side-by-side for best effect.
Type the following commands on the Shell to bring up a Gazebo simulation.
user:~$ roslaunch gazebo_ros mud_world.launch
You should now see something similar to this:
Step 3: What is Gazebo simulation in theory?
Well, I just showed you a Gazebo simulation in the step above, in practice. Now we are going to look what it’s in theory.
A Gazebo simulation is a robot simulation made with Gazebo, a 3D simulator with the ability to accurately and efficiently simulate populations of robots in complex indoor and outdoor environments.
It’s similar to game engines, but produces better simulations and offers a suite of sensors and interfaces for both users and programs.
It has the following main components:
World files – contain all the elements in a simulation, including robots, lights, sensors, and static objects. In the image above, the world is shown in the Gazebo app.
Models – represent individual elements. The three robots and the object in front of them are models.
gzserver – the “work horse” Gazebo program – it reads the world file to generate and populate a world.
gzclient – connects to gzserver and visualizes the elements. In the shell output, under “NODES”, we have both gzserver and gzclient listed.
gzweb – web version of gzclient, using WebGL.
Step 4: Wrapping up
And that’s it! You know what a Gazebo simulation is in both practice and theory. This knowledge is the foundation for using and creating Gazebo simulations.
Extra: Video
Prefer to watch a video demonstrating the steps above? We have one for you below!
Related Resources and Further Learning
If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:
Did you like this post? Do you have questions about what is explained? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.
If you want to learn about other ROS topics, please let us know in the comments area and we will do a video or post about it
welcome to this new post on the “ROS In 5 Minutes” series!
In this post we are going to see how to publish the position of a robot with Python using the TransformBroadcaster. For that we are going to use Robot Ignite Academy, which is the best platform for those who want to Learn ROS Fast.
Before we start, in case you are new to ROS, remember that we have ROS Basics courses in Python and C++:
Ok, let’s get started. In order to develop our position publisher in ROS we first need to create a ROS package. Our package will be located on the src folder of the ~/catkin_ws (catkin workspace) and its name will be tutorial. Given that we will use python, we add the rospy dependency. For that we use the following commands:
mkdir ~/catkin_ws/src/ -p
cd ~/catkin_ws/src/
catkin_create_pkg tutorial rospy
Now that our package is created, let’s create a python file called broadcaster on its src folder and make it executable with the commands below:
cd ~/catkin_ws/src/tutorial/src/
touch my_broadcaster.py
chmod +x my_broadcaster.py
Now let’s add the code that publishes the positions to our my_broadcaster.py file. The content is as follows:
#! /usr/bin/env python
from tf import TransformBroadcaster
import rospy
from rospy import Time
def main():
rospy.init_node('my_broadcaster')
b = TransformBroadcaster()
translation = (0.0, 0.0, 0.0)
rotation = (0.0, 0.0, 0.0, 1.0)
rate = rospy.Rate(5) # 5hz
x, y = 0.0, 0.0
while not rospy.is_shutdown():
if x >= 2:
x, y = 0.0, 0.0
x += 0.1
y += 0.1
translation = (x, y, 0.0)
b.sendTransform(translation, rotation, Time.now(), 'ignite_robot', '/world')
rate.sleep()
if __name__ == '__main__':
main()
Now that we have everything in place, we just run our code with:
rosrun tutorial my_broadcaster.py
With the code running we don’t see any message. That is the expected behavior since we didn’t call any log functions in our code.
In order to really see the code in action we have to open RViz, which stands for ROS Visualization. For that we need to run in a different shell the following command:
rosrun rviz rviz
Once RViz is running, in order to see it you have to click on the Open Graphical Interface button, the one which is being pointed by a red arrow on the image below:
Once you click that button you will be able to see RViz. The Fixed Frame will be probably pointing to /map, so you have to change it to world as we can see on the next image:
Once we selected the frame we are using as the fixed one we have to add the TF Display. If you look at the previous image you will see on the bottom left a button called “Add“. Let’s click that button and select TF, as in the image below:
After that you should be able to see the positions of our robot being published. The image below shows that.
Remember that we also have a video on YouTube that details everything written in this post.
To conclude, I hope you have liked the post and the video. If so, please give us a thumbs up and subscribe to our channel on YouTube: https://www.youtube.com/watch?v=8U-cwv6db3U.
Also, whether you like the video or not, please leave a comment on the comments section of YouTube. Feel free also to share this content with your friends.
In today’s videos we are going see 5 different ways if seeing tf data, which at the end is used to know the positions of robots in a given world, for example.
But before we start, if you want to Learn ROS Fast, remember to take one of the following courses on Robot Ignite Academy:
In order to create our package we have used the following commands:
mkdir ~/catkin_ws/src -p
cd ~/catkin_ws/src
catkin_create_pkg tutorial rospy
cd tutorial/
mkdir test
cd test/
touch test_code.py
chmod +x test_code.py
ls
The content of our test_code.py file is:
#! /usr/bin/env python
import unittest
import rostest
class MyTestCase(unittest.TestCase):
def test_whatever(self):
pass
if __name__ == “__main__”:
rostest.rosrun(‘tutorial’, ‘test_code’, MyTestCase)
The first way of executing it is by calling it directly:
./test_code.py
The second way is using a .test file:
roscd tutorial
mkdir launch
cd launch/
touch test_code.test
After filling that file we call it with:
rostest tutorial test_code.test
The 3rd way of executing is by adding the line below to our CMakeLists.txt file:
catkin_add_nosetests(test/test_code.py)
and calling:
cd ~/catkin_ws/
catkin_make run_tests
And the 4th way is by adding the lines below to our CMakeLists.txt file (remove to remove the line added on the 3rd way, otherwise
your test will be executed twice, wasting time):