Ubuntu18.04 cartographer

安装abseil

cd ~/3rdparty
git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
git checkout d902eb869bcfacc1bad14933ed9af4bed006d481
mkdir build
cd build
cmake -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DCMAKE_INSTALL_PREFIX=/usr/local/stow/absl \
  ..
ninja
sudo ninja install
cd /usr/local/stow
sudo stow absl

protobuf:依据个人情况是否安装proto3. (如果已经安装完ros,就不要在执行这条命名,因为ros里面已经安装了,不然会冲突

参考:

ubuntu18.04 源码安装cartorgrapher详细步骤(2021.5.16亲测有效)_大葱聪的博客-CSDN博客

Cartographer算法安装与仿真经历(ubuntu18.04)_cartographer小鱼安装_秋…雨的博客-CSDN博客

-------------------------------20230614-------雷达配置使用-----------------------------------------------------------

 用于启动cartographer_node

cd src/cartographer_ros/cartographer_ros/launch然后创建这个launch文件

<launch>
  <param name="/use_sim_time" value="false" />

  <node name="cartographer_node" pkg="cartographer_ros"
      type="cartographer_node" args="
          -configuration_directory $(find cartographer_ros)/configuration_files
          -configuration_basename rs16_lidar.lua"
      output="screen">
    <remap from="scan" to="/scan" />
  </node>
  
  <node pkg="tf" type="static_transform_publisher" name="base_to_laser" args="0.0 0.0 0.45 0 0.0 0.0 map rslidar 100" />

  <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_2d.rviz" />
</launch>

        其中configuration_directory和configuration_basename表示的是.lua文件的目录和名字。.lua文件在cartographer运行的时候需要读取其中的参数。

        node pkg="tf"是表示小车底盘坐标系和世界坐标系之间的关系。

        node name="cartographer_occupancy_grid_node"通过运行cartographer_ros下的cartographer_occupancy_grid_node这个节点,Cartographer将根据之前建立的地图和轨迹数据,生成一个占用栅格地图,并在ROS中发布该地图。分辨率为0.05。

        最后这个节点,将启动rviz可视化工具,并加载指定的配置文件demo_2d.rviz。该配置文件将显示Cartographer生成的地图、轨迹和其他传感器数据,以便进行可视化和调试。

.lua文件配置

cd src/cartographer_ros/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 = "rslidar",
  published_frame = "rslidar",
  odom_frame = "odom",
  provide_odom_frame = false,
  publish_frame_projected_to_2d = false,
  use_pose_extrapolator = on,
  use_odometry = false,
  use_nav_sat = false,
  use_landmarks = false,
  num_laser_scans = 1,
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 1,
  num_point_clouds = 0,
  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.,
}

MAP_BUILDER.use_trajectory_builder_2d = true

TRAJECTORY_BUILDER_2D.ceres_scan_matcher.translation_weight = 2
TRAJECTORY_BUILDER_2D.ceres_scan_matcher.rotation_weight = 10
TRAJECTORY_BUILDER_2D.submaps.num_range_data = 90
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1

POSE_GRAPH.optimization_problem.huber_scale = 1e2
POSE_GRAPH.optimize_every_n_nodes = 35
POSE_GRAPH.constraint_builder.min_score = 0.65

return options

        首先包含map_builder.luatrajectory_builder.lua文件中的配置

        

  • map_frame:设置地图坐标系的名称为"map"。

  • tracking_frame:设置跟踪帧的名称为"rslidar"。

  • published_frame:设置发布帧的名称为"rslidar"。

  • odom_frame:设置里程计坐标系的名称为"odom"。

  • provide_odom_frame:设置是否提供里程计坐标系为false,表示不提供。

  • publish_frame_projected_to_2d:设置是否发布经过2D投影的帧为false

  • use_pose_extrapolator:设置是否使用姿态外推器为on

  • use_odometryuse_nav_satuse_landmarks:设置是否使用里程计、卫星导航和地标的数据为false

  •   num_laser_scans = 1:雷达的个数

创建pointcloud_to_laserscan

cd src
git clone https://github.com/BluewhaleRobot/pointcloud_to_laserscan.git
cd xxx_ws
catkin_make
cd src/pointcloud_to_laserscan/launch
<?xml version="1.0"?>

