└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | The Raspberry Pi Zero is a small, affordable, and powerfull single board computer. With ROS Kinetic, we can use this as a convenient I/O expander and remote camera, integrated with the rest of our robot via the Rasbperry Pi Zero USB Network Gadget. The Raspberry Pi camera is hardware accelerated, enabling efficient VGA video streaming with the ROS Camera interfaces. 3 | 4 | The following steps will enable the compilation and installation of ROS Kinetic on a Raspberry Pi Zero, running Raspian Jessie Lite. 5 | 6 | Many thanks for the helpful documentation sets and Wiki instructions referenced below. They provided several missing steps and gaps I was missing. 7 | 8 | # Installation 9 | 10 | ## Installing Raspbian Jessie on Rasberry Pi Zero 11 | To begin, download the last version of the Raspbian OS from [this link](http://www.raspberrypi.org/downloads/) 12 | 13 | In our case we downloaded the *Jessie Lite* version at https://downloads.raspberrypi.org/raspbian_lite_latest 14 | 15 | Plug the Rasp SD card in your Linux based PC and copy the image. 16 | ```bash 17 | $ sudo umount /dev/sdb 18 | $ sudo dd bs=1M if=2016-11-25-jessie-lite.img of=/dev/sdb 19 | ``` 20 | **NOTE:** you can see other methods in http://www.raspberrypi.org/documentation/installation/installing-images/README.md 21 | 22 | ### First boot on your Raspberry Pi Zero 23 | Once you are connecting to your Raspberry you must prepare it. 24 | ```bash 25 | $ sudo raspi-config 26 | ``` 27 | You could: 28 | * Expand filesystem. 29 | * Change your password. 30 | * Set up language and regional settion 31 | * ... 32 | 33 | ### Increase Swap Space 34 | In order to ensure there is enough swap space to compile ROS, make the following modificationb below, then reboot the Raspberry Pi Zero so the change takes affect. 35 | 36 | ```bash 37 | sudo vi /etc/dphys-swapfile 38 | ``` 39 | and set the variable CONF_SWAPSIZE=1024 40 | 41 | ## ROS Kinetic on Raspberry Pi Zero 42 | ### Setup ROS Repositories 43 | While we are going to build ROS Kinetic from source on our Raspberry Pi Zero, the ROS repository for Jessie contains many architectural independent packages we'll need to run ROS. 44 | ```bash 45 | $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu jessie main" > /etc/apt/sources.list.d/ros-latest.list' 46 | $ wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add - 47 | ``` 48 | Now update the Debian package index with the new repository: 49 | ```bash 50 | $ sudo apt-get update 51 | $ sudo apt-get upgrade 52 | ``` 53 | 54 | ### ROS bootstrap dependencies 55 | ```bash 56 | $ sudo apt-get install python-setuptools git checkinstall cmake libboost-system-dev libboost-thread-dev 57 | $ sudo easy_install pip 58 | $ sudo pip install -U rosdep rosinstall_generator wstool rosinstall 59 | ``` 60 | 61 | ### Initializing rosdep 62 | ```bash 63 | $ sudo rosdep init 64 | $ rosdep update 65 | ``` 66 | 67 | ### Create a catkin Workspace 68 | 69 | In order to build the core packages, you will need a catkin workspace. 70 | ```bash 71 | $ mkdir ~/ros_catkin_ws 72 | $ cd ~/ros_catkin_ws 73 | ``` 74 | Next we will want to fetch the core packages so we can build them. We will use wstool for this. 75 | We will install ROS-Comm (ROS package, build, and communication libraries without GUI tools) and additional packages used for the camera support: 76 | ```bash 77 | $ rosinstall_generator ros_comm diagnostics bond_core dynamic_reconfigure nodelet_core rosserial class_loader image_common vision_opencv image_transport_plugins pluginlib --rosdistro kinetic --deps --wet-only --exclude roslisp --tar > kinetic-robot-wet.rosinstall 78 | $ wstool init -j8 src kinetic-robot-wet.rosinstall 79 | ``` 80 | **NOTE:** If wstool init fails or is interrupted, you can resume the download by running: 81 | ``` 82 | $ wstool update -j8 -t src 83 | ``` 84 | ### libconsole-bridge-dev 85 | We need install libconsole-bridge-dev for ROS_Comm, as it is not yet available in the Jessie repositories and must be built manually. 86 | The packages can be built from source in a new directory (Also install checkinstall and cmake): 87 | ```bash 88 | $ mkdir ~/ros_catkin_ws/external_src 89 | $ cd ~/ros_catkin_ws/external_src 90 | $ git clone https://github.com/ros/console_bridge.git 91 | $ cd console_bridge 92 | $ cmake . 93 | $ sudo checkinstall make install 94 | ``` 95 | When check-install asks for any changes, the name (2) needs to change from "console-bridge" to "libconsole-bridge-dev" otherwise the rosdep install wont find it. 96 | 97 | ### Resolving Dependencies with rosdep 98 | The remaining dependencies should be resolved by running rosdep: 99 | 100 | ```bash 101 | $ cd ~/ros_catkin_ws 102 | $ rosdep install --from-paths src --ignore-src --rosdistro kinetic -y -r --os=debian:jessie 103 | ``` 104 | 105 | ### Building the catkin Workspace 106 | Once you have completed downloading the packages and have resolved the dependencies, you are ready to build the catkin packages. 107 | 108 | **NOTE:** Building time takes about 9 hours on a Raspberry Pi Zero. Before invoking the build step, you may be interesting in using a program like screen to close your ssh connection and allow the build on the Raspberry Pi to continue uninterrupted. 109 | http://raspi.tv/2012/using-screen-with-raspberry-pi-to-avoid-leaving-ssh-sessions-open 110 | 111 | Invoke catkin_make_isolated: 112 | ```bash 113 | $ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic 114 | ``` 115 | Now ROS should be installed! Remember to source the new installation: 116 | ```bash 117 | $ echo 'source /opt/ros/kinetic/setup.bash' >> ~/.bashrc 118 | ``` 119 | Then you must reboot or execute: 120 | ```bash 121 | $ source /opt/ros/kinetic/setup.bash 122 | ``` 123 | 124 | ## Raspicam node 125 | The following instructions enable the Raspberry Pi camera as a fully functional ROS camera node, using the ROS Kinetic base built above. 126 | 127 | ### Enable RaspiCam 128 | First of all we must to enable cam in our Raspberry Pi. 129 | 130 | To do this just: 131 | ```bash 132 | $ sudo raspi-config 133 | ``` 134 | Activate option -> *5: Enable Camera* 135 | 136 | Finish and reboot raspberry. 137 | 138 | ### Adding ARM libraries for interfacing to Raspberry Pi GPU 139 | The raspicam node software below requires the following GPU interface code be checked out at the location /home/pi/userland, so we download this repository here: 140 | ```bash 141 | $ git clone https://github.com/raspberrypi/userland.git /home/pi/userland 142 | ``` 143 | 144 | ### Install raspicam node 145 | 146 | ```bash 147 | $ mkdir -p ~/catkin_ws/src 148 | $ cd ~/catkin_ws/src 149 | $ git clone https://github.com/fpasteau/raspicam_node.git raspicam 150 | $ cd ~/catkin_ws 151 | $ catkin_make 152 | $ source devel/setup.bash 153 | ``` 154 | 155 | ### Running the camera node 156 | 157 | ```bash 158 | $ roscore & 159 | $ rosrun raspicam raspicam_node & 160 | $ rosservice call /camera/start_capture 161 | ``` 162 | 163 | ### Viewing the camera node 164 | 165 | ```bash 166 | $ rqt_image_view image:=/raspicam_node/camera/image/compressed 167 | ``` 168 | 169 | # References 170 | * https://github.com/antdroid-hexapod/antdroid/wiki/Installation 171 | * http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Indigo%20on%20Raspberry%20Pi 172 | * http://wiki.ros.org/kinetic/Installation/Source 173 | --------------------------------------------------------------------------------