# 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