<launch>

    <!-- run pointcloud_to_laserscan node -->
    <node pkg="pointcloud_to_laserscan" type="pointcloud_to_laserscan_node" name="pointcloud_to_laserscan">

        <remap from="cloud_in" to="/rslidar_points"/>
        
        <rosparam>
            # target_frame: rslidar # Leave disabled to output scan in pointcloud frame
            transform_tolerance: 0.01
            min_height: -0.4
            max_height: 1.0

            angle_min: -3.1415926 # -M_PI
            angle_max: 3.1415926 # M_PI
            angle_increment: 0.003 # 0.17degree
            scan_time: 0.1
            range_min: 0.2
            range_max: 100
            use_inf: true
            inf_epsilon: 1.0

            # Concurrency level, affects number of pointclouds queued for processing and number of threads used
            # 0 : Detect number of cores
            # 1 : Single threaded
            # 2->inf : Parallelism level
            concurrency_level: 1
        </rosparam>

    </node>

</launch>

参考:RoboSense(速腾)16线激光雷达数据进行cartographer建图的实践历程_%zoe%的博客-CSDN博客

------------------------------------------20230629---------------------------------------------- 

用自己的雷达跑cartographer

0 这里使用这个项目

GitHub - xiangli0608/cartographer_detailed_comments_ws: cartographer work space with detailed comments

首先创建一个工作空间并且catkin_make

然后把这个项目复制到src中,然后使用Vscode的Ctrl+Shift+B编译即可

(注:打开vscode的json文件可以看到编译使用的语句是:"catkin_make_isolated --install --use-ninja")

1 配置urdf文件,用于确定好安装的雷达和IMU之间的空间位姿关系(如果不使用imu就可以不配置urdf,使用imu建图更精准)

关于urdf文件,要么商家给你了,要么就只有自己量。

2 配置参数.lua文件

这一步则需要配置一下cartographer的TF树。这里的修改主要涉及到cartographer_ros/cartographer_ros/configuration_files下的lua文件中的几个参数:

map_frame = "map",  -- 默认即可
-- 如果没有imu,下面两个frame可以都修改为雷达的坐标系,通常为laser
-- 如果有imu需要将 tracking_frame 更改为imu的frame_id  
  tracking_frame = "base_link",  -- 一般为发布频率最高的传感器的 frame_id,有imu就用imu,不然就是雷达的frameid
  published_frame = "base_link",  -- 底盘的 frame_id
  odom_frame = "odom",    -- cartographer提供的里程计坐标系 frame_id 【与实际里程计无关】
  provide_odom_frame = false,  -- 是否使用cartographer提供的里程计坐标系

  num_laser_scans = 1,

如何查看frameid:(frame_id:用来告诉你,发布的数据是来自哪一个坐标系的。)

激光雷达简介与激光数据分析_雷达的frameid是什么_wongHome的博客-CSDN博客

# rostopic echo [topic]  | grep frame_id
# 查看我的imu话题的frame_id
 rostopic echo /wit/imu  | grep frame_id

# 查看雷达点云数据的frame_id
 rostopic echo /point_cloud_raw  | grep frame_id

我们还可以借助rviz,看看base_link坐标系下有没有对应的imu数据。如下图中,需要将Fixed frame修改为frame_id,同时需要添加一个Imu组件并选择对应的话题。如果一切正确,就可以看见如图一个箭头,箭头也会对应偏移(主要是体现在姿态角的变化)。

​ tracking_frame一般设置为发布频率最高的传感器的frame_id,cartographer将会把其他数据都转移到该坐标系下进行计算。如果只使用雷达数据进行2D建图,那就只需要将其设置为雷达数据话题的frame_id,一般为laser。如果使用雷达数据+IMU进行2D或者3D建图,因为IMU的发布频率明显高于雷达,所以需要设置为imu数据话题的frame_id,一般imu_link。我使用的Pixhawk飞控的imu的frame_id为base_link,故设置为base_link

3 launch文件

1)调用对应的配置文件 2)配置发布imu数据和雷达数据的话题

参考:Cartographer 3D实时建图教程(超详细) - 镭神C16 + IMU (一) - 知乎

---------------------------------------------wit imu配合cartographer----------------------------------------

官方文档:ROS Python使用说明 · 深圳维特智能科技有限公司

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值