The Easiest way to install ROS Melodic on RaspberryPi 4

The Easiest way to install ROS Melodic on RaspberryPi 4

Install ROS Melodic on Raspberry Pi 4 in a hassle-free way. But, before that make sure you have the raspberry pi OS up and ready, connected to the internet. Ok then, let’s GET STARTED!

Let’s start by setting up the repositories and installing the necessary dependencies :

  • Setting up the repositories
sudo sh -c ‘echo “deb https://packages.ros.org/ros/ubuntu $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’

dd the KEY

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  • Update && Upgrade
sudo apt-get update && sudo apt-get upgrade
  • Installing the required dependence
sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential  cmake
  • Then initialize rosdep and update it
sudo rosdep init 

sudo rosdep update

As we need to install ROS from Source we shall create a separate WorkSpace for it:

mkdir ~/ros_catkin_ws 

cd ~/ros_catkin_ws
  • Now, we shall install ROS Melodic
rosinstall_generator desktop --rosdistro melodic --deps --wet-only --tar > melodic-desktop-wet.rosinstall
  • This command will take some time depending on your Internet speed as its downloading all the core ROS package’s
wstool init -j8 src melodic-desktop-wet.rosinstall
  • [OPTIONAL] Run this command if the ‘wstool init’ is failed or interrupted by any cause
wstool update -j 4 -t src

Next, we use the rosdep tool for installing all the rest of the dependencies:

rosdep update 

cd ~/ros_catkin_ws 

rosdep install --from-paths src --ignore-src --rosdistro melodic -y

Finally, Build and Source the Installation

  • This command will take a lot of time so grab some snacks while it is downloading and resolving the dependencies
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/melodic -j2

Now ROS Melodic should be installed on your Raspberry Pi 4. We’ll source the new installation with the following command:

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

So it's Done! Try launching roscore to check if everything is up and running

Setting things up for further use :

  • Now, we shall create a separate workspace where we can install pkg’s and get started with using ROS Melodic
mkdir -p ~/catkin_ws/src

cd ~/catkin_ws

catkin_make

echo "source $HOME/catkin_ws/devel/setup.bash" >> ~/.bashrc

Now, you’re all set to use ROS Melodic with Pi 4. You can now install packages in your src directory and get started!

Engr. Muhammad Ahmad

President GSS GIKI | M.S. Computer Eng. GA | Robotics & IoT Innovator | FPGA Optimization Expert

2 年

can you share the OS on which these commands can work as I tried for ubuntu buster, mate18.04 ...

回复
Bart van der Haagen

Engineering specialst / ROS developer / Co-founder DataBot-Labs / Rebel Robotics

3 年

Isn’t it so that when building isolated you have to source the isolated/setup.bash?

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了