Alright, be honest. We all were like, “ROS sounds cool.” Let me install it and see how it works, plus how hard can installing it be(famous last words). Then you search up “ROS install Ubuntu”, and you find 50 guides all saying something different. Some require 4 hours of compiling while others simply use ATP. What is the deal with all of this?
Now how this one works is simple. ROS only supports LTS versions of Ubuntu. That is 20.04, 18.04, 16.04, 14.04, etc. Now for each LTS version, there is a version of ROS. For 20.04, it is Noetic Ninjemys, for 18.04, it was Melodic Morenia, etc. You must be wondering, “Can you communicate between other versions of ROS?” Absolutely! They will communicate flawlessly with each other. They communicate over an IP Protocol that is common and reverse compatible. It is a little difficult to communicate between ROS1 and ROS2 since you must use ros_bridge. But that’s for another day!
For 20.04 LTS
Now, unless you have some crazy dependency, the latest ROS1 version is the way to go for beginners. The latest as of December 12, 2021, is ROS Noetic. Installing previous versions will be a little harder. 1 more thing, I will show installation on Ubuntu 20.04 but other operating systems like Arch, Windows, and Debian are available. Here is how you can install Noetic Ninjemys:
Link to other OS installations: http://wiki.ros.org/noetic/Installation
(The # means comment. Don’t run that part.)
1.1 (Usually done by default) Make sure "restricted," "universe," and "multiverse" are enabled. Check https://help.ubuntu.com/community/Repositories/Ubuntu 2.1 sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' # Add their repository to your machine 3.1 sudo apt install curl # Usually comes preinstalled 3.2 curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - # Add repository key 4.1 sudo apt update # Update repository listing 4.2 sudo apt install ros-noetic-desktop-full # Contains all essential packages like perception and simulation. Perfect for beginers. Others are "ros-noetic-ros-base" which is the bare-bones. The middle version is "ros-noetic-desktop" which had some debug tools but none of the perception and simulation packages. You must source the ROS environment everytime so you can run "source /opt/ros/noetic/setup.bash" but if you don't want to run it everytime you spawn a terminal: 5.1 echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc 5.2 Close all terminal instances and reopen terminal.Update ROS Core Dependencies: 6.1 sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential # Install tools 6.2 sudo apt install python3-rosdep # Install rosdep(tool) 6.3 sudo rosdep init # Initialize rosdep 6.4 rosdep update # Update rosdep
There is a separate way where you can install and compile all the ~150 packages from source. This is for the professional developers or the confused beginners(get it?). Please let me know in the comments if you want me to make a separate article on this!
Alright, the installation is finally complete. Not so fast! We still have to make the development environment. Don’t worry, it is SUPER easy!
1 mkdir WORKSPACE_NAME # Go to the place you want your code, environment, and packages to reside. Replace WORKSPACE with a name of your choice. 2 cd WORKSPACE_NAME # Go into directory 3 mkdir src # DO NOT change this name or it won't compile. Also, DO NOT cd into it 4 catkin_make # compile your blank project!
Finally, the moment you have all been waiting for…your very first ROS1 command!
Please note, that this article shows you how to set up ROS on 1 computer. Meaning that the Master and Nodes are on the same computer. TO communicate across many computers, there is a painful setup procedure that I won’t make you endure just yet(brace yourself for the future).
ROS1(not ROS2) works on the following system:
ROS Core manages the master node. It manages all the communication happening in the ROS network. You cannot run any ROS nodes without it.
roscore # Spawns a ROS master node.
The first thing you are going to do is make a little turtle draw things on a screen using your arrows.
If you are short on time, install it using APT:
sudo apt-get install ros-$(rosversion -d)-turtlesim # install the turtle sim package
If you want to learn ROS properly, do this:
1. cd WORKSPACE_NAME/src # Go to the source directory 2. sudo apt install git # Install git if you don't have it. 3. git clone https://github.com/ros/ros_tutorials.git # Download the turtle_sim and lesson packages 4. cd .. # Go to main directory 5. catkin_make # Compile the project 6. source devel/setup.bash # Re-Source compiled files.
Now, let us run it! Make sure roscore is running on a different terminal
1. rosrun turtlesim turtlesim_node # command node script
This should show a box where you can move a turtle around. But more importantly, is the things happening behind the scene.
What do you see? Can you find our node?
Where is the turtle location topic? Did you see it?
rostopic <TURTLE_POSE_TOPIC_NAME> echo
Replace the first argument with the topic name you previously found. Can you see the coordinates move as the turtle runs around(or should I say crawl around)?
cmd_vel: This is what we call a Twist message. It contains target velocity values for 3 axes of translation and 3 axes of rotation. You can imagine how useful this is for a remote-controlled robot.
Command structure: Did you notice the pattern in the commands. It is the object you are accessing(rosnode, rosservice, rostopic, rosrun, etc), then the action you want to perform(echo, list, hz, etc), then the arguments. We will dive into the depth of these commands in another article.