Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pvandervelde/328ae4e33962a7a40c8a7975565af25a to your computer and use it in GitHub Desktop.
Save pvandervelde/328ae4e33962a7a40c8a7975565af25a to your computer and use it in GitHub Desktop.
Steps to create a Raspberry Pi 4 image with ROS noetic and OpenCV

Ros on Raspberry Pi 4 - OS

Install git

sudo apt-get install git

Install zsh

NOTE: Picked zsh because it has better highlighting and completion, but also catkin generates zsh scripts.

Install zsh:

sudo apt-get install zsh

Make zsh default

chsh -s /bin/zsh

Install oh-my-zsh

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Install autosuggestions

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

Install highlighting

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Update the plugins line in the .zshrc file

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

Install Ros

following: https://varhowto.com/install-ros-noetic-raspberry-pi-4/

Add the apt repository

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu buster main" > /etc/apt/sources.list.d/ros-noetic.list'

add the key

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

Update

sudo apt update

Install dependencies

sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake

run rosdep

sudo rosdep init
rosdep update

make a catkin workspace

mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws

Use the ROS install generator to create the right install

rosinstall_generator robot navigation slam_gmapping laser_pipeline perception --rosdistro noetic --deps --wet-only --tar > noetic-ros_comm-wet.rosinstall
wstool init src noetic-ros_comm-wet.rosinstall
rosdep install -y --from-paths src --ignore-src --rosdistro noetic -r --os=debian:buster

increase swap from 100Mb to 1Gb

sudo dphys-swapfile swapoff
sudoedit /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon

Build all the ROS things and install them in /opt/ros/noetic

sudo src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/noetic -j1 -DPYTHON_EXECUTABLE=/usr/bin/python3

install opencv

Install dependencies - For images

sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev

Install dependencies - For video

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev

More dependencies

sudo apt-get install libgtk2.0-dev

Optimization libraries

sudo apt-get install libatlas-base-dev gfortran

Install pip3

sudo apt-get install python3-pip

Install numpy

pip install numpy

get the image backup

wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
sudo chmod +x pishrink.sh
sudo mv pishrink.sh /usr/local/bin

sudo mount /dev/sda1 /media/stick

sudo dd if=/dev/mmcblk0 of=/media/stick/rpi4-ros-noetic-opencv.img bs=1M

cd /media/stick

sudo pishrink.sh -z rpi4-ros-noetic-opencv.img
@dmalawey
Copy link

This is gonna be great. How long do you estimate it takes to run through the installs?

@pvandervelde
Copy link
Author

Several hours. I think it took me about 3ish hours to get ROS installed. There's a lot of packages and the Pi isn't that fast. All the other stuff was pretty quick. Making the backup depends on the size of the card you have. You'll need at least a 16Gb card because my install is about 9Gb in size.

@pvandervelde
Copy link
Author

@dmalawey If you want the image that came out of this experiment I have it stored somewhere. I noticed that I missed some of the python modules for scuttle itself so I'm going to add those at some point.

@pvandervelde
Copy link
Author

Notes to self:

Also to install are:

@dmalawey
Copy link

dmalawey commented Feb 8, 2022

Hey Patrick,

You'll need at least a 16Gb card

We always include a 32Gb card with SCUTTLE kits - is yours SP brand or Samsung? Just checking

As for the image - I would love to get the image. But I'm also not ready to try it for a couple of weeks so I can wait for you to add python modules that you mentioned.

@pvandervelde
Copy link
Author

More notes to self:

  • If you want to have the joystick work, you'll also need the ROS joy package. And for that you'll need some extra headers

    sudo apt-get install libspnav-dev

@pvandervelde
Copy link
Author

We can load all the scuttle ros code on the card the first time around if we create the ros workspace outside the user folder, e.g. if we create a /ros/ws directory in which we put all the scuttle ros code. That way we can put all the code we need in the image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment