**This post represents a slow way to compile ROS. In a new post I show how to crosscompile ROS.”
This post should guide you through the process of compiling ROS on a virtualized Raspberry PI Zero.
Setup virtual Raspberry PI Zero with QEMU
Start by checking out the repo of a custom kernel for qemu:
Next download the latest Raspbian Image. It is advised to create a qemu image of the extracted image:
You can resize the image by running
qemu-img convert -f raw -O qcow2 2018-11-13-raspbian-stretch-lite.img raspbian-stretch-lite.qcow.
This will not resize the root partition! You’ll have to do this later by using
raspi-config or doing it manually.
That’s all! Now you can start the virtual PI by running:
Please note that you can not use more than 256MB of RAM and only one core.
Login with pi:raspberry and you should have a working PI with access to the internet like the host.
To install ROS you basically have to follow this guide. A TLDR version is the following:
sudo apt install python-pip
sudo pip install -U catkin_pkg
Note: This is not recommended because packages installed by pip override those from apt. In this case we need to do this because the version provided by apt is not working
sudo apt install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential
sudo rosdep init
rosinstall_generator ros_comm --rosdistro melodic --deps --tar > melodic-ros_comm.rosinstall
If you want a full install replace
rosdep install --from-paths src --ignore-src --rosdistro melodic -r --os=debian:stretch -y(
debian:strechis required because we are installing on Raspbian)
In my case this installed the following dependencies: ???
./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -j1
You can try to compile with
-j2 (More does not make sense), but you maybe will get an out of memory error because the PI has
only 256MB of RAM. Here is an example of the memory consumption ;)
You can active the ROS environment with
source ~/ros_catkin_ws/install_isolated/setup.bash. You
can also add this to your
.bashrc if you like.
The next task for me is to get the data from the qemu image to copy it to the real hardware.