文章目录
- 前言
- 一、ROS安装步骤中的sudo rosdep init和rosdep update问题 ?
- 1.初始化ROS中sudo rosdep init 可能出现的问题及解决方法如下:
- 2.更新rosdep update
- 二、安装cartographer的成功过程
- 1.安装基本工具(wstool,rosdep,ninja)以编译和运行cartographer
- 2.创建cartographer的工作空间
- 3.安装cartographer_ros的依赖项
- 4.安装必备的库
- 5.编译测试
- 6.下载cartographer 例子数据包
- 7.launch和lua文件修改
- 总结
前言
电脑型号:联想小新pro 13 AMD
电脑双系统
Ubuntu20.04
提示:以下是本篇文章正文内容,下面案例可供参考
一、ROS安装步骤中的sudo rosdep init和rosdep update问题 ?
只要这里顺利进行后,在后面安装Cartographer时。在这相同的步骤上可以直接跳过,应该不会出啥问题。
1.初始化ROS中sudo rosdep init 可能出现的问题及解决方法如下:
a)如果输出如下,则一切顺利,请跳到2、更新rosdep update
b)错误1:如果输出大意为找不到命令,这说明系统还未安装rosdep
// 请输入如下命令:
sudo apt install python-rosdep2
//还是找不到命令请输入:
sudo apt install python3-rosdep2
(这是因为ubuntu20.04一般只预装python3,因此第二条指令往往可以解决这个问题)
再运行sudo rosdep init 即可
c)错误2:ERROR: cannot download default sources list from:https : //http://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.listWebsite may be down.
在终端输入以下指令:
sudo gedit /etc/resolv.conf
在打开的文件中输入:
把上面的注释掉,前面加个#
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器
再运行sudo rosdep init 即可
d)错误3:ERROR: default sources list file already exists: /etc/ros /rosdep/sources.list.d/20-default.listPlease delete if you wish to re-initialize
这种情况一般是之前装过ROS系统没有卸载干净
在终端输入以下指令(删除初始化文件):
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
再运行sudo rosdep init 即可
2.更新rosdep update
此处是做让我头疼的地方,不过在找到一些大佬的解决方案后,我终于成功了。先把链接放上rosdep update 超时失败2021最新解决方法
sudo gedit /etc/hosts
//加入如下的ip可一试
在这里我是采用该链接中的第3个方法成功的,由于我用的版本是noetic,故而这里的python2.7要换成python3
例如: /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
sudo gedit /usr/lib/python3/dist-packages/rosdep2/sources_list.py
//1.首先修改rosdep下载资源的脚本文件:把以下行添加到脚本中的download_rosdep_data()函数中,以应用代理服务:
url="https://ghproxy.com/"+url
sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py
//2用同样的方法修改里面的DEFAULT_INDEX_URL参数,如下:
DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
// 同样的方法把“https://ghproxy.com/”添加到网址前:
sudo gedit /usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
36行
sudo gedit /usr/lib/python3/dist-packages/rosdep2/sources_list.py
72行
sudo gedit /usr/lib/python3/dist-packages/rosdep2/rep3.py
39行
sudo gedit /usr/lib/python3/dist-packages/rosdistro/manifest_provider/github.py
68行 119行
sudo gedit /usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
204行添加如下:
gbpdistro_url = "https://ghproxy.com/" + gbpdistro_url
剩下的就是大家耐心的一个个修改了,祝你好运。最后rosdep update成功模样如下:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///etc/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/base.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/python.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/ruby.yaml
Hit file:///etc/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index file:///etc/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Add distro "foxy"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
updated cache in /home/xxxx/.ros/rosdep/sources.cache
二、安装cartographer的成功过程
1.安装基本工具(wstool,rosdep,ninja)以编译和运行cartographer
在终端输入指令:
sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow
2.创建cartographer的工作空间
在终端输入指令:(catkin_ws是文件夹名称,可以自行更改)
mkdir catkin_ws
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
在此处大概率会报错,从倒数第二句开始,这里的做法是不管他,由于他们表示的意思是要下载几个库,因此我直接把之前下好的库放在工作空间的src文件夹下。如下图所示
此图是经过了ctrl+h后出现的后面两个脚本。主要是下载了这3个文件。这里提供这3个文件的下载链接,或者是可以访问我下好的链接都行,建议用手机热点,下载通过后保存 好三个文件然后下次再次安装可以直接复制到对应文件夹里。
cd ~/catkin_ws/src
git clone https://github.com/googlecartographer/cartographer_ros.git
git clone https://github.com/googlecartographer/cartographer.git
git clone https://github.com/ceres-solver/ceres-solver.git
总结这里依次需要安装4个文件,1个功能包,上面3个外加abseil-cpp包和protobuf包这,这两个包建议不要直接复制到/catkin_ws下,可通过下面连接用手机热点下载下来,耐心等待即可。
3.安装cartographer_ros的依赖项
先使用rosdep安装所需的软件包。此处我们之前已经运行过 sudo rosdep init,故这里将显示错误,可以忽略(因为初始化的文件已经存在,无需再次初始化。如果不放心可以回到最上面的“一”中解决)。
1、sudo apt-get update
2、sudo rosdep init
3、rosdep update
4、rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
5、sudo apt-get install -y \
clang \
cmake \
g++ \
git \
google-mock \
libboost-all-dev \
libcairo2-dev \
libcurl4-openssl-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
lsb-release \
ninja-build \
stow
6、sudo apt-get install libceres-dev
7、sudo apt install libgmock-dev
问题解决:
上面第7可以解决的问题是:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GMOCK_LIBRARY
linked by target "time_conversion_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
linked by target "time_conversion_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
linked by target "msg_conversion_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
linked by target "msg_conversion_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
linked by target "metrics_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
linked by target "metrics_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
linked by target "configuration_files_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
linked by target "configuration_files_test" in directory /home/mckros/catkin_ws/src/cartographer_ros/cartographer_ros
-- Configuring incomplete, errors occurred!
See also "/home/mckros/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/mckros/catkin_ws/build/CMakeFiles/CMakeError.log".
make: *** [Makefile:4520:cmake_check_build_system] 错误 1
Invoking "make cmake_check_build_system" failed
参考连接:
4.安装必备的库
1)安装abseil-cpp库
在终端输入命令:
cd catkin_ws
src/cartographer/scripts/install_abseil.sh
1、cd abseil-cpp
2、cd build
3、cmake -G Ninja -CMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=/usr/local/stow/absl ..
4、ninja
5、sudo ninja install
6、cd /usr/local/stow
7、sudo stow absl
如果提示版本冲突,请输入以下指令先删除旧版本:
sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp
然后再次执行(此处省略跳过)
src/cartographer/scripts/install_abseil.sh
我这里是没有冲突的,因为版本就装了一个。
2)安装protobuf库
在终端输入命令:
cd catkin_ws
src/cartographer/scripts/install_proto3.sh
1、cd protobuf
2、mkdir build
3、cd build
4、cmake -G Ninja -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUI-Dprotobuf_BUIL-D_TESTS=OFFLD_TYPE=Release ../cmake
5、ninja
6、sudo ninja install
3)安装ceres库
在终端输入命令
1、cd ceres-solver
2、mkdir build
3、cd build
4、cmake .. -G Ninja -DCXX11=ON
5、ninja
6、sudo ninja install
4)安装cartographer库
1、cd cartographer
2、mkdir build
3、cd build
4、cmake .. -G Ninja
5、ninja
6、sudo ninja install
5.编译测试
在终端输入:
catkin_make_isolated --install --use-ninja
链接成功后,即可下载cartographer 例子数据包进行测试,先记得source
source install_isolated/setup.bash
6.下载cartographer 例子数据包
source install_isolated/setup.bash
//revo lds激光雷达
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/revo_lds/cartographer_paper_revo_lds.bag
//launch文件
roslaunch cartographer_ros demo_revo_lds.launch bag_filename:=${HOME}/Downloads/cartographer_paper_revo_lds.bag
7.launch和lua文件修改
1)launch文件修改
修改地方为两处laser.lua和remap,记住remap的对象要是对应机器人的
<launch>
<param name="/use_sim_time" value="true" />
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename laser.lua"//此处为修改的文件名称
output="screen">
<remap from="scan" to="scan" />//激光雷达的话题
</node>
<node name="rviz" pkg="rviz" type="rviz" required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
</launch>
2)lua文件修改
主要修改地方为四处对应的坐标系
include "map_builder.lua"
include "trajectory_builder.lua"
options = {
map_builder = MAP_BUILDER,
trajectory_builder = TRAJECTORY_BUILDER,
map_frame = "map",//一般默认为这个
tracking_frame = "laser",//对应的激光雷达坐标系
published_frame = "laser",//同上对应的雷达坐标系
odom_frame = "odom",//一般默认为这个
provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_pose_extrapolator = true,
use_odometry = false,
use_nav_sat = false,
use_landmarks = false,
num_laser_scans = 1,
num_multi_echo_laser_scans = 0,
num_subdivisions_per_laser_scan = 1,
num_point_clouds = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
trajectory_publish_period_sec = 30e-3,
rangefinder_sampling_ratio = 1.,
odometry_sampling_ratio = 1.,
fixed_frame_pose_sampling_ratio = 1.,
imu_sampling_ratio = 1.,
landmarks_sampling_ratio = 1.,
}
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.submaps.num_range_data = 35
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1
POSE_GRAPH.optimization_problem.huber_scale = 1e2
POSE_GRAPH.optimize_every_n_nodes = 35
POSE_GRAPH.constraint_builder.min_score = 0.65
return options
总结
只要能解决本文中的rosdep update和安装所必备的库就可以实现cartographer的安装,这也是今天成功后比较开心,即兴所写下来的过程,希望大家批评指正!