cartographer analysis - first chapter
来源:互联网 发布:ubuntu ifconfig 编辑:程序博客网 时间:2024/05/02 04:36
为了分析这个代码的运行原理,首先切到最初的版本,这样的简化代码有利于理解cartographer的运行基本方式。
如上是cartographer的调用入口。
Node 是一个类,run 函数调用了Node的三个接口:构造函数,以及SpinForever, Initialize.
可以看到仅开放了main函数调用的方法。
Initialize()方法:
1. subscribe to IMU
2. subscribe to laser: 3 types
const bool has_laser_scan_2d = node_handle_.hasParam("laser_scan_2d_topic");const bool has_multi_echo_laser_scan_2d = node_handle_.hasParam("multi_echo_laser_scan_2d_topic");const bool has_laser_scan_3d = node_handle_.hasParam("laser_scan_3d_topics");
以下集中分析2d 这种case
if (has_laser_scan_2d) { const string topic = GetParamOrDie<string>("laser_scan_2d_topic"); laser_2d_subscriber_ = node_handle_.subscribe(topic, kSubscriberQueueSize, &Node::LaserScanMessageCallback, this); expected_sensor_identifiers.insert(topic); }
这里注册了回调函数LaserScanMessageCallback
。
接下里,定义了用于sparse graph optimization的对象:sparse_pose_graph_
auto sparse_pose_graph_2d = ::cartographer::common::make_unique< ::cartographer::mapping_2d::SparsePoseGraph>( ::cartographer::mapping::CreateSparsePoseGraphOptions(lua_parameter_dictionary.GetDictionary("sparse_pose_graph").get()), &thread_pool_, &constant_node_data_);trajectory_builder_ = ::cartographer::common::make_unique< ::cartographer::mapping_2d::GlobalTrajectoryBuilder> (::cartographer::mapping_2d::CreateLocalTrajectoryBuilderOptions(lua_parameter_dictionary.GetDictionary("trajectory_builder").get()),sparse_pose_graph_2d.get());sparse_pose_graph_ = std::move(sparse_pose_graph_2d);
可以看到对于class 的数据成员,遵循了后缀下划线的风格惯例。代码中大量采用了C++11的语法,std::move
将左值转换成右值。
在Initialize()
最后,会调用:
那么HandleSensorData函数又做了什么?
所以会根据不同的sensor 类型,调用对应的Add方法。
如下包含了2个Add和两个回调函数的实现上:
通过回调函数,imu
和laser
数据都会被传入到sensor_data
的AddSensorData
方法中。
可以发现Add操作分别调用了trajectory_builder_->AddImuData 和trajectory_builder_->AddHorizontalLaserFan
。
0 0
- cartographer analysis - first chapter
- cartographer analysis - second chapter
- cartographer source analysis
- Architectural Analysis (Brief Chapter)
- !!!Chapter 2 Algorithm Analysis
- !!!Chapter 11 Amortized Analysis
- CHAPTER 2 System Performance Analysis
- cartographer
- cartographer
- Chapter 6. First Contact: DirectDraw
- CHAPTER 3 SQL Query Performance Analysis
- Head First Object-Oriented Analysis and Design
- Chapter 2 The first steps in Vim
- Head First Python Notes - Chapter 5
- Head First Python Notes - Chapter 6
- Chapter 4: The First Way - Accelerate Flow
- head first java 笔记 chapter 1~3
- head first java 笔记 chapter 4~7
- linux update git
- 生命倒计时-倒数9116日
- 安卓漫漫路之读取本地html文件.
- C#中子类对父类中虚方法的处理有重写(override)和覆盖(new),他们有什么区别?
- json
- cartographer analysis - first chapter
- 程序设计:小学生考试系统(三)
- 使用了 :before 等伪元素中的其中一个来做 animation 动画; 在 animation 动画改变了其中的某个 rem 的值; 在这样的前提下,又是使用有这个 bug 的版本浏览器,那么就
- python学习——运算符
- Unity发布的ios包在iphone上声音小的原因
- 深入研究java.lang.Object类
- HTML入门学习笔记--基础标签(2)
- Linux 下 pip 升级遇到的问题 python3.5
- Android Service AIDL 简单使用