Installing ROS on a Raspberry Pi 4 is difficult because, though the ubuntu images seem good to go, I experienced unknown problems setting up a headless install of ubuntu 18. Ubuntu 20.04 worked eventually, but initial startup took over 5 minutes for the device to show up on my network. Plus I was interested in installing ros melodic, which is built for ubuntu 18. So here are the steps I used. I installed raspbian buster and compiled ros from scratch.
Download the Raspberry Pi Imager: https://www.raspberrypi.org/downloads/
Alternate imagers:
Download an Image: I used the lite version and then added packages as needed
Install raspbian using the instructions for a headless install located here: https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-headless-raspberry-pi
Alternate instructions:
Make sure you follow the instructions below for setting up wireless & ssh
Other information:
Find the Pi on your network (in linux). You can use a virtual machine to do this
sudo apt install -y net-tools nmap
arp -na
nmap -sn 10.0.0.*
Note the IP address
log on using putty
Define a static IP address (derived from here)
edit dhcpcd.conf
sudo nano /etc/dhcpcd.conf
uncomment out lines for static ip/subnet and router and define them to what you need.
Restart
sudo reboot
Alternate Instructions(I didn’t use):
install xrdp (using this tutorial):
install gedit
sudo apt install -y gedit
Install ROS using this tutorial
Alternate Instructions(didn’t use):
change password for user pi
passwd
Set up camera using this tutorial
Note: This section may be outdated. Please see this section about libcamera
1. install other packages for viewing and programming
```
sudo apt install -y gpicview vlc thonny
pip3 install picamera
```
1. After installing picamera there may be a warning. use the next lines to fix:
```
echo "export PATH=\$PATH:/home/pi/.local/bin" >> ~/.bashrc
source ~/.bashrc
```
install opencv using this tutorial
Notes:
sudo pip3 install
instead of pip install
to install in python3install other necessary packages
sudo apt install -y libilmbase-dev libopenexr-dev libgstreamer1.0-dev
clone raspicam node
git clone https://github.com/idealabasu/raspicam_node.git
not sure these packages are needed:
sudo apt install -y python3-catkin-pkg
sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo apt install -y python3-empy
update ros install with joystick and compressed image transport packages, following instructions here:
and using
rosinstall_generator ros_comm joystick_drivers compressed_image_transport camera_info_manager dynamic_reconfigure diagnostic_updater cv_bridge --rosdistro melodic --deps --wet-only --tar > melodic-custom_ros.rosinstall
Add idealab ros workspace: (see other tutorial)
checkout rpi4 branch
git checkout rpi4
(Mental Note) cloned and copied raspicam_node into code_idealab_ros/src (don’t do, already done)
Make projects
cd ~/code/code_idealab_ros
catkin_make
optional: change ros master uri to remote. Only necessary if you want the raspberry pi to work within a bigger ros network. Modify ip addresses to match desired network topology
echo "export MY_MASTER_IP=10.0.0.201" >> .bashrc
echo "export MY_IP=10.0.0.200" >> .bashrc
echo "export ROS_MASTER_URI=http://\$MY_MASTER_IP:11311" >> .bashrc
echo "export ROS_IP=\$MY_IP" >> .bashrc
source .bashrc
Run Roslaunchp (modified from here
#roslaunch raspicam_node camerav2_1280x720.launch
#roslaunch raspicam_node camerav2_410x308_30fps.launch
roslaunch raspicam_node dan_cam1.launch
on the host:
in one terminal:
roscore
in a second terminal:
rosrun rqt_image_view rqt_image_view