Google Cartographer的正确安装方式

Google Cartographer的正确安装方式

昨天装了google cartographer,连着遇到了几个坑,不过忘了截图
任何出现proto2,proto3什么的报错,一定是Protobuf没装好
直接用脚本装没用,必须下源码,编译安装才管用,目标版本号是3.6.1
事不宜迟,直接描述正确的安装流程:

安装protobuf3

# 首先安装protobuf
sudo apt-get install autoconf autogen
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh
./configure
make
# 这一步可能会报错,无视就好
make check
sudo make install
sudo ldconfig # refresh shared library cache.

这里可以通过来检查一下安装后protobuf的版本,目前是3.6.1

protoc --version
libprotoc 3.6.1

可以添加一个环境变量来确保链接到正确的prtobuf版本,不过不加似乎也没问题(o´ω`o)

which protoc
/usr/local/bin/protoc
export PROTOBUF_PROTOC_EXECUTABLE=/usr/local/bin/protoc

安装Cartographer

# Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build

# Create a new workspace in 'catkin_ws'.
mkdir catkin_ws
cd catkin_ws
wstool init src

# Merge the cartographer_turtlebot.rosinstall file and fetch code for dependencies.
# the first one give me turtlebot stuff, the second one give me the newest repo.
# 第一个repo提供了turtlebot相关的功能,第二个repo是官方最新的repo
# 如果想要使用turtlebot功能,就要先update第一个链接,然后update第二个
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_turtlebot/master/cartographer_turtlebot.rosinstall
wstool update -t src
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src


# Install deb dependencies.
# The command 'sudo rosdep init' will print an error if you have already
# executed it since installing ROS. This error can be ignored.
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

# Build and install.
catkin_make_isolated --install --use-ninja
source install_isolated/setup.bash

Demo

官方提供了很多包包可以试着跑跑看看效果
然而因为某些不可描述的原因,国内大概不是很方便下载→_→
另外每个包都超大的。。。下了好久啊

turtlebot相关的demo

# Download the example bag.
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/turtlebot/cartographer_turtlebot_demo.bag

# Launch the 2D LIDAR demo.
roslaunch cartographer_turtlebot demo_lidar_2d.launch bag_filename:=${HOME}/Downloads/cartographer_turtlebot_demo.bag

# Launch the 2D depth camera demo.
roslaunch cartographer_turtlebot demo_depth_camera_2d.launch bag_filename:=${HOME}/Downloads/cartographer_turtlebot_demo.bag

# Launch the 3D depth camera demo.
roslaunch cartographer_turtlebot demo_depth_camera_3d.launch bag_filename:=${HOME}/Downloads/cartographer_turtlebot_demo.bag

官方提供的其他demo:

Deutsches Museum
# Download and launch the 2D backpack demo:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag

# Download and launch the 3D backpack demo:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/with_intensities/b3-2016-04-05-14-14-00.bag
roslaunch cartographer_ros demo_backpack_3d.launch bag_filename:=${HOME}/Downloads/b3-2016-04-05-14-14-00.bag
Pure localization

Pure localization uses 2 different bags. The first one is used to generate the map, the second to run pure localization.

# Download the 2D bags from the Deutsche Museum:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/b2-2016-04-05-14-44-52.bag
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/b2-2016-04-27-12-31-41.bag

# Generate the map (wait until cartographer_offline_node finishes) and then run pure localization:
roslaunch cartographer_ros offline_backpack_2d.launch bag_filenames:=${HOME}/Downloads/b2-2016-04-05-14-44-52.bag
roslaunch cartographer_ros demo_backpack_2d_localization.launch \
   load_state_filename:=${HOME}/Downloads/b2-2016-04-05-14-44-52.bag.pbstream \
   bag_filename:=${HOME}/Downloads/b2-2016-04-27-12-31-41.bag

# Download the 3D bags from the Deutsche Museum:
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-13-54-42.bag
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_3d/b3-2016-04-05-15-52-20.bag

# Generate the map (wait until cartographer_offline_node finishes) and then run pure localization:
roslaunch cartographer_ros offline_backpack_3d.launch bag_filenames:=${HOME}/Downloads/b3-2016-04-05-13-54-42.bag
roslaunch cartographer_ros demo_backpack_3d_localization.launch \
   load_state_filename:=${HOME}/Downloads/b3-2016-04-05-13-54-42.bag.pbstream \
   bag_filename:=${HOME}/Downloads/b3-2016-04-05-15-52-20.bag
Static landmarks
# Download the landmarks example bag.
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/mir/landmarks_demo_uncalibrated.bag

# Launch the landmarks demo.
roslaunch cartographer_mir offline_mir_100_rviz.launch bag_filename:=${HOME}/Downloads/landmarks_demo_uncalibrated.bag
Revo LDS

Download and launch an example bag captured from a low-cost Revo Laser Distance Sensor from Neato Robotics vacuum cleaners:

wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/revo_lds/cartographer_paper_revo_lds.bag
roslaunch cartographer_ros demo_revo_lds.launch bag_filename:=${HOME}/Downloads/cartographer_paper_revo_lds.bag
PR2

Download and launch an example bag captured from a PR2 R&D humanoid robot from Willow Garage:

wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/pr2/2011-09-15-08-32-46.bag
roslaunch cartographer_ros demo_pr2.launch bag_filename:=${HOME}/Downloads/2011-09-15-08-32-46.bag
Taurob Tracker

Download and launch an example bag captured from a Taurob Tracker teleoperation robot:

wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/taurob_tracker/taurob_tracker_simulation.bag
roslaunch cartographer_ros demo_taurob_tracker.launch bag_filename:=${HOME}/Downloads/taurob_tracker_simulation.bag

参考链接:

https://google-cartographer-ros.readthedocs.io/en/latest/index.html
https://google-cartographer-ros-for-turtlebots.readthedocs.io/en/latest/#
https://github.com/googlecartographer
https://google-cartographer.readthedocs.io/en/latest/
https://github.com/googlecartographer/cartographer_ros/issues/687
https://github.com/protocolbuffers/protobuf/blob/master/src/README.md

### 回答1: 安装Cartographer需要以下步骤: 1. 首先,在Ubuntu 18.04上安装依赖项。打开终端并执行以下命令: ``` sudo apt-get update sudo apt-get install -y cmake g++ git google-mock libboost-all-dev libcairo2-dev libeigen3-dev libgflags-dev libgoogle-glog-dev liblua5.3-dev libprotobuf-dev libsuitesparse-dev lsb-release ninja-build python-sphinx protobuf-compiler python3-dev python3-sphinx ros-melodic-tf2-sensor-msgs libceres-dev ``` 2. 安装Google的protobuf: ``` wget https://github.com/google/protobuf/releases/download/v3.8.0/protobuf-all-3.8.0.tar.gz tar -xf protobuf-all-3.8.0.tar.gz cd protobuf-3.8.0/ ./configure make sudo make install ``` 3. 克隆Cartographer存储库: ``` git clone https://github.com/googlecartographer/cartographer.git ``` 4. 创建并进入构建目录: ``` cd cartographer mkdir build cd build ``` 5. 运行CMake编译配置: ``` cmake .. make -j ``` 6. 安装Cartographer: ``` sudo make install ``` 完成安装后,您可以在终端中测试Cartographer: ``` cartographer_rosbag_validate -h ``` 这将显示Cartographer的命令行帮助。 ### 回答2: 在Ubuntu 18.04上安装Cartographer可以按照以下步骤进行操作: 1. 打开终端,使用命令sudo apt-get update来更新软件包。 2. 安装依赖项:sudo apt-get install -y google-mock libboost-all-dev libeigen3-dev libceres-dev liblua5.3-dev ninja-build protobuf-compiler python-sphinx libatlas-base-dev 3. 安装CMake:sudo apt-get install -y cmake 4. 进入要安装Cartographer的目录,例如/home/username/Documents。 5. 使用以下命令克隆Cartographer源代码: git clone https://github.com/cartographer-project/cartographer.git cd cartographer git checkout master git fetch --all git reset --hard origin/master git submodule init git submodule update 6. 创建一个用于构建的目录并进入该目录: mkdir build && cd build 7. 运行以下命令配置构建: cmake .. 8. 运行以下命令编译并安装Cartographer: make -j sudo make install 9. 安装完成后,可以使用以下命令验证Cartographer是否正确安装cartographer_assets_writer cartographer_grpc_assets_writer cartographer_info cartographer_pbstream_to_rosbag cartographer_ros cartographer_rosbag cartographer_rosver cartographer_turtlebot_3_localization 通过以上步骤,您应该可以成功在Ubuntu 18.04上安装Cartographer。可能需要一些时间来完成编译和安装过程,请耐心等待。如果遇到任何问题,可以参考Cartographer的官方文档或寻求相关技术支持。 ### 回答3: 在Ubuntu 18.04上安装Cartographer是一个相对繁琐的过程,以下是详细步骤: 1. 首先,你需要确认你的系统已经安装好了一些基本的开发工具。可以在终端中运行以下命令来安装这些工具: ``` sudo apt-get update sudo apt-get install -y build-essential cmake git ``` 2. 接下来,需要安装一些依赖项。运行以下命令进行安装: ``` sudo apt-get install -y google-mock libboost-all-dev libcairo2-dev libeigen3-dev libgflags-dev libgoogle-glog-dev liblua5.2-dev libsuitesparse-dev libwebp-dev ninja-build protobuf-compiler python-sphinx ``` 3. 安装和配置Java开发环境。Cartographer使用Java来构建文档,所以需要安装Java JDK: ``` sudo apt-get install -y openjdk-8-jdk ``` 然后设置Java环境变量: ``` export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export PATH=$JAVA_HOME/bin:$PATH ``` 4. 现在,你可以从GitHub上克隆Cartographer的源代码库: ``` git clone https://github.com/googlecartographer/cartographer.git ``` 然后进入克隆下来的目录: ``` cd cartographer ``` 并且检出最新的稳定版本: ``` git fetch --all git tag git checkout tags/<tag_name> ``` 5. 创建一个构建目录,并切换到该目录: ``` mkdir build cd build ``` 6. 使用CMake来配置Cartographer的构建: ``` cmake .. ``` 7. 使用ninja构建Cartographer: ``` ninja ``` 8. 最后,运行测试来确保安装成功: ``` ninja test ``` 至此,你已经成功安装Cartographer。记得将Cartographer添加到你的系统路径中,以便在任何目录下都可以使用它: ``` export CARTOGRAPHER_PATH=<path_to_cartographer> export PATH=$CARTOGRAPHER_PATH:$PATH ``` 希望以上步骤对你有所帮助!
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值