Learn to build your own autonomous robot using ROS
This is going to be a series of tutorials where we’ll learn how to build a completely autonomous robot.
Even the beginners and robot hobbyist can go through this, because this tutorials are made considering you are a beginner to ROS.
Flow of this tutorial would be:
- ROS installation
- Make a urdf for two wheeled differential drive
- Moving the robot using your keyboard
- Configuring and using SLAM for mapping the given environment
- configuring and using move_base and AMCl for autonomous navigation and path planning by avoiding obstacles
These are the things that are going to be covered in this series, and these are the basic things you need for an autonomous mobile robot.
You’ll find tutorials for all of those in ros official site and on many other tutorial sites and YouTube videos. But this tutorial is different from all those you find on the internet because there’s not much tutorials or resources where you can find how to build an autonomous robot from the basics. There will be parts of this explained in different tutorials. In this we will learn how to integrate all those and build a fully functional autonomous robot.
So, Starting from start(obviously) first we will learn how to install ROS on our computer. You can skip this part and got to Next if you already have ROS installed.
We are going to ROS melodic and Ubuntu 18.04 for this tutorial.
Follow this link for official tutorial on how to install ROS. you can follow the link or copy paste the commands mentioned below(these commands are copied from ros official installation guide)
Setup your computer to accept software from packages.ros.org.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Set up your keys
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
First, make sure your Debian package index is up-to-date:
sudo apt update
we will install full desktop version
sudo apt install ros-melodic-desktop-full
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrcsource /opt/ros/melodic/setup.bash
Dependencies for building packages
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdepsudo rosdep init
This should successfully ROS on your machine, now we have create a workspace where we can keep all our ros packages.
Follow this link for creating a work space. or copy paste the given commands into your terminal(and even this is copied from the official ros catkin tutorials)
Let’s create and build a catkin workspace:
mkdir -p ~/catkin_ws/src
To make sure your workspace is properly overlayed by the setup script, make sure ROS_PACKAGE_PATH environment variable includes the directory you’re in.
The above command should return
Phew…..lot of commands! right, but it’s gonna be worth!!!!!!!!
We have now successfully installed ROS and created a workspace to work in. Now we are ready to go, let’s build our cool autonomous robot.
Now let’s begin with creating our own robot. For that we need to create a package. Software in ROS is organized in package. A package might contain ROS nodes, ROS msgs, ROS libraries. The goal of these package it to provide this useful functionality in an easy-to-consume manner so that software can be easily reused.
Packages are easy to create by hand or with tools like catkin_create_pkg. For creating a ROS package follow the commands below or (ref.)
Now use the catkin_create_pkg script to create a new package called ‘sk’ which depends on std_msgs, roscpp, and rospy:
catkin_create_pkg sk std_msgs rospy roscpp
So now we have ROS installed, and we have setup our catkin workspace and also have a ROS pkg where we can put all ROS files.
We will continue this, till then best of luck exploring the ROS you just installed. We can do wonders with this.
You can find the rest of the stories in this series here (I’ll put a link as soon as I create next tutorial)