ROS中安裝使用cartographer
一、在安裝cartographer前,需要系統滿足如下的要求:
- 64-bit, modern CPU (e.g. 3rd generation i7)
- 16 GB RAM
- Ubuntu 14.04 (Trusty)
- gcc version 4.8.4
- ROS Indigo
本人是自己設計製作的機器人平臺,只有一個鐳射雷達感測器URG-04LX-UG01。本人就是利用這個感測器實現的SLAM。
二、安裝過程及命令:
# 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_ros.rosinstall file and fetch code for dependencies.
wstool merge -t src https://raw.githubusercontent.com/googlecartographer/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src
# Install deb dependencies.
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
備註:
問題:在catkin_make_isolated –install –use-ninja這一步,需要連線國外網下載ceres-solver,如果沒有翻牆,會提示下載ceres-solver失敗。
解決方法:
1.購買個VPN,連上國外網,翻牆後再執行該步驟的命令
- 開啟下面這個檔案,修改git下載的地址
build_isolated/ceres_solver/install/ceres_src-prefix/tmp/ceres_src-gitclone.cmake
黑體部分修改成如下這樣
while(error_code AND number_of_tries LESS 3)
execute_process(
COMMAND “/usr/bin/git” clone “https://github.com/ceres-solver/ceres-solver” “ceres_src”
WORKING_DIRECTORY
修改好後從新執行該步驟命令
三、執行google提供的demo,顯示google採集到的一個房間的地圖:
# Download the 2D backpack example bag.
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/backpack_2d/cartographer_paper_deutsches_museum.bag
# Launch the 2D backpack demo.
roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}/Downloads/cartographer_paper_deutsches_museum.bag
備註,在執行測試這個demo的過程中,本人出現了兩個錯誤:
1.rviz提示錯誤。原因是我是用teamviewer遠端連到機器人上操作的,而rviz無法在遠端執行顯示。所以本人只好在機器人上接上了顯示器,這樣rviz就能正常運行了
2.playbag提示錯誤。原因是cartographer_paper_deutsches_museum.bag這個包沒有完整下載。完整下載應該是500M左右。
四、利用cartographer,實現實時的構圖定位
1.先將鐳射雷達節點的執行起來
rosrun hokuyo hokuyo
2.修改demo_revo_lds.launch
vim demo_revo_lds.launch
修改後的檔案如下:
1 2 3 4 5 6 7 |
<
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 revo_lds.lua"</code> <code class="xml color1">output</code><code class="xml plain">=</code><code class="xml string">"screen"</code><code class="xml plain">></code></div><div class="line number4 index3 alt1"><code class="xml spaces"> </code><code class="xml plain"><</code><code class="xml keyword">remap</code> <code class="xml color1">from</code><code class="xml plain">=</code><code class="xml string">"scan"</code> <code class="xml color1">to</code><code class="xml plain">=</code><code class="xml string">"scan"</code> <code class="xml plain">/></code></div><div class="line number5 index4 alt2"><code class="xml spaces"> </code><code class="xml plain"></</code><code class="xml keyword">node</code><code class="xml plain">> </code></div><div class="line number6 index5 alt1"><code class="xml spaces"> </code><code class="xml plain"><</code><code class="xml keyword">node</code> <code class="xml color1">name</code><code class="xml plain">=</code><code class="xml string">"rviz"</code> <code class="xml color1">pkg</code><code class="xml plain">=</code><code class="xml string">"rviz"</code> <code class="xml color1">type</code><code class="xml plain">=</code><code class="xml string">"rviz"</code> <code class="xml color1">required</code><code class="xml plain">=</code><code class="xml string">"true"</code> <code class="xml color1">args</code><code class="xml plain">=</code><code class="xml string">"-d $(find cartographer_ros)/configuration_files/demo_2d.rviz"
/>
</
launch
>
|
3.修改配置引數檔案revo_lds.lua
vim ../configuration_files/revo_lds.lua
修改後的檔案如下:
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
include "map_builder.lua"
options = { map_builder = MAP_BUILDER,
sensor_bridge = {
horizontal_laser_min_range = 0.3,
horizontal_laser_max_range = 5.6,
horizontal_laser_missing_echo_ray_length = 1.2,
constant_odometry_translational_variance = 0.,
constant_odometry_rotational_variance = 0.,
},
map_frame = "map",
tracking_frame = "laser",
published_frame = "laser",
odom_frame = "odom",
provide_odom_frame = true,
use_odometry_data = false,
use_horizontal_laser = true,
use_horizontal_multi_echo_laser = false,
num_lasers_3d = 0,
lookup_transform_timeout_sec = 0.2,
submap_publish_period_sec = 0.3,
pose_publish_period_sec = 5e-3,
}
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
return options
|
4.重新編譯
catkin_make_isolated –install –use-ninja
5.執行指令碼進行實時構圖定位
roslaunch cartographer_ros demo_revo_lds.launch
備註:
1.如果您使用的鐳射雷達不同,上面修改demo_revo_lds.launch和配置引數檔案revo_lds.lua可能需要做相應的調整。
本人部落格:http://blog.csdn.net/happiness_jia/article/details/52856197
參考資料:
https://google-cartographer-ros.readthedocs.io/en/latest/index.html
http://wiki.ros.org/hokuyo_node/Tutorials/UsingTheHokuyoNode
</div>
<div class="clear"></div>
</div>