在树莓派Raspbian/Debian 10 Buster上安装ROS

ROS各个版本的源码安装方式基本大致相同,
参考网址:
http://wiki.ros.org/Installation/Source
ROS不建议Debian系统通过源码安装,也没有一键安装的方法,http://wiki.ros.org/Installation/Debian

ROS先决条件 需要有python2和pip。

安装 python 库 和 C编译必要的整体环境build-essential
sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential

安装rosdep

$ sudo rosdep init
如果出现
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

在/etc/hosts 里面添加一行
185.199.110.133 raw.githubusercontent.com
如果还是失败,使用dns查询
https://tool.chinaz.com/dns
查询raw.githubusercontent.com的ip地址,逐个尝试

$ rosdep update

创建catkin Workspace工作空间

mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws

Desktop-Full Install: ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception
ROS全包,有gazebo模拟等

$ rosinstall_generator desktop_full --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-full-wet.rosinstall

$ wstool init -j8 src kinetic-desktop-full-wet.rosinstall

Desktop Install (recommended): ROS, rqt, rviz, and robot-generic libraries
桌面版,有rviz

$ rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-wet.rosinstall

$ wstool init -j8 src kinetic-desktop-wet.rosinstall

ROS-Comm: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.
有ros命令行tools和一些基本包,

$ rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall

$ wstool init -j8 src kinetic-ros_comm-wet.rosinstall

wstool init 是将文件里面的需要编译的文件下载到src文件夹

因为是使用的是树莓派,所以只能装ROS-Comm。

在编译之前,需要解决一些需要的库,如果中断了,多尝试几次

$ rosdep install --from-paths src --ignore-src --rosdistro kinetic -y

为了减少大家的时间,不重复遇到的问题, 感兴趣的可以往下面看

$ cd ~/ros_catkin_ws/src/
$ sudo mv rospack ~/rospack.bak
$ sudo git clone https://github.com/ros/rospack.git
$ cd ..

$ sudo apt install libtinyxml2-dev

$ sudo fallocate -l 1G /opt/swap (路径可自己定义)
$ sudo mkswap /opt/swap
$ sudo swapon /opt/swap
$ free -m 可以查看增加的交换空间
              total        used        free      shared  buff/cache   available
Mem:           1939         153         272          33        1513        1655
Swap:          1123           1        1122

编译Workspace

$ sudo mkdir -p /opt/ros/kinetic

开始编译
$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic
安装位置/opt/ros/kinetic可以自定义

出现错误

==> Processing catkin package: 'rospack'
==> Building with env: '/opt/ros/kinetic/env.sh'
Makefile exists, skipping explicit cmake invocation...
==> make cmake_check_build_system in '/home/pi/ros_catkin_ws/build_isolated/rosp                                                                                                             ack'
==> make -j4 -l4 in '/home/pi/ros_catkin_ws/build_isolated/rospack'
[ 22%] Building CXX object CMakeFiles/rospack.dir/src/rospack_backcompat.cpp.o
[ 22%] Building CXX object CMakeFiles/rospack.dir/src/rospack.cpp.o
[ 33%] Building CXX object CMakeFiles/rospack.dir/src/utils.cpp.o
[ 44%] Building CXX object CMakeFiles/rospack.dir/src/rospack_cmdline.cpp.o
In file included from /home/pi/ros_catkin_ws/src/rospack/src/rospack.cpp:28:
/home/pi/ros_catkin_ws/src/rospack/include/rospack/rospack.h:108:10: fatal error                                                                                                             : boost/tr1/unordered_set.hpp: No such file or directory
 #include <boost/tr1/unordered_set.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from /home/pi/ros_catkin_ws/src/rospack/src/rospack_cmdline.cpp                                                                                                             :28:
/home/pi/ros_catkin_ws/src/rospack/include/rospack/rospack.h:108:10: fatal error                                                                                                             : boost/tr1/unordered_set.hpp: No such file or directory
 #include <boost/tr1/unordered_set.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

看CHANGELOG.rst,是旧的rospack,和github上CHANGELOG不符,boost/tr1已被弃用,去github下载新的。
rospack地址

$ cd ~/ros_catkin_ws/src/
$ sudo mv rospack ~/rospack.bak
$ sudo git clone https://github.com/ros/rospack.git
$ cd ..

继续重新编译安装
出现另外一个错误

CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find TinyXML2 (missing: TinyXML2_LIBRARY TinyXML2_INCLUDE_DIR)

缺少TinyXML2库。解决办法:

$ sudo apt install libtinyxml2-dev

然后编译到roscpp宕机了,一般都是内存不够导致
原本的交换空间只用99M,现在加1GB交换空间进去。
$ free -h 可查看 有多少内存和交换空间(swap)
交换空间的实质是使用硬盘临时代替内存,当作临时存储数据的地方,硬盘速度没内存的速度快

$ sudo fallocate -l 1G /opt/image/swap (路径可自己定义)
$ sudo mkswap /opt/image/swap
$ sudo swapon /opt/image/swap

$ sudo nano /etc/fstab
后面追加
/opt/image/swap    /swap    swap    defaults 0 0
安装完后请删除掉这句话,重启就还是原来的交换空间大小了
删除 /opt/image/swap 文件释放硬盘空间
$ sudo rm -rf /opt/image/swap

继续编译

-- Install configuration: "Release"
-- Installing: /opt/ros/kinetic/_setup_util.py
-- Installing: /opt/ros/kinetic/env.sh
.. 省略一大堆文字
-- Installing: /opt/ros/kinetic/lib/rosbag/makerule.py
-- Installing: /opt/ros/kinetic/lib/rosbag/savemsg.py
-- Installing: /opt/ros/kinetic/lib/rosbag/topic_renamer.py
<== Finished processing package [52 of 52]: 'rosbag'

运行

$ source /opt/ros/kinetic/setup.bash
roscore
...logging to /home/pi/.ros/log/5d8b53d4-a2c5-11e9-8887-b827eb443c56/roslaunch-raspberrypi-8288.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://raspberrypi:44203/
ros_comm version 1.12.14


SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

NODES

auto-starting new master
process[master]: started with pid [8299]
ROS_MASTER_URI=http://raspberrypi:11311/

最后加上source
nano ~/.bashec
添加
source /opt/ros/kinetic/setup.bash
over!

ros 入门教程–创客智造

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值