Start by configuring your package manager to pull software from ROS’s official repositories. Launch a terminal and run this to set up sources.list:
APT_SOURCES_PATH=/etc/apt/sources.list.d/ros-latest.list
OS_CODENAME=$(lsb_release -cs)
echo "deb http://packages.ros.org/ros/ubuntu $OS_CODENAME main" | sudo tee $APT_SOURCES_PATH
Next, authenticate incoming packages by adding the official ROS GPG key:
wget -qO - https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
Udpate your local package index before installing any components:
sudo apt update
For full ROS functionality including core libraries, visualization tools, simulators, and robot-specific packages, install the Desktop-Full variant:
sudo apt install ros-melodic-desktop-full
This installation may take several minutes dependign on your network bandwidth.
After package installation completes, initialize and update rosdep, the tool that resolves system-level dependencies for ROS packages:
sudo rosdep init
rosdep update
To make ROS environment variables load automatically with every new bash session, append the setup script to your .bashrc file and source it immediately:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
Install additional ROS utility tools for workspace management and package handling:
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
Verify the instalation by checking the active ROS distribution:
rosversion -d
If successful, the output will display "melodic".