**
**
这里不要换成AMD架构的PC平台的软件源,需要换成配套ARM使用的源。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main universe restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main universe restricted
保存一下source.list
sudo apt update
**
**
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
但官网的源下载速度过慢,这里推荐更换清华源或中科大源,个人推荐清华源。
清华源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
中科大源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
如果想要更换其他源直接输入你想要更换的源的指令即可。
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
上面这个设置失败的话可使用下面这个替代的秘钥,两个只要有一个能执行成功即可。
sudo apt-key adv --keyserver 'hkp://pgp.mit.edu:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
首先更新一下软件源 sudo apt-get update
接下来安装ROS的桌面完整版(Desktop-full) sudo apt-get install ros-melodic-desktop-full
等待ing
rosdep 是ROS中自带的工具,主要功能是为某些功能安装包安装系统依赖,同时也是某些ROS核心功能包必须用到的工具,如果提示找不到命令rosdep,则执行:
sudo apt install rospack-tools
接下来执行命令进行初始化以及更新ROS
sudo rosdep init
rosdep update
此处更新失败的较多,最好的解决办法是科学上网,其次是手机开热点,电脑连接手机热点进行更新。我总结了几种出错的解决方法。
首先是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
解决方法:
打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
199.232.68.133 raw.githubusercontent.com
#保存后退出再尝试
这个ip地址可能随时会变,因此保险起见登录IPAddress.com,在里面输入 raw.githubusercontent.com查找最优ip地址,查到后改为这个ip
再执行sudo gedit /etc/resolv.conf
,将原有的nameserver
这一行注释,并添加以下两行:
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器
先sudo apt-get update
再执行sudo rosdep init
会出现已有该文件的错误
ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
只要将这个文件删除sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
再执行sudo rosdep init
即可。不成功的话多执行几次,初始化成功会出现
wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
然后执行rosdep update
这也会出现报错,大多都是超时或网络的原因导致的(科学上网完美解决)经常出错情况如下:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit http://github.com/ros/rosdistro/raw/master/rosdep/osx-homebrew.yaml
ERROR: unable to process source [http://github.com/ros/rosdistro/raw/master/rosdep/base.yaml]:
<urlopen error _ssl.c:489: The handshake operation timed out> (http://github.com/ros/rosdistro/raw/master/rosdep/base.yaml)
ERROR: error loading sources list:
The read operation timed out
解决方法:
更改 /usr/lib/python2.7/dist-packages/rosdep2/
下的三个文件sources_list.py
、gbpdistro_support.py
、rep3.py
中的值,改大一点就可以了,这里我改到了100。分别执行以下三个指令:
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
通过搜索功能找到DOWNLOAD_TIMEOUT =15.0
修改数值保存即可。
多执行rosdep update
几次。
实在不行的话(这里是指执行了一下午 哈哈哈)下面有一个不太推荐的解决办法就是直接下载文件替换到本地,可直接跳过Hit过程,连接本地文件。
文件下载地址为 github.com
该方法参考连接为https://blog.csdn.net/super_sean/article/details/105433250 步骤非常详细。
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
rosinstall 也是ROS中一个常用工具,可以下载和安装ROS中的功能包程序
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
**
**
首先安装libpcap-dev
:
sudo apt-get install libpcap-dev
然后创建 ROS工作目录并将例程克隆到工作空间进行编译
cd ~
mkdir -p catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/RoboSense-LiDAR/ros_rslidar
cd ~/catkin_ws
catkin_make
A-loam
例程链接为 https://github.com/HKUST-Aerial-Robotics/A-LOAM.git
同样放到工作空间中进行编译。
接下来主要讲讲我在编译这两个包所出现的问题,错误顺序记不清了。
错误一:Project ‘cv_bridge‘ specifies ‘/usr/include/opencv‘ as an include dir, which is not found
CMake Error at /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake:113 (message):
Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir,
which is not found. It does neither exist as an absolute directory nor in
'/opt/ros/melodic//usr/include/opencv'. Check the issue tracker
'https://github.com/ros-perception/vision_opencv/issues' and consider
creating a ticket if the problem has not been reported yet.
Call Stack (most recent call first):
/opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
open_quadtree_mapping/CMakeLists.txt:24 (find_package)
我们安装的opencv版本应为opencv4,出错的原因是'/usr/include/opencv'
所以我们只需要更改一下位置为/usr/include/opencv4
就可以了,执行以下指令:
sudo gedit /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
改掉第96行为/usr/include/opencv4
原文链接:https://blog.csdn.net/weixin_42587961/article/details/107666708
错误二:fatal error: pcap.h: No such file or directory
在编译的时候,发现没有pcap.h头文件去这个网站里面下载libpcap压缩包
http://www.tcpdump.org/#latest-release
然后解压之后 cd libpcap-1.9.0,执行以下指令:
cd libpcap-1.9.0
./configure
然后把libcap-1.9.1/pcap/中的pcap.h
文件复制到/usr/include/中
sudo cp pcap.h /usr/include/
原文链接:https://blog.csdn.net/wuyou1995/article/details/104742424
错误三:Opencv4 CV_LOAD_IMAGE_GRAYSCALE找不到解决方法
原文链接:https://blog.csdn.net/Bixiwen_liu/article/details/107345635
错误四:最大也是最麻烦的一个错误 --缺少ceres库,编译ceresku时又缺少glog
需要下载的包如下图:
ceres包下载链接 github.com
googletest包下载链接 github.com
gflags包下载链接 github.com
glog包下载链接 github.com
这四个包的编译顺序为googletest
、gflags
、glog
、ceres
。
编译指令为
mkdir build
cd build
cmake ..
make -j4
sudo make install
其中googletest
正常编译就可,gflags
、glog
这两个包的编译参考原文链接为https://blog.csdn.net/yuchunhai321/article/details/87428994?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_utm_term-3&spm=1001.2101.3001.4242
上面三个包都编译成功了再编译ceres包,ceres包编译成功后再将上面我们所要用的A-Loam和激光雷达包重新编译,应该不会有什么报错了。
.sh
脚本同时调用两个包比是比较方便的。roslaunch rslidar_pointcloud rs_lidar_16.launch
roslaunch aloam_velodyne aloam_velodyne_VLP_16.launch
若要进行点云数据的保存则运行:
rosbag record /rslidar_points
该指令会记录你获取的所有点云数据,并保存到你运行脚本的文件夹中,若要重现点云数据则需要先运行ROS再读取该点云数据包以及运行A-Loam,可以看到点云重建的三位图,指令如下:
roscore
rosbag play bagname
roslaunch aloam_velodyne aloam_velodyne_VLP_16.launch