日志文章

2020-6-4 aflfte2011

raspbian ros安装

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

设置repositories 储存库
以下的可能不需要

Debian 的 contrib 和 non-free deb 的储存库
Debian SourcesList

sudo gedit /etc/apt/sources.list
后面追加
deb http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster main contrib non-free

deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free

deb http://deb.debian.org/debian buster-updates main contrib non-free
deb-src http://deb.debian.org/debian buster-updates main contrib non-free

sudo apt update
sudo apt-upgrade

错误,缺乏 PUBLISH KEY, 19年开始,apt update很多deb都有这种问题。

W: GPG error: http://deb.debian.org/debian buster InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY EF0F382A1A7B6500 NO_PUBKEY DCC9EFBF77E11517
E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian-security buster/updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
E: The repository 'http://deb.debian.org/debian-security buster/updates InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian buster-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138
E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not signed

解决办法
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY
给了几条key,注意key是否与系统匹配,可以使用apt-key del 删除key。

以上的可能不需要

ROS 的储存库

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

不同的key对应不同版本的ROS,
删除key的方式。

apt-key list 
pub   rsa4096 2019-05-30 [SC] [expires: 2021-05-29]
      C1CF 6E31 E6BA DE88 68B1  72B4 F42E D6FB AB17 C654
uid           [ unknown] Open Robotics <info@osrfoundation.org>

sudo apt-key del C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

更新库

sudo apt update && sudo apt upgrade -y

安装 bootstrap
sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential

安装rosdep

sudo rosdep init
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

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

在编译之前,需要解决一些依赖
rosdep install --from-paths src --ignore-src --rosdistro kinetic -y

编译Workspace

sudo mkdir -p /opt/ros/kinetic
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /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 入门教程–创客智造

« Hallo word | debian 允许root用户登录»