树莓派3-Jessie编译安装ROS-indigo完整版
dajianli
dajianli 8719 7
热门 2016-07-23 22:28
大家在学习ROS中有时候直接使用笔记本或者工控机(小主机),比较麻烦、价格也比较贵,然后很多人就把注意打到小型的嵌入式计算机中如TK1、树莓派、香蕉派等,然而这些设备安装ROS时或多或少有些问题,例如教程只有安装ros-comm版本的,很多功能使用受限,很多小伙伴想把ROS-Desktop移植到这些设备上,但是坑比较多,然后一直过程一波三折,很少有走下去的,我在前期也走过这些坑,当时看了很多的教程,比如最有名的就是博主东方赤龙的树莓派2编译完整版的ROS-indigo,后来树莓派3发行,在树莓派2的基础上增加了板载蓝牙、无线,并且相应的性能也提升了,这时候我也有点心痒痒,于是继续入坑准备用树莓派3编译完整版indigo(其他版本类似,不过建议还是用indigo的),因为树莓派3的系统是jessie(树莓派2是wheezy,wheezy和jessie的区别大家百度一下就知道了),所以有些小细节要改,遂做如下记录:
本文作者为ROSClub.cn---Ray
转载请注明作者及其来源

1、安装前准备
树莓派3,TF卡16G,Raspbian OS(JESSIE),ROS Indigo,Win32DiskImager
1.1 Raspbian OS
在树莓派官网下载磁盘镜像,最新镜像为RASPBIAN JESSIE,
[点此下载](https://www.raspberrypi.org/downloads/raspbian/)
注意:选择RASPBIAN JESSIE,我下载的时候是2016-05-27的
1.2 烧写Raspbian jessie镜像
使用Win32DiskImager将下载好的树莓派镜像(.img文件)烧写进准备好的TF卡中
注意:在Win32DiskImager中不要选错盘符
2、准备ROS Indigo源代码及依赖库
2.1 准备工作
先添加代码源,然后更新系统,再添加ROS代码库的key。这里使用了阿里云的国内镜像,速度相对来说较快。
以下操作全在Xshell下操作

pi@raspberrypi:~ $ sudo chmod 777 /etc/apt/sources.list
pi@raspberrypi:~ $ sudo echo "deb http://mirrors.aliyun.com/raspbian/raspbian/ jessie main contrib non-free rpi" >/etc/apt/sources.list
pi@raspberrypi:~ $ sudo echo "deb-src http://mirrors.aliyun.com/raspbian/raspbian/ jessie main contrib non-free rpi" >>/etc/apt/sources.list
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu jessie main" > /etc/apt/sources.list.d/ros-latest.list
pi@raspberrypi:~ $ wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -


更新系统

pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get upgrade


2.2 安装必要软件包

pi@raspberrypi:~ $ sudo apt-get install python-setuptools
pi@raspberrypi:~ $ sudo easy_install pip
pi@raspberrypi:~ $ sudo pip install -U rosdep rosinstall_generator wstool rosinstall


2.3 初始化rosdep

pi@raspberrypi:~ $ sudo rosdep init
pi@raspberrypi:~ $ rosdep update


3、编译ROS源码
3.1 编译前准备
3.1.1 创建一个workspace,用来下载和编译ROS完整源码

pi@raspberrypi:~ $ mkdir ~/ros_catkin_ws
pi@raspberrypi:~ $ cd ~/ros_catkin_ws


3.1.2 下载源码
ROS官方提供了两种源码包,
一种是ROS-Comm(官方推荐),里面仅包含了基本必备内容,没有GUI等工具;
一种是Desktop,里面除了ROS-Comm包含的基本必备内容外,还包含了rqt,rviz和robot-generic等工具。
这里我们选择Desktop版,如果只想安装ROS-Comm版,只需要将下面的命令中desktop替换为ros_comm即可。

pi@raspberrypi:~ $ rosinstall_generator desktop --rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-desktop-wet.rosinstall
pi@raspberrypi:~ $ wstool init -j8 src indigo-desktop-wet.rosinstall


这样所有ROS代码会被下载到~/ros_catkin_ws/src目录中,-j8参数意思是开启8个线程一起下载。
如果下载异常中断,可以尝试使用以下命令恢复下载:
pi@raspberrypi:~ $ wstool update -j4 -t src


3.2 解决ROS依赖问题
在正式编译ROS之前,我们还需要手动安装以下几个依赖包:
libconsole-bridge-dev, liburdfdom-headers-dev, liburdfdom-dev, liblz4-dev, and collada-dom-dev。
ROS_Comm所需依赖包:libconsole-bridge-dev and liblz4-dev
Desktop所需依赖包:libconsole-bridge-dev, liblz4-dev, liburdfdom-headers-dev, liburdfdom-dev, collada-dom-dev
3.2.1 为这些依赖包建立单独的用于编译安装的文件夹,同时安装checkinstall和cmake:

pi@raspberrypi:~ $ mkdir ~/ros_catkin_ws/external_src
pi@raspberrypi:~ $ sudo apt-get install checkinstall cmake


3.2.2 安装libconsole-bridge-dev

pi@raspberrypi:~ $ cd ~/ros_catkin_ws/external_src
pi@raspberrypi:~ $ sudo apt-get install libboost-system-dev libboost-thread-dev
pi@raspberrypi:~ $ git clone https://github.com/ros/console_bridge.git
pi@raspberrypi:~ $ cd console_bridge
pi@raspberrypi:~ $ cmake .
pi@raspberrypi:~ $ sudo checkinstall make install


***在最后一步checkinstall的时候,会询问多个问题,在有一个问题提供多个选项的时候,选择2修改包名称为libconsole-bridge-dev,然后在之后的两个问题都选择N,否则最后编译时会出错。
3.2.3 安装liburdfdom-headers-dev

pi@raspberrypi:~ $ cd ~/ros_catkin_ws/external_src
pi@raspberrypi:~ $ git clone https://github.com/ros/urdfdom_headers.git
pi@raspberrypi:~ $ cd urdfdom_headers
pi@raspberrypi:~ $ cmake .
pi@raspberrypi:~ $ sudo checkinstall make install


***在最后一步checkinstall的时候,会询问多个问题,在有一个问题提供多个选项的时候,选择2修改包名称为liburdfdom-headers-dev,然后在之后的两个问题都选择N,否则最后编译时会出错。
3.2.4 安装liburdfdom-dev

pi@raspberrypi:~ $ cd ~/ros_catkin_ws/external_src
pi@raspberrypi:~ $ sudo apt-get install libboost-test-dev libtinyxml-dev
pi@raspberrypi:~ $ git clone https://github.com/ros/urdfdom.git
pi@raspberrypi:~ $ cd urdfdom
pi@raspberrypi:~ $ cmake .
pi@raspberrypi:~ $ sudo checkinstall make install


***在最后一步checkinstall的时候,会询问多个问题,在有一个问题提供多个选项的时候,选择2修改包名称为liburdfdom-dev,然后在之后的两个问题都选择N,否则最后编译时会出错。
3.2.5 安装collada-dom-dev

pi@raspberrypi:~ $ cd ~/ros_catkin_ws/external_src
pi@raspberrypi:~ $ sudo apt-get install libboost-filesystem-dev libxml2-dev
pi@raspberrypi:~ $ wget http://downloads.sourceforge.net/project/collada-dom/Collada%20DOM/Collada%20DOM%202.4/collada-dom-2.4.0.tgz
pi@raspberrypi:~ $ tar -xzf collada-dom-2.4.0.tgz
pi@raspberrypi:~ $ cd collada-dom-2.4.0
pi@raspberrypi:~ $ cmake .
pi@raspberrypi:~ $ sudo checkinstall make install


这里的collada-dom-2.4.0.tgz大概几十兆,建议本地下载后传到树莓派中(可以使用rzsz命令,自行搜索使用方法)

***在最后一步checkinstall的时候,会询问多个问题,在有一个问题提供多个选项的时候,选择2修改包名称为collada-dom-dev,然后在之后的两个问题都选择N,否则最后编译时会出错。
3.2.6 安装liblz4-dev

pi@raspberrypi:~ $ cd ~/ros_catkin_ws/external_src  
pi@raspberrypi:~ $ wget http://archive.raspbian.org/raspbian/pool/main/l/lz4/liblz4-1_0.0~r122-2_armhf.deb  
pi@raspberrypi:~ $ wget http://archive.raspbian.org/raspbian/pool/main/l/lz4/liblz4-dev_0.0~r122-2_armhf.deb  
pi@raspberrypi:~ $ sudo dpkg -i liblz4-1_0.0~r122-2_armhf.deb liblz4-dev_0.0~r122-2_armhf.deb


3.3 使用rosdep解决剩余依赖

pi@raspberrypi:~ $ cd ~/ros_catkin_ws  
pi@raspberrypi:~ $ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:jessie


上面命令会遍历所有的package并递归安装依赖
***3.5 修改部分代码(编译某些包错误可能需要修改以下文件)
在/home/pi/ros_catkin_ws/src/rviz/src/rviz目录中找到mesh_loader.cpp文件,找到以下代码区域:

#if defined(ASSIMP_UNIFIED_HEADER_NAMES)
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp>
#else
#include <assimp/assimp.hpp>
#include <assimp/aiScene.h>
#include <assimp/aiPostProcess.h>
#include <assimp/IOStream.h>
#include <assimp/IOSystem.h>
#endif


在这段代码之后,增加以下代码段,保存退出。

#ifdef __arm__
#include <string.h>
bool Assimp::IOSystem::ComparePaths(const char *p1, const char *p2) const
{
return !::strcasecmp(p1, p2);
}
#endif


在/home/pi/ros_catkin_ws/src/robot_model/collada_urdf/src目录中找到collada_to_urdf.cpp和collada_urdf.cpp文件,也同样添加以上代码段后保存退出。
这样在之后的编译过程中就不会再有报错信息。
3.6 编译安装ROS

pi@raspberrypi:~ $ cd ~/ros_catkin_ws
pi@raspberrypi:~ $ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo -j2
pi@raspberrypi:~ $ source /opt/ros/indigo/setup.bash


编译命令最后的-j2参数是开启两个线程编译,默认不带参数是使用四线程,但是对于树莓派的cpu和内存来说,容易因耗尽资源而死机中断。
至此,在树莓派3上编译安装ROS就完成了。
作者水平有限,如有错误请及时指出
大家可以用树莓派配置主从机操作:ROS中多机通信最简单的配置方法-树莓派 to PC
参考链接:
http://blog.csdn.net/u013494117/article/details/51751939
http://blog.csdn.net/crazyquhezheng/article/details/43413231
https://www.raspberrypi.org/downloads/raspbian/
http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Indigo%20on%20Raspberry%20Pi
分享:
游客
要评论请先登录 或者 注册
Lan_SLAM 原型机 2016-07-27 15:55 沙发
树莓派2B能安装jessie吗?
Lan_SLAM 原型机 2016-07-28 14:11 板凳
我是树莓派2,按照你的步骤,可是没有安装checkinstall cmake成功,怎么解决?
wp198950 初代型 2016-07-30 23:55 地板
楼主你好 !我安装上面的安装 但是一直出现
==> Processing catkin package: 'collada_parser'
==> Building with env: '/opt/ros/indigo/env.sh'
Makefile exists, skipping explicit cmake invocation...
==> make cmake_check_build_system in '/home/pi/ros_catkin_ws/build_isolated/collada_parser'
==> make -j2 in '/home/pi/ros_catkin_ws/build_isolated/collada_parser'
[ 50%] Building CXX object CMakeFiles/collada_parser.dir/src/collada_parser.cpp.o
In file included from /usr/local/include/urdf_model/joint.h:43:0,
                 from /usr/local/include/urdf_model/link.h:44,
                 from /usr/local/include/urdf_model/model.h:42,
                 from /home/pi/ros_catkin_ws/src/robot_model/collada_parser/include/collada_parser/collada_parser.h:44,
/usr/local/include/urdf_model/types.h: At global scope:
/usr/local/include/urdf_model/types.h:51:9: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:53:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:53:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:53:1: error: 'weak_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:54:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:54:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:54:1: error: 'weak_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:55:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:55:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:55:1: error: 'weak_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:56:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:56:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:56:1: error: 'weak_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:57:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:57:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:57:1: error: 'weak_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:58:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:58:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:58:1: error: 'weak_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:59:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:59:1: error: 'shared_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:59:1: error: 'weak_ptr' in namespace 'std' does not name a type
/usr/local/include/urdf_model/types.h:60:1: error: 'shared_ptr' in namespace 'std' does not name a type
wp198950 初代型 2016-07-30 23:56 4楼
wp198950:楼主你好 !我安装上面的安装 但是一直出现
==> Processing catkin package: 'collada_parser'
==> Building with env: '/opt/ros/indigo/env.sh'
Ma...
回到原帖
一直编译不过去
不知道怎么回事?能不能帮忙看看
nickxiang0306 原型机 2016-12-08 14:06 5楼
wp198950:楼主你好 !我安装上面的安装 但是一直出现
==> Processing catkin package: 'collada_parser'
==> Building with env: '/opt/ros/indigo/env.sh'
Ma...
回到原帖
我在编译中也遇到此问题,请问你解决没有?
活到老 原型机 2016-12-24 16:14 7楼
感谢楼主,分享心得
 返回顶部