cartographer建图参数注释及配置修改
⽂章⽬录
建图命令:
录完包之后,运⾏以下命令,会播放包内容。
roslaunch cartographer_ros demo_backpack_2d.launch bag_filenames:=XXX.bag
播放结束后,再运⾏以下命令,⽣成pbstream⽂件。
rosrvice call /finish_trajectory 0
rosrvice call /write_state "filename: '${HOME}/Downloads/XXXX.pbtream'"
再将pbtream⽂件转化成pgm和yaml⽂件。
rosrun cartographer_ros cartographer_pbstream_to_ros_map -map_filestem=./XXX.pgm -pbstream_filename=./XXXX.pbstream -resolution=0.05
完成建图,⽣成⼀张地图作为导航的底图---END
⼀、demo_backpack_2d.launch
demo_backpack_2d.launch为启动⽂件,主要包括:
(1)backpack_2d.launch⽂件——>主要修改对象。
文化自信的重要性
(2)demo_2d.rviz⽂件——>主要⽤于显⽰,暂不⽤修改。
<launch>
<param name="/u_sim_time" value="true"/>
<include file="$(find cartographer_ros)/launch/backpack_2d.launch"/>
<node name="rviz" pkg="rviz" type="rviz" required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz"/>
<node name="playbag" pkg="rosbag" type="play"
args="--clock $(arg bag_filename)"/>
</launch>
⼆、backpack_2d.launch
backpack_2d.launch⽂件主要包括:
(1)backpack_2d.urdf⽂件——机器⼈描述⽂件
(2)backpack_2d.lua⽂件——配置⽂件
<launch>
非感染性发热
<!--机器⼈描述⽂件-->
<param name="robot_description"
textfile="$(find cartographer_ros)/urdf/backpack_2d.urdf"/>
<!--机器⼈状态发布,,,⾥程计信息??-->
<node name="robot_state_publisher" pkg="robot_state_publisher"
type="robot_state_publisher"/>
<!--cartographer建图节点,调⽤配置参数-->
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_baname backpack_2d.lua"
output="screen">
<!--remap "scan"根据⾃⼰的激光雷达类型配置-->
<remap from="scan" to="scan"/>
</node>
<!--栅格地图节点-->
<node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
type="cartographer_occupancy_grid_node" args="-resolution 0.05"/>
</launch>
三、backpack_2d.urdf
<robot name="cartographer_backpack_2d">
<material name="orange">
<color rgba="1.0 0.5 0.2 1"/>
</material>
<material name="gray">
<color rgba="0.2 0.2 0.2 1"/>
</material>
<!--name "lar"修改成⾃⼰的-->
<link name="lar">
<visual>
<origin xyz="0 0 0"/>
<geometry>
<cylinder length="0.05" radius="0.03"/>
</geometry>
<material name="gray"/>
</visual>
</link>
<link name="ba_link"/>
<!--name="lar_link_joint"修改成⾃⼰的-->
<!--link="lar"修改成⾃⼰的-->
<joint name="lar_link_joint" type="fixed">
<parent link="ba_link"/>
<child link="lar"/>
<!--ypy:row,pich,yaw;x,y,z为雷达安装的位置。以ba_link为基点,ba_link为⼩车的中⼼点--> <origin rpy="0 0 0" xyz="0.05 0 0.2"/>
</joint>
</robot>
四、backpack_2d.lua
backpack_2d.lua主要包括:
(1)map_builder.lua⽂件
(2)trajectory_builder.lua⽂件
include "map_builder.lua"
include "trajectory_builder.lua"
options ={
map_builder = MAP_BUILDER,
trajectory_builder = TRAJECTORY_BUILDER,
map_frame ="map",
tracking_frame ="ba_link",--如果有imu填imu,没有imu则⽤ba_link
published_frame ="odom",--有odom⼀般⽤odom,没有odom⼀般⽤ba_link
odom_frame ="odom",
provide_odom_frame =fal,--底盘提供了⾥程计,这⾥不使⽤算法提供的⾥程计;如果没有底盘提供,则可以⽤cartographer提供的⾥程计,这⾥摄制成tr ue
publish_frame_projected_to_2d =fal,
u_po_extrapolator =true,--使能位姿
u_odometry =true,--是否使⽤⾥程计(底盘提供)
u_nav_sat =fal,
u_landmarks =fal,
num_lar_scans =1,-- 激光雷达数量
num_multi_echo_lar_scans =0,--google提供的激光雷达,这⾥⽤不到,为0
num_subdivisions_per_lar_scan =1,--每扫描⼀帧作为⼀帧,原始值为10帧为⼀帧
num_point_clouds =0,
lookup_transform_timeout_c =0.2,
submap_publish_period_c =0.3,
上英语课的英语
po_publish_period_c =5e-3,
trajectory_publish_period_c =30e-3,
rangefinder_sampling_ratio =1.,
odometry_sampling_ratio =1.,
fixed_frame_po_sampling_ratio =1.,
imu_sampling_ratio =1.,
landmarks_sampling_ratio =1.,
}
MAP_BUILDER.u_trajectory_builder_2d =true--对应map_builder.lua⽂件,这⾥设置成true.
TRAJECTORY_BUILDER_2D.num_accumulated_range_data =4--每4帧取⼀帧,防⽌雷达帧率太⾼耗费计算资源,可以减少计算量
return options
五、map_builder.lua
-- MAP_BUILDER.u_trajectory_builder_2d = true所以这⾥的参数都为true
include "po_graph.lua"
MAP_BUILDER ={
u_trajectory_builder_2d =fal,
u_trajectory_builder_3d =fal,
num_background_threads =4,
po_graph = POSE_GRAPH,
collate_by_trajectory =fal,
}
六、trajectory_builder.lua
trajectory_builder.lua⽂件包括:
(1)trajectory_builder_2d.lua
(2)trajectory_builder_3d.lua
include "trajectory_builder_2d.lua"
include "trajectory_builder_3d.lua"
TRAJECTORY_BUILDER ={
trajectory_builder_2d = TRAJECTORY_BUILDER_2D,
trajectory_builder_3d = TRAJECTORY_BUILDER_3D,
-- pure_localization_trimmer = {
-- max_submaps_to_keep = 3,
-- },
collate_fixed_frame =true,
collate_landmarks =fal,
}
七、trajectory_builder_2d.lua(⽣成较好的⼦图)
TRAJECTORY_BUILDER_2D ={
--没有接⼊imu,设置fal。2D SLAM 可选 IMU;3D SLAM 必选 IMU。
高二学生期末总结--[[2D 订阅IMU话题后,将由imu话题来计算运动的⾓速度值,同时激光雷达俯仰⾓度变化后,
也可以将⼀定⾼度范围内的点云投影到平⾯上。]]
u_imu_data =fal,
-- 激光雷达数据的有效范围,需根据传感器参数和机器⼈⼯作场景确定。
min_range =0.,--激光雷达探测的深度最⼩距离(最近距离)
max_range =30.,--激光雷达探测的深度最⼤距离(最远距离)
min_z =-0.8,--激光雷达探测的⾼度最⼩距离(最低距离)
max_z =2.,--激光雷达探测的⾼度最⼤距离(最⾼距离)
missing_data_ray_length =5.,--当传感器数据超出有效范围最⼤值时,按此值来处理。默认配置为5m,⼩于最⼤距离30m。 num_accumulated_range_data =1,--积累到这个数量的点云信息后,执⾏⼀次匹配scan_match,将有效点云插⼊局部地图--[[由于激光雷达的基于原点旋转扫描采样,距离近的障碍物采集数据密集,
距离远的障碍物采集点稀疏,为保证远近障碍物权重⼀致,需做处理。采⽤体素滤波器进⾏降采样机制,
使得局部稠密的点变得稀疏。此值越⼩,得到的数据越稠密,但是计算量越⾼;此值越⼤,丢失数据越多,但计算更快。]]
voxel_filter_size =0.025,
--⾃适应体素滤波器adaptive voxel filter参数配置,⾃适应得出的参数在配置参数范围内。
adaptive_voxel_filter ={
max_length =0.5,
min_num_points =200,
max_range =50.,
},
loop_closure_adaptive_voxel_filter ={
max_length =0.9,
min_num_points =100,
max_range =50.,
},
什么是春天的使者--[[局部local SLAM部分,两种匹配策略:CeresScanMatcher和RealTimeCorrelativeScanMatcher]]
-
- RealTimeCorrelativeScanMatcher启⽤和参数配置
-- 设置成true,启⽤
u_online_correlative_scan_matching =true,
--[[RealTimeCorrelativeScanMatcher:⽤于传感器质量较差场合,该算法拥有类似于回环检测的特点,
具有环境鲁棒性,但耗费计算资源。]]
real_time_correlative_scan_matcher ={
-- 搜索窗⼝
linear_arch_window =0.1,
angular_arch_window = math.rad(20.),
-- 权重
translation_delta_cost_weight =1e-1,
rotation_delta_cost_weight =1e-1,
},
-- CeresScanMatcher:⽤于⾼质量的传感器场合;
ceres_scan_matcher ={
occupied_space_weight =1.,
--下⾯两个权重是指:PoExtrapolator或者RealTimeCorrelativeScanMatcher的权重;
translation_weight =10.,
rotation_weight =40.,
-- Ceres匹配算法收敛速度配置
ceres_solver_options ={
-- 含义:bool量,启动⾮单调置信区域;
u_nonmonotonic_steps =fal,
-- 含义:最⼤迭代步数;
max_num_iterations =20,
-- 含义:线程数;
num_threads =1,
},
},
--[[motion filter配置:为了防⽌⼀个submap中插⼊太多scan数据,加⼊motion filter,
在移动不明显时丢弃点云数据。满⾜以下条件,则丢弃。有效帧的判断阈值参数⼊下:]]
motion_filter ={
-- 时间间隔
max_time_conds =5.,
-- 平移距离
max_distance_meters =0.2,
-- 旋转⾓度1rad=180/2pi=28.7
max_angle_radians = math.rad(1.),
},
-- TODO(schwoere,wohe): Remove this constant. This is only kept for ROS.
imu_gravity_time_constant =10.,
po_extrapolator ={心得体会格式
u_imu_bad =fal,
constant_velocity ={
imu_gravity_time_constant =10.,
po_queue_duration =0.001,
},
imu_bad ={
po_queue_duration =5.,
gravity_constant =9.806,
po_translation_weight =1.,
po_rotation_weight =1.,
imu_acceleration_weight =1.,
imu_rotation_weight =1.,
odometry_translation_weight =1.,
odometry_rotation_weight =1.,
solver_options ={
微信不能登录
u_nonmonotonic_steps =fal;
max_num_iterations =10;
num_threads =1;
},
},
},
-- Submaps⼤⼩规格配置眺望远方
submaps ={
--Submaps由⼀定数量的range data构成。Submaps越⼩,内部漂移越⼩;Submaps越⼤,越有利于全局定位的回环检测。 num_range_data =90,
--栅格地图格式:通常为PROBABILITY_GRID格式,也可选Truncated Signed Distance Fields (TSDF)格式。
grid_options_2d ={
grid_type ="PROBABILITY_GRID",
--地图分辨率配置:2D地图仅有⼀个分辨率配置项
resolution =0.05,
},
--概率栅格地图占有概率计算权重
range_data_inrter ={
range_data_inrter_type ="PROBABILITY_GRID_INSERTER_2D",