当前位置: 代码迷 >> 综合 >> Cartographer 3D激光SLAM测试记录文档
  详细解决方案

Cartographer 3D激光SLAM测试记录文档

热度:83   发布时间:2023-12-13 07:14:40.0

Cartographer 3D激光SLAM测试记录文档

 

 1.硬件准备:

        速腾聚创16线激光雷达;

        xsense Ti_30 6轴IMU;(3D必须要IMU)

 2.到官网下载相关的ROS驱动文件编译安装相关。

 

开始测试:
 修改cartographer_ws/install_isolated/share/cartographer_ros/launch/目录下的launch文件:

 修改如下:


<launch><param name="/use_sim_time" value="false" /><!--include file="$(find rslidar_pointcloud)/launch/rs_lidar_16.launch" /><include file="$(find xsens_driver)/launch/xsens_driver.launch" /--><param name="robot_description" textfile="$(find cartographer_ros)/urdf/my_backpack_3d.urdf" /><node name="robot_state_publisher" pkg="robot_state_publisher"type="robot_state_publisher"/><node name="cartographer_node" pkg="cartographer_ros"type="cartographer_node" args="-configuration_directory $(find cartographer_ros)/configuration_files-configuration_basename my_backpack_3d.lua"output="screen"><remap from="points2" to="rslidar_points" /><remap from="imu" to="imu/data" /></node><node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"type="cartographer_occupancy_grid_node" args="-resolution 0.05" /><node name="rviz" pkg="rviz" type="rviz" required="true"args="-d $(find cartographer_ros)/configuration_files/demo_3d.rviz" /></launch>

 修改urdf文件(cartographer_ws/install_isolated/share/cartographer_ros/configuration_files/目录下)如下(具体参数看自己传感器的安装位置,这里并没有精确的去标定,下次补上):

<!--Copyright 2016 The Cartographer AuthorsLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
--><robot name="cartographer_backpack_3d"><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><link name="imu_link"><visual><origin xyz="0.0 0.0 0.0" /><geometry><box size="0.06 0.04 0.02" /></geometry><material name="orange" /></visual></link><link name="rslidar"><visual><origin xyz="0.0 0.0 0.0" /><geometry><cylinder length="0.07" radius="0.05" /></geometry><material name="gray" /></visual></link><link name="base_link" /><joint name="imu_link_joint" type="fixed"><parent link="base_link" /><child link="imu_link" /><origin xyz="0 0 0" rpy="0 0 0" /></joint><joint name="rslidar_link_joint" type="fixed"><parent link="base_link" /><child link="rslidar" /><origin xyz="0 0 -0.055" rpy="0. 0  0" /></joint></robot>

修改lua文件(cartographer_ws/install_isolated/share/cartographer_ros/configuration_files/目录下)如下:

include "map_builder.lua"
include "trajectory_builder.lua"options = {map_builder = MAP_BUILDER,trajectory_builder = TRAJECTORY_BUILDER,map_frame = "map",tracking_frame = "base_link",published_frame = "base_link",odom_frame = "odom",provide_odom_frame = true,publish_frame_projected_to_2d = false,use_odometry = false,use_nav_sat = false,use_landmarks = false,num_laser_scans = 0,num_multi_echo_laser_scans = 0,num_subdivisions_per_laser_scan = 1,num_point_clouds = 1,lookup_transform_timeout_sec = 0.2,submap_publish_period_sec = 0.3,pose_publish_period_sec = 5e-3,trajectory_publish_period_sec = 30e-3,rangefinder_sampling_ratio = 1.,odometry_sampling_ratio = 1.,fixed_frame_pose_sampling_ratio = 1.,imu_sampling_ratio = 1.,landmarks_sampling_ratio = 1.,
}TRAJECTORY_BUILDER_3D.num_accumulated_range_data = 1MAP_BUILDER.use_trajectory_builder_3d = true
MAP_BUILDER.num_background_threads = 7
POSE_GRAPH.optimization_problem.huber_scale = 5e2
POSE_GRAPH.optimize_every_n_nodes = 320
POSE_GRAPH.constraint_builder.sampling_ratio = 0.03
POSE_GRAPH.optimization_problem.ceres_solver_options.max_num_iterations = 10
POSE_GRAPH.constraint_builder.min_score = 0.62
POSE_GRAPH.constraint_builder.global_localization_min_score = 0.66return options


到此就配置完成了,这时候就可以在线跑3D的了,恩,比较懒,不想放图了。

---------------------------------------------------------

下面继续探索高大上的3D点云图的构建,可惜的是我们并不可以在线建立3D点云图,我们只能离线建图,具体为什么这样去看官网说明,这里不啰嗦了,之后想改成在线的,之后补上。

准备工作:

     因为并没有为了实时性,并没有在线建立点云功能,所以我们需要录取数据包rosbag,录制好之后,配置文件:

首先在cartographer_ws/install_isolated/share/cartographer_ros/launch/目录下创建launch文件如下:

<launch><param name="/use_sim_time" value="true" /><node name="rviz" pkg="rviz" type="rviz" required="true"args="-d $(find cartographer_ros)/configuration_files/demo_3d.rviz" /><node name="cartographer_offline_node" pkg="cartographer_ros"type="cartographer_offline_node" args="-configuration_directory $(find cartographer_ros)/configuration_files-configuration_basenames my_backpack_3d.lua-urdf_filenames $(find cartographer_ros)/urdf/my_backpack_3d.urdf-bag_filenames $(arg bag_filenames)"output="screen"><remap from="points2" to="rslidar_points" /><remap from="imu" to="imu/data" /></node><node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
</launch>

启动该launch文件后等待终端结束,我们就可以在当前目录下看到.pstream文件,进一步我们根据这个文件联合Rosbag包就可以恢复点云数据,继续配置文件:

cartographer_ws/install_isolated/share/cartographer_ros/launch/目录下配置launch文件:

<launch><node name="cartographer_assets_writer" pkg="cartographer_ros" required="true"type="cartographer_assets_writer" args="-configuration_directory $(find cartographer_ros)/configuration_files-configuration_basename my_assets_writer_backpack_3d.lua-urdf_filename $(find cartographer_ros)/urdf/my_backpack_3d.urdf-bag_filenames $(arg bag_filenames)-pose_graph_filename $(arg pose_graph_filename)"output="screen"></node>
</launch>

cartographer_ws/install_isolated/share/cartographer_ros/configuration_files文件下配置lua文件如下:

VOXEL_SIZE = 5e-2include "transform.lua"options = {tracking_frame = "base_link",pipeline = {{action = "min_max_range_filter",min_range = 1.,max_range = 60.,},{action = "dump_num_points",},-- Now we recolor our points by frame and write another batch of X-Rays. It-- is visible in them what was seen by the horizontal and the vertical-- laser.{action = "fixed_ratio_sampler",sampling_ratio = 0.05,},{action = "color_points",frame_id = "rslidar",color = { 255., 255., 255. },},{action = "write_pcd",filename = "map.pcd",},}
}return options

到这里就配置完了,启动该结点后得到pcd文件使用pcl_view显示如下(放张图,之后慢慢补):

 

 

 

 

  相关解决方案