之前在ubuntu20.04上成功安裝cartographer,但是翻遍全網都沒找到官方的22.04安裝教程,然后找到小魚的,試了一下,一次成功,連接如下:
gd2l-ros2/docs/humble/chapt10/get_started/2.Carto介紹及安裝.md at master · fishros/d2l-ros2https://github.com/fishros/d2l-ros2/blob/master/docs/humble/chapt10/get_started/2.Carto%E4%BB%8B%E7%BB%8D%E5%8F%8A%E5%AE%89%E8%A3%85.md
?
1.Carttographer安裝
1.1 apt安裝
安裝carotgrapher
sudo apt install ros-humble-cartographer
需要注意我們不是直接使用cartographer
,而是通過cartographer-ros
功能包進行相關操作,所以我們還需要安裝下cartographer-ros
sudo apt install ros-humble-cartographer-ros
1.2 源碼安裝
小魚推薦源碼安裝方式,將下面的源碼克隆到工作空間的src目錄下:
git clone https://ghproxy.com/https://github.com/ros2/cartographer.git -b ros2
git clone https://ghproxy.com/https://github.com/ros2/cartographer_ros.git -b ros2
安裝依賴
這里我們使用小魚的rosdepc進行依賴的安裝,rosdepc指令找不到可以先運行下面的一鍵安裝命令,選擇一鍵配置rosdep即可。
wget http://fishros.com/install -O fishros && . fishros
接著在工作空間下運行下面這個命令進行依賴的安裝。
rosdepc 是小魚制作的國內版rosdep,是一個用于安裝依賴的工具。該工具的安裝可以采用一鍵安裝進行,選項編號為3。安裝完成后運行一次rodepc update即可使用。
rosdepc install -r --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y
編譯
這里有一個新的命令--packages-up-to,意思是其所有依賴后再編譯該包
colcon build --packages-up-to cartographer_ros
1.3 測試是否安裝成功
如果是源碼編譯請先source下工作空間后再使用下面指令查看是否安裝成功;
ros2 pkg list | grep cartographer
能看到下面的結果即可
cartographer_ros
cartographer_ros_msgs
可能你會好奇為什么沒有cartographer,因為cartographer包的編譯類型原因造成的,不過沒關系,cartographer_ros依賴于cartographer,所以有cartographer_ros一定有cartographer。