In this video we’re going to show how you can easily have ROS2 crystal running on your computer, in just a few steps, without the need of installing anything.
This video shows you how start running ROS 2 in your computer in a few seconds without having to install anything. You will also learn how to create a ROS 2 package and how to interact with a Gazebo simulation that runs on ROS 1, using the ros1_bridge
—
Feedback
—
Did you like this video? 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 on the comments area and we will do a video about it;)
—
Commands used
—
Start the ROS2 docker machine, mounting a host directory: docker run -it -v “/home/user/ai_ws:/home” osrf/ros2:bouncy-basic
Create a package: ros2 pkg create [package_name]
See a list of packages: ros2 pkg list
—
Links mentioned in the video and other useful links:
—
– Robot Ignite Academy, the place to learn to program robots using only a web browser
– ROS Development Studio (ROSDS), a powerful online tool for pushing your ROS learning in a practical way (the environment used in the video for demonstration)
—
Feedback
—
Did you like this video? Whatever the case, please leave a comment in 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 on the comments area and we will do a video about it.
In this short post, we’ll find out what a ROS2 message is and what ROS2 has provided to work with messages. Keeping up with our usual style, we’ll use a practical-centric approach to learning ROS, with some sort of twist here – a practical/theory sandwich!
Let’s go!
Setup for the practicals
To follow this post, you need access to a ROS2 installation. There are two options for this. I recommend option 1; I used it for this post.
Avoid all headaches related to ROS(2) installation and embrace the future — spin a development environment within a few seconds and with a few clicks on ROSDS. If you select this option, to “open a terminal”, just select the Shell app on the ROSDSTools menu.
Keep all the headaches related with ROS(2) installation; you have good reasons like supporting the drug companies…kidding 🙂 — use a local ROS2 install or a PC with Docker installed.
Okay, you just made your choice; now, let’s shoot the first command. On a new terminal, spin up the ROS2 docker machine. You can skip this if you have ROS2 installed locally:
user:~$ docker run -it osrf/ros2:nightly
Unable to find image 'osrf/ros2:nightly' locally
nightly: Pulling from osrf/ros2
...
root@9cd3dc8de69a:/#
Good job; now we are ready for some action!
So, what is a ROS2 message? Here’s your sandwich!
Well, you had it coming; here you go!
What does ROS2 have to say about messages?
In your open shell, type this command at the shell:
root@9cd3dc8de69a:/# ros2 msg
usage: ros2 msg [-h] Call `ros2 msg <command> -h` for more detailed usage. ...
Various msg related sub-commands
optional arguments:
-h, --help show this help message and exit
Commands:
list Output a list of available message types
package Output a list of available message types within one package
packages Output a list of packages which contain messages
show Output the message definition
Call `ros2 msg <command> -h` for more detailed usage.
That’s about all you get to work with ROS2 messages in the current version.
The makers of ROS2 decided to save you some typing by shortening “message” to “msg”, but you might find yourself typing “ros2 message…” sometimes. Not to worry, it happens, and the shell will faithfully do its job of shocking you back to reality :). But I digress…
Back to the issue on ground: all that output above and not a word about what a ROS2 message is? The shell output is rather assuming, don’t you think? Anyways, time to use some theory. We’ll come back to the shell later on.
A picture speaks a thousand words
So they say. Since the shell couldn’t help us, maybe a picture will. Here is it:
Key points about the picture above:
Nodes need to communicate with one another.
They do so by sending and receiving messages over channels called topics.
These are the basics of ROS(2) messages. We’ll see more in the “tell and show” subsections that follow.
There are different kind of messages
Yes, depending on the goal. For instance, a message to move a robot wheel is different from a message to take a picture with its camera.
Let’s see what the shell has to say about this, using the first command (list) shown in our first shell output:
Whew, we have a bucket list there (output truncated)! Those are the message types bundled with ROS2. You can create your own messages, but we won’t talk about that here.
You now know that there are many message type, but there’s one more important thing you should know…
You need to know the structure of messages before you can use them effectively
Yes, that right:
Sending nodes need this to compose a valid message.
Receiving nodes need this to properly process the message received.
Let’s say we want to send a ‘string’ message “Hello World”. Looking at the list of bundled messages, std_msgs/String looks like a good candidate. How do we compose a message of that type? Here’s where the last command (show) proposed by our first shell output comes in:
root@9cd3dc8de69a:/# ros2 msg show std_msgs/String
string data
So we know from the output above that we need to compose a message object with a single variable data of string type. Now let’s send the message over the wire:
Remember we mentioned that we send messages over channels called topics? Here we’re sending out message over the /world channel. If you want to learn more about working with topics, please see this post.
Take home – make your own sandwich!
So far so good! Having taken the sandwich in the section above, I believe you have come of age and can make some yourself now 🙂 . The following were intentionally left out of this post, try them out:
Examine the structure of the geometry_msgs/Twist , geometry_msgs/Vector3 and any other message(s) you wish from the bucket list of message types.
Try out the message sub-commands shown in the first shell output: package and packages.
Video version of this post
One man’s meat is another man’s fish. If you prefer to learn about ROS2 messages by watching a short video, we have one for your below. Happy watching!
Feedback
Did you like this post or the video? Whatever the case, please leave us your thoughts in 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 post or video about it.
In this post, we’ll see how to work (or play) with ROS2 topics from the command line. This is very useful for tinkering with ROS2 topics as wells as writing and debugging mission-critical ROS2 programs.
Let’s go, shall we?
Getting Ready for the Action
This post is 99.99% practical, so you need a functional ROS2 installation to follow along. We will use one of the awesome Docker images of ROS2 provided by the Open Source Robotics Foundation (OSRF), to keep it easy for everyone and make sure we can tinker with ROS2 without committing too much time to installing it (yet). Choose any of the following options:
Spin a free ROS development environment at ROSDS. With this, you skip all installations; just a few clicks and you will have access a ROS-ready computer within your browser. This is the recommended option and the one used for this post. In this option, a “open a terminal” means you should pick the Shell app from the ROSDS Tools menu.
You have docker installed on your local development machine. Please note that a ROS2 installation is not necessary since we’re using a docker image.
Open a terminal on your machine and spin up the ROS2 docker image:
user:~$ docker run -it osrf/ros2:nightly
Unable to find image 'osrf/ros2:nightly' locally
nightly: Pulling from osrf/ros2
...
root@759719bcb5a5:/#
Important: if the image tag specified is not available, please check out the available tags at https://hub.docker.com/r/osrf/ros2/tags.
Now open three other terminals and run the same command above. We’ll need to work with them in parallel. So we should have four terminals now, Terminals 1 – 4.
ROS2 topics – how you can work (or play) with them
Now we are getting down to it; let’s see how we can work or play with ROS2 topics.
See a list of commands available to work with ROS2
First, we want to see the operations we can do on ROS2 topics. Depending on the version of ROS2 in the image you are able to spin, you might see a slightly different output. The version used in this post is ROS2 Crystal, but the one in the video is ROS2 Bouncy. That said, we’ll be looking at basically the same operations regardless of the RO2 version.
To see what commands you can run against ROS2 topics, type in the command shown below.
In Terminal 1:
root@759719bcb5a5:/# ros2 topic
usage: ros2 topic [-h] [--include-hidden-topics]
Call `ros2 topic <command> -h` for more detailed usage. ...
Various topic related sub-commands
optional arguments:
-h, --help show this help message and exit
--include-hidden-topics
Consider hidden topics as well
Commands:
delay Display delay of topic from timestamp in header
echo Output messages from a topic
hz Print the average publishing rate to screen
info Print information about a topic
list Output a list of available topics
pub Publish a message to a topic
Call `ros2 topic <command> -h` for more detailed usage.
There you go! Now let’s try some of these commands.
See a list of available topics
Following the output of the command we ran above, let’s get this list of available topics.
In Terminal 1:
root@759719bcb5a5:/# ros2 topic list
/parameter_events
/rosout
ROS2 created the above topics by default; we didn’t create them. But that’ll change in a bit.
⇒ Take home: run the command ros2 topic list -h to see more options for this command, and try out some.
Create a topic and publish to it at the same time
Now we’ll create and publish to a new topic, /barbarians: run the command below.
Basically, to publish to a topic, you do ros2 topic pub [topic_name] [message_type] [message_in_right_structure]. For our case above:
Our desired topic name was /barbarians
The message type I wanted to publish is a String, so I just used the inbuilt message type std_msgs/String.You can get a list of inbuilt messages with ros2 msg list.
I “composed” the message according to the structure dictated by std_msgs/String. I got the structure of this message type with:
root@dd56efdf3a28:/# ros2 msg show std_msgs/String
string data
And that’s it!
Also, by publishing to a topic that did not exist before, we got ROS2 to automatically create it. Let’s confirm that.
In Terminal 2:
root@ed2f3e495885:/# ros2 topic list
/barbarians
/parameter_events
/rosout
root@ed2f3e495885:/#
We could also publish to an existing topic, and we’ll see that shortly.
⇒ Take home: run the command ros2 topic pub -h to see more options for this command, and try out some.
So we see that we have 1 node publishing to the topic, and zero nodes subscribed to it. Since it’s a “barbaric” topic, let’s have another node publishing to it:
We have seen how to use four different commands related to ROS2 topics: list, pub, info, echo. You may have seen that we didn’t cover every command listed. What to do with the ones we didn’t cover? Try them out on your own, of course ;).
The video version of this post
I hope you learned something useful from this post. If you prefer to watch the video version of this post, we have you covered. Please find the video below.
Feedback
Did you like this video? Whatever the case, please leave us some feedback in 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.
In this post, we’ll see what a ROS(2) node is, and the similarities and differences between ROS1 and ROS2 nodes. We’ll do this using both practicals and theory, practicals first!
Let’s go!
Setup for the practicals
I believe passionate engineers like to get their hands dirty as much as they like to have solid theoretical foundations. And, since I get to decide here ?, we’ll start with the latter.
Now, the required setup for practicals (installation of ROS and other packages) can take a lot of time but, thankfully, we have an easy way out – ROSDS. With this online tool, you will have access to ROS-ready computers (both ROS1 and ROS2) within your browser in a few seconds. If you don’t have one already, you can create a free account here.
PS:
When you create a project (ROSject) on ROSDS, be sure to select the Ubuntu 16.04 + ROS Kinetic + Gazebo 7 configuration.
If you have access to local installations of ROS1 and ROS2, and you don’t want to embrace the online revolution yet, then you can also use your local installations.
When I say ‘terminal’ in this post, that means picking the Shell app from the ROSDSTools menu or opening a terminal on your local PC.
Practicals – ROS nodes in action
For a practical-oriented topic, we’ve had enough theory already; let’s get down to it and see ROS nodes in action! Fire up a terminal and run the command that displays a list of nodes in ROS1. Your output might be different, but you should have a list of items like this:
user:~$ rosnode list
/rosapi
/rosbridge_websocket
/rosout
/web_video_server
Take note of the items listed above and then run the following command in another terminal:
To see the turtle on ROSDS, pick the Graphical Tools app from the Tools menu to see your cute turtle:
Well done! Now go back to the previous terminal and re-run the command that displays a list of nodes in ROS1. Now you should see an extra node (“/turtlesim”) in your list.
user:~$ rosnode list
/rosapi
/rosbridge_websocket
/rosout
/turtlesim
/web_video_server
So far so good, but all that is ROS1, so now let’s #goROS2! In another terminal, run the command shown. That should bring up a ROS2-ready docker machine, waiting for your command:
user:~$ docker run -it osrf/ros2:bouncy-desktop
Unable to find image 'osrf/ros2:bouncy-desktop' locally
bouncy-desktop: Pulling from osrf/ros2
...
root@43a5e0d0c74c:/#
As we also need two terminals for the ROS2 “tinkertoons”, spin up a second terminal and run the same command as above. In the first ROS2 terminal run the following commands that display the list of nodes in ROS2. Observe the outputs (the -a switch shows hidden nodes).
root@43a5e0d0c74c:/# ros2 node list
root@43a5e0d0c74c:/# ros2 node list -a
_ros2cli_node_daemon_0
Basically, no user-created node is running now. Let’s change that: in the second ROS2 terminal, run:
Now get back to the first ROS2 terminal and rerun the last command. You should see an addition node (talker) displayed, thanks to the talker(tive) program we just ran:
root@43a5e0d0c74c:/# ros2 node list -a
_ros2cli_node_daemon_0
talker
And we are all done for the practicals! But what’s the catch? At this point, we could use some theory. Next!
So, what is a ROS(2) node?
Let’s hear from the horse’s mouth:
A node is a process that performs computation. – http://wiki.ros.org/Nodes
A node really isn’t much more than an executable file within a ROS package. ROS nodes use a ROS client library to communicate with other nodes. – http://wiki.ros.org/ROS/Tutorials/UnderstandingNodes
As we saw from the practicals, the turtlesim_node and talkerexecutables displayed a turtle and some text on-screen, respectively, by performing computations and communicating with other nodes. For one, they both communicated with nodes responsible for displaying output. So, in both ROS1 and ROS2, a node is essentially the same thing.
Done. Now you know what a ROS(2) node is. We’ll examine the similarities and different between ROS1 and ROS2 nodes in the next section.
ROS1 and ROS2 nodes compared
From the previous sections, we’ve already seen that ROS1 and ROS2 nodes are essentially the same. You may also have seen from the practical session that the commands for running and displaying a list of nodes in ROS1 and ROS2 are similar, even if they are not the same.
In this section, we’ll look briefly at some fundamental similarities and differences between ROS1 and ROS2 nodes. The table below summarizes these. Black text represents similarities while red text represents differences.
ROS2 node
ROS1 node
What is it?
An executable using ROS2 to communicate with other nodes
An executable using ROS1 to communicate with other nodes
(De)advertises itself and discovers other nodes using…
A distributed discovery process (which does not depend on a single node)
The ROS1 Master (a single node)
After discovery, communicates with other nodes…
Peer to peer
Peer to peer
Uses these client libraries (among others)
rclcpp = C++ client library rclpy = Python client library
roscpp = C++ client library rospy = Python client library
And that’s it!
Summary
ROS nodes are the executables that make things happen in a ROS system, and they are essentially the same for both ROS1 and ROS2, even if there are some differences. If you’re already familiar with ROS1, you can hit the ground running with ROS2, with just a few differences to master.
Video Version
If you prefer see the audio-visual version of this post, we’ve got you covered. Just click to watch the video below.
Feedback
Did you like this post? Whatever the case, please leave a comment in 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 on the comments area and we will do a post or video about it.
Hello ROS developers! In this post, we’ll find out what happened to roscore in ROS2 and how similar functions of the ROS1 master were implemented in ROS2. Sit back and get ready to have some fun!
In order to approach this theory-like topic with as much practical as possible, this post has two main sections:
Some tinkering with a ROS2 installation. This is the real fun part: trying to find roscore in ROS2.
Some theory. As this might be a little boring, so we’ll keep it short and sweet!
Section 1: Trying to find roscore in a ROS2 installation
Since ROS2 arrived in town, there has been a rumour going round that “roscore is missing”! But don’t take anyone’s word for it; let’s find out for ourselves. Shall we?
We need a functional ROS2 installation for this. We will use one of the awesome Docker images of ROS2 provided by the Open Source Robotics Foundation (OSRF), to keep it easy for everyone and make sure we can tinker with ROS2 without committing too much time to installing it (yet). Choose any of the following options:
Spin a free ROS development environment at ROSDS. With this, you skip all installations; just a few clicks and you will have access a ROS-ready computer within your browser. This is the recommended option.
You have docker installed on your local development machine. Please note that a ROS2 installation is not necessary since we’re using a docker image, but if you have ROS2 installed already you may choose to use it instead of the docker image.
We are using option 1 for this post. It’s about time we skipped local installations and start developing within our browsers, but I digress.
Now is time for action: fire up a terminal on your machine and get ready to shoot some commands at it! Our first task is spinning up the ROS2 docker installation:
user:~$ docker run -it osrf/ros2:bouncy-ros-core
Unable to find image 'osrf/ros2:bouncy-ros-core' locally
...
root@d213f10c91f9:/#
You should get something like the above, ending with a prompt that grants access to the ROS2 docker machine. Now type the following commands and study the output.
root@d213f10c91f9:/# roscore
bash: roscore: command not found
root@d213f10c91f9:/# ros2core
bash: ros2core: command not found
root@d213f10c91f9:/# ros2 core
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...
ros2: error: argument Call `ros2 <command> -h` for more detailed usage.: invalid choice: 'core' (choose from 'daemon', 'extension_points', 'extensions', 'launch', 'lifecycle', 'msg', 'node', 'param', 'pkg', 'run', 'service', 'srv', 'topic')
root@d213f10c91f9:/# ros2 master
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...
ros2: error: argument Call `ros2 <command> -h` for more detailed usage.: invalid choice: 'master' (choose from 'daemon', 'extension_points', 'extensions', 'launch', 'lifecycle', 'msg', 'node', 'param', 'pkg', 'run', 'service', 'srv', 'topic')
You may want to try other commands to find roscore in ROS2, but I’m done here. ?
Conclusion:could not find roscore in ROS2. The rumour appears true after all.
But what happened to roscore – it was the “core” of ROS, so now what? Let’s find out in the next section.
Section 2: ROS2 – ending the ROS “slave trade”
“Hey, are you saying the people of ROS engaged in slave trade?!” Of course not! It’s just a fun way of describing how ROS1 worked. Relieved? ?
So let’s break the news here: roscore is dead in ROS2. It was killed, buried for good, and replaced by a better system. Here are some highlights:
In ROS1, roscore is the master node. Other nodes depend on it. But in ROS2, no more “master” (and “slaves”). Exit roscore. Enter DDS (Data Distribution Service).
In ROS1, roscore drives a client/server (or slave/master) architecture. For ROS2, DDS drives a distributed architecture.
Peer-to-peer communication (not master-slave :D). This sounds more democratic, doesn’t it?
No more single point of failure (fault tolerance). roscore can hold other nodes to ransom in ROS1, but no node can do that in ROS2.
Configurable Quality of Service (QoS). ROS1 provides a “best effort” service, but in ROS2 we can set the QoS required for a specific use case.
ROS2 also uses DDS for serialization and transport, in addition to “discovery”, which was the main function of roscore in ROS1.
In short, in ROS2, DDS is the new Sherrif in town; roscore has been fired!
Wrapping up
You still have your terminal open? Great, let’s see an example of how one of the core functions performed by roscore is ROS1 is now done in ROS2:
root@d213f10c91f9:/# ros2 node list -a
_ros2cli_node_daemon_0
The command above “finds existing nodes, including hidden ones”. In ROS1, roscore, which was a single node, used to rule this space. But no more in ROS2!
Video
Do you prefer to see this post in “audio and video” instead of “black and white”? If yes, the video below is for you. Enjoy!
We want to hear you!
Did you like this post? Whatever the case, please leave a comment in the comments section below, so we can interact and learn from each other.
If you want to learn about other ROS topics, then please let us know on the comments area and we will do a post or video about it.