Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephcoombe/aea36f03b1d511dac5b1b87be253d00f to your computer and use it in GitHub Desktop.
Save josephcoombe/aea36f03b1d511dac5b1b87be253d00f to your computer and use it in GitHub Desktop.
Install Google Cartographer and Local Protobuf Version. Based on https://gist.github.com/l1va/630043c4a23e6b3f5c73c088ba6b62d5
# Install Google Cartographer and Local Protobuf Version
#
# Based on:
# install_cartographer_proto_locally.sh: https://gist.github.com/l1va/630043c4a23e6b3f5c73c088ba6b62d5
#
# References:
# Cartographer ROS Integration: https://google-cartographer-ros.readthedocs.io/en/latest/index.html
# Compiling Cartographer ROS: https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html
# This file was generated by an older version of protoc - #625: https://github.com/googlecartographer/cartographer_ros/issues/625
# Issue8557 - subprocess PATH semantics and portability: https://bugs.python.org/issue8557
# Python does not find System32: https://stackoverflow.com/a/41631476/8670609
# `catkin_ws` is the name of your catkin_ws
cd ~/catkin_ws
# Install wstool and rosdep.
sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build
# Build sources with old protobuf firstly
# Note: This step is optional
catkin_make_isolated --install --use-ninja -DCATKIN_ENABLE_TESTING=false
# Get Google Cartographer ROS code
wstool init src
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
# Install proto3 locally.
# Build and install in 'catkin_ws/protobuf/install' proto3.
#set -o errexit
#set -o verbose
VERSION="v3.4.1"
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout tags/${VERSION}
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=../install \
../cmake
ninja
ninja install
cd ../../
# 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.
CMPF=${CMAKE_PREFIX_PATH//:/;}
catkin_make_isolated --install --use-ninja \
-DCMAKE_PREFIX_PATH="${PWD}/install_isolated;${PWD}/protobuf/install;${CMPF}" \
-DCATKIN_ENABLE_TESTING=false
# Source in separate terminal if you need to build there as well
source install_isolated/setup.bash
# Note: You may want to build google_cartographer_ros in a separate
# catkin_ws and then overlay your primary catkin_ws on top.
# In new terminal:
# $ cd ../my_other_catkin_ws
# $ catkin_make
# $ source install_isolated/setup.bash
# $ catkin_make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment