cartographer之运行自己的bag包
要注意的是:在carto src目录下改变文件之后,不仅仅是代码,配置文件及launch文件之后,需要重新编译一下,系统会将改变后的文件安装到指定目录,才会生效。
参考carto的3D 的demo,从launch文件看起:
<launch><param name="/use_sim_time" value="true" /><include file="$(find cartographer_ros)/launch/backpack_3d.launch" /><node name="rviz" pkg="rviz" type="rviz" required="true"args="-d $(find cartographer_ros)/configuration_files/demo_3d.rviz" /><node name="playbag" pkg="rosbag" type="play"args="--clock $(arg bag_filename)" />
</launch>
可以看到在启动该launch文件后,还会再启动carto的launch文件夹中 $(findcartographer_ros)/launch/backpack_3d.launch,那么我们接下来看该launch又开启了什么
<launch><param name="robot_description"textfile="$(find cartographer_ros)/urdf/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 backpack_3d.lua"output="screen"><remap from="points2_1" to="horizontal_laser_3d" /><remap from="points2_2" to="vertical_laser_3d" /><!--remap from="points2" to="vertical_laser_3d" /--><remap from="imu" to="imu" /></node><node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
</launch>
由此,明了启动顺序与文件。
1.先是启动/urdf/backpack_3d.urdf,它是机器人描述文件,结合ros 下robot_state_publisher节点,能够发布出机器人关节的静态TF,因此我们知道,这个文件结合robot_state_publisher是提供静态TF,那么针对不同机器人,不同IMU、Lidar的布置形式,其对应的TF是不同的。
因此,如果需要跑自己的数据包,就需要搞清楚自己数据包的机器的布置。
我照着backpack_3d.urdf写了一个自己的urdf文件,my_fang_3d.urdf
<robot name="cartographer_TYWL_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"><visual><origin xyz="0 0 0" /><geometry><box size="0.06 0.04 0.02" /></geometry><material name="orange" /></visual></link><link name="velodyne"><visual><origin xyz="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" /><origin xyz="0.5 -0.1 0.6" rpy="0 0 0" /></joint><joint name="velodyne_link_joint" type="fixed"><parent link="base_link" /><child link="velodyne" /><origin xyz="0.5 0.0 0.7" rpy="0. 0 0" /></joint>
</robot>
添加自己的IMU,名称需要和录制的包imu话题的frame_id一致,base_link不需要改;主要还要改的就是imu_link_joint的参数,指代的实际传感器与base的静态TF。
2.通过看原demo可以发现,
它加载了/configuration_files -configuration_basename backpack_3d.lua",因此我自己写了一个新的.lua文件。robot_3d.lua:
options = {map_builder = MAP_BUILDER,trajectory_builder = TRAJECTORY_BUILDER,map_frame = "map",tracking_frame = "imu", --"base_link"published_frame = "base_link", --"base_link"odom_frame = "odom",provide_odom_frame = true,publish_frame_projected_to_2d = false,use_pose_extrapolator = true,use_odometry = false,use_nav_sat = false, --这里选择是否用GPS,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 = 160MAP_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
3. 根据自己数据包设置ros remap映射,新建一个demo_robot_3D.launch
<launch><!--加载小车模型--><!-- <param name="robot_description"textfile="$(find cartographer_ros)/urdf/minibus.urdf" /> --><param name="robot_description"textfile="$(find cartographer_ros)/urdf/my_fang_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 robot_3d.lua" output="screen"><!--这里是你自己3d点云雷达的话题--><!-- <remap from="points2" to="/minibus/front/lslidar_point_cloud" /> --><!--<remap from="points2_2" to="vertical_laser_3d" />--><remap from="/imu" to="/imu/data" /><remap from="/points2" to="/velodyne_points" /></node><node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
</launch>
4.新增一个最上层的launch文件,demo_fang_3d.launch
<launch><param name="/use_sim_time" value="true" /><include file="$(find cartographer_ros)/launch/demo_robot_3D.launch" /><node name="rviz" pkg="rviz" type="rviz" required="true"args="-d $(find cartographer_ros)/configuration_files/demo_3d.rviz" /><node name="playbag" pkg="rosbag" type="play"args="--clock $(arg bag_filename)" />
</launch>
以上步骤,讲述了新增自己数据包的launch文件,若按照方式设置完,即可进行建图,效果如下显示:
然后就是保存地图的环节,与上一个博客所示
(1) 结束轨迹:
rosservice call /finish_trajectory 0
(2)生成pbstream文件
rosservice call /write_state "{filename: '/home/fang/cartographer_ws/src/bags/2021-10-01-11-14-31.bag.pbstream', include_unfinished_submaps: 1}"
(3)生成地图
roslaunch cartographer_ros assets_writer_backpack_3d.launch bag_filenames:='/home/fang/cartographer_ws/src/bags/2021-10-01-11-14-31.bag' pose_graph_filename:=/home/fang/cartographer_ws/src/bags/2021-10-01-11-14-31.bag.pbstream'
此处调用了assets_writer_backpack_3d.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 assets_writer_backpack_3d.lua-urdf_filename $(find cartographer_ros)/urdf/backpack_3d.urdf-bag_filenames $(arg bag_filenames)-pose_graph_filename $(arg pose_graph_filename)"output="screen"></node>
</launch>
文件调用了carto默认的backpack_3d.urdf,因而新增一个assets_writer_fang_3d.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 assets_writer_backpack_3d.lua-urdf_filename $(find cartographer_ros)/urdf/my_fang_3d.urdf-bag_filenames $(arg bag_filenames)-pose_graph_filename $(arg pose_graph_filename)"output="screen"></node>
</launch>
这一次就能够正常生成地图
cartographer之运行自己的bag包相关推荐
- 【ROS-cartographer学习小记-01】使用自己的激光雷达思岚A1运行cartographer,附代码以及bag包-直接运行即可看到结果
[ROS-cartographer学习小记-01]使用自己的激光雷达思岚A1运行cartographer 0.前提条件 1.修改revo_Ids.lua文件 3.修改demo_revo_lds.lau ...
- 把ros2录制的bag包转换为ros1格式的bag包
把ros2录制的bag包转换为ros1格式的bag包 1 安装ros2和ros1之间通信的库包 2 把录制的ros2的bag包转换ros1格式的bag包 2.1 启动ros2到ros1的桥 2.2 使 ...
- 怎么用ALOAM跑kitti数据集的bag包
1.查看你的bag包的topic是啥,如下图所示 我的topic是/kitti/velo/pointcloud; 3.打开scanRefistration.cpp,如下图所示 将/kitti/velo ...
- 从bag包中提取图片和点云数据为pcd格式点云文件
从bag包中提取图片和点云数据为pcd格式点云文件 1 开始提取bag包之前的准备工作 2 从bag包中提取图片和点云数据 首先说明一下我运行的系统环境: python2 Ubuntu18.04 RO ...
- kitti数据集转换bag包——图文教程
前言:在做实验言过程中遇到了想要使用kitti数据集,而我想要的输入数据为bag包文件,故而需要将kitti数据集转化为rosbag包,经过查找相关资料终于实现,现分享出来yon供大家一起交流使用,如 ...
- Elasticsearch的前后台运行与停止(rpm包方式)
对应,这es的下载,需要rpm包. Elasticsearch-2.4.3的下载(图文详解) 建议用root用户 [root@djt002 elasticsearch-2.4.3]$ pwd /usr ...
- java bat 运行 jar文件_运行bat文件启动java的jar且不弹出DOS窗口,后台运行java的jar包...
本文主要是将java的jar包启动的cmd命令添加到bat文件来执行,且不弹出DOS窗口,也就是后台运行java的jar包. 这里以win10为例 1.新建 一个txt文件,在文件添加以下内容.其中E ...
- Dockerfile文件创建centos:7,配置JDK8的环境变量,与运行springboot的jar包,的镜像
DockerFile文件创建centos:7 配置JDK8的环境变量 与运行springboot的jar包 准备文件 一:官网下载Linux的JDK包 https://www.oracle.com/j ...
- ros --- 录制imu bag包 和 imu标定
ros --- base notes ( tf ...) 1. ros 录制imu bag包 2. imu标定 创建 launch 文件 1. ros 录制imu bag包 rosbag 指令 ros ...
最新文章
- rocket mq整体架构
- 图标适配大小_主题真的是大吃一鲸适配全EMUI
- java学习笔记day06---匿名内部类
- 如何启用计算机超级账户,Windows7启用超级管理员账户的方法
- 独立开发者分享:游戏本地化的6个建议
- P2P技术如何拯救一家直播网站
- 安卓开发工程师面试题!春招我借这份PDF的复习思路,不吃透都对不起自己
- 2014牡丹江网络赛ZOJPretty Poem(暴力枚举)
- 一个下课的时间带你手写promise!
- 我是如何一步步拿下 Google Offer 的?
- 转:Gulp使用指南
- java自动行走_java数据结构实现机器人行走
- PyCharm中的Debug使用
- 服务器数据库文件恢复,数据库数据恢复
- HTML引用高德英文地图
- html压缩工具中文,HTML Compress(html压缩工具)
- selenium自动登录知网下载论文
- JS原生事件如何绑定
- javaweb面向对象
- 什么是API测试?开发必知的8种API自动化测试类型