Ethzasl MSF源码阅读(2):百川汇海
这里有个感觉,就是百川汇海。即IMU数据和相机的消息数据都汇集到msf_core进行处理。接上一篇,
1. 查看IMUHandler_ROS::IMUCallback和IMUHandler_ROS::StateCallback回调函数。
MUHandler_ROS::IMUCallback,传入的消息sensor_msgs::ImuConstPtr。
void IMUCallback(const sensor_msgs::ImuConstPtr & msg)
{
static int lastseq = constants::INVALID_SEQUENCE;
if (static_cast<int>(msg->header.seq) != lastseq +
&& lastseq != constants::INVALID_SEQUENCE) {
MSF_WARN_STREAM(
"msf_core: imu message drop curr seq:" << msg->header.seq
<< " expected: " << lastseq + );
}
lastseq = msg->header.seq; msf_core::Vector3 linacc;
linacc << msg->linear_acceleration.x, msg->linear_acceleration.y, msg
->linear_acceleration.z; msf_core::Vector3 angvel;
angvel << msg->angular_velocity.x, msg->angular_velocity.y, msg
->angular_velocity.z; this->ProcessIMU(linacc, angvel, msg->header.stamp.toSec(),
msg->header.seq);
}
IMUHandler_ROS::StateCallback,传入的参数sensor_fusion_comm::ExtEkfConstPtr,这个需要理解一下。
void StateCallback(const sensor_fusion_comm::ExtEkfConstPtr & msg)
{
static_cast<MSF_SensorManagerROS<EKFState_T>&>(this->manager_)
.SetHLControllerStateBuffer(*msg); // Get the imu values.
msf_core::Vector3 linacc;
linacc << msg->linear_acceleration.x, msg->linear_acceleration.y, msg
->linear_acceleration.z; msf_core::Vector3 angvel;
angvel << msg->angular_velocity.x, msg->angular_velocity.y, msg
->angular_velocity.z; int32_t flag = msg->flag;
// Make sure we tell the HL to ignore if data playback is on.
if (this->manager_.GetDataPlaybackStatus())
flag = sensor_fusion_comm::ExtEkf::ignore_state; bool isnumeric = true;
if (flag == sensor_fusion_comm::ExtEkf::current_state) {
isnumeric = CheckForNumeric(
Eigen::Map<const Eigen::Matrix<float, , > >(msg->state.data()),
"before prediction p,v,q");
} // Get the propagated states.
msf_core::Vector3 p, v;
msf_core::Quaternion q; p = Eigen::Matrix<double, , >(msg->state[], msg->state[],
msg->state[]);
v = Eigen::Matrix<double, , >(msg->state[], msg->state[],
msg->state[]);
q = Eigen::Quaternion<double>(msg->state[], msg->state[], msg->state[],
msg->state[]);
q.normalize(); bool is_already_propagated = false;
if (flag == sensor_fusion_comm::ExtEkf::current_state && isnumeric) {
is_already_propagated = true;
} this->ProcessState(linacc, angvel, p, v, q, is_already_propagated,
msg->header.stamp.toSec(), msg->header.seq);
}
查看IMUHandler_ROS类的父类IMUHandler的ProcessIMU和ProcessState方法,如下:
void ProcessIMU(const msf_core::Vector3& linear_acceleration,
const msf_core::Vector3& angular_velocity,
const double& msg_stamp, size_t msg_seq) {
core_->ProcessIMU(linear_acceleration, angular_velocity, msg_stamp,
msg_seq);
}
void ProcessState(const msf_core::Vector3& linear_acceleration,
const msf_core::Vector3& angular_velocity,
const msf_core::Vector3& p, const msf_core::Vector3& v,
const msf_core::Quaternion& q, bool is_already_propagated,
const double& msg_stamp, size_t msg_seq) {
core_->ProcessExternallyPropagatedState(linear_acceleration,
angular_velocity, p, v, q,
is_already_propagated,
msg_stamp, msg_seq);
}
可以发现对应了msf_core_的ProcessIMU和ProcessExternallyPropagatedState方法。
2. 查看PoseSensorHandler::MeasurementCallback回调函数。注意,在构造函数中挂载了三个不同的MeasurementCallback函数。
geometry_msgs::PoseWithCovarianceStamped,geometry_msgs::TransformStamped,geometry_msgs::PoseStamped三种消息类型。
template<typename MEASUREMENT_TYPE, typename MANAGER_TYPE>
void PoseSensorHandler<MEASUREMENT_TYPE, MANAGER_TYPE>::MeasurementCallback(
const geometry_msgs::PoseWithCovarianceStampedConstPtr & msg)
{
this->SequenceWatchDog(msg->header.seq,
subPoseWithCovarianceStamped_.getTopic());
MSF_INFO_STREAM_ONCE(
"*** pose sensor got first measurement from topic "
<< this->topic_namespace_ << "/"
<< subPoseWithCovarianceStamped_.getTopic() << " ***");
ProcessPoseMeasurement(msg);//注意
}
查看 ProcessPoseMeasurement(msg)函数:
template<typename MEASUREMENT_TYPE, typename MANAGER_TYPE>
void PoseSensorHandler<MEASUREMENT_TYPE, MANAGER_TYPE>::ProcessPoseMeasurement(const geometry_msgs::PoseWithCovarianceStampedConstPtr & msg)
{
received_first_measurement_ = true; // Get the fixed states.
int fixedstates = ;
static_assert(msf_updates::EKFState::nStateVarsAtCompileTime < , "Your state "
"has more than 32 variables. The code needs to be changed here to have a "
"larger variable to mark the fixed_states");
// Do not exceed the 32 bits of int. // Get all the fixed states and set flag bits.
MANAGER_TYPE* mngr = dynamic_cast<MANAGER_TYPE*>(&manager_); // TODO(acmarkus): if we have multiple sensor handlers, they all share the same dynparams,
// which me maybe don't want. E.g. if we have this for multiple AR Markers, we
// may want to keep one fix --> move this to fixed parameters? Could be handled
// with parameter namespace then.
if (mngr) {
if (mngr->Getcfg().pose_fixed_scale) {
fixedstates |= << MEASUREMENT_TYPE::AuxState::L;
}
if (mngr->Getcfg().pose_fixed_p_ic) {
fixedstates |= << MEASUREMENT_TYPE::AuxState::p_ic;
}
if (mngr->Getcfg().pose_fixed_q_ic) {
fixedstates |= << MEASUREMENT_TYPE::AuxState::q_ic;
}
if (mngr->Getcfg().pose_fixed_p_wv) {
fixedstates |= << MEASUREMENT_TYPE::AuxState::p_wv;
}
if (mngr->Getcfg().pose_fixed_q_wv) {
fixedstates |= << MEASUREMENT_TYPE::AuxState::q_wv;
}
} shared_ptr<MEASUREMENT_TYPE> meas(new MEASUREMENT_TYPE(
n_zp_, n_zq_, measurement_world_sensor_, use_fixed_covariance_,
provides_absolute_measurements_, this->sensorID,
enable_mah_outlier_rejection_, mah_threshold_, fixedstates, distorter_)); meas->MakeFromSensorReading(msg, msg->header.stamp.toSec() - delay_); z_p_ = meas->z_p_; //store this for the init procedure
z_q_ = meas->z_q_; this->manager_.msf_core_->AddMeasurement(meas);
}
这里调用了this->manager_.msf_core_->AddMeasurement(meas),查看AddMeasurement方法。
3.以上,最终对应于MSF_Core类的三个函数,即
ProcessIMU、ProcessExternallyPropagatedState、AddMeasurement。
4.MSF_Core类,MSF_core类负责汇集IMU消息和位姿观测值,同时实现了状态预测,而msf_updates::pose_measurement::PoseMeasurement<>实现了状态的更新。
这个在分析MSF_Core三个方法的时候再说明。

Ethzasl MSF源码阅读(2):百川汇海的更多相关文章
- Ethzasl MSF源码阅读(1):程序入口和主题订阅
关于IMU融合知乎上的一篇问答:有哪些开源项目是关于单目+imu做slam的? Ethz的Stephen Weiss的工作,是一个IMU松耦合的方法. 1.程序入口:ethzasl_msf\msf_u ...
- Ethzasl MSF源码阅读(3):MSF_Core和PoseMeasurement
1.MSF_Core的三个函数:ProcessIMU.ProcessExternallyPropagatedState和AddMeasurement MSF_Core维护了状态队列和观测值队列,这里需 ...
- 【原】FMDB源码阅读(三)
[原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...
- 【原】FMDB源码阅读(二)
[原]FMDB源码阅读(二) 本文转载请注明出处 -- polobymulberry-博客园 1. 前言 上一篇只是简单地过了一下FMDB一个简单例子的基本流程,并没有涉及到FMDB的所有方方面面,比 ...
- 【原】FMDB源码阅读(一)
[原]FMDB源码阅读(一) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 说实话,之前的SDWebImage和AFNetworking这两个组件我还是使用过的,但是对于 ...
- 【原】AFNetworking源码阅读(六)
[原]AFNetworking源码阅读(六) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 这一篇的想讲的,一个就是分析一下AFSecurityPolicy文件,看看AF ...
- 【原】AFNetworking源码阅读(五)
[原]AFNetworking源码阅读(五) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇中提及到了Multipart Request的构建方法- [AFHTTP ...
- 【原】AFNetworking源码阅读(四)
[原]AFNetworking源码阅读(四) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇还遗留了很多问题,包括AFURLSessionManagerTaskDe ...
- 【原】AFNetworking源码阅读(三)
[原]AFNetworking源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇的话,主要是讲了如何通过构建一个request来生成一个data tas ...
随机推荐
- python中字符串前的r什么意思
Python中,u表示unicode string,表示使用unicode进行编码,没有u表示byte string,类型是str,在没有声明编码方式时,默认ASCI编码.如果要指定编码方式,可在文件 ...
- slfj+logback
1.pom.xml <dependency> <groupId>org.projectlombok</groupId> <artifactId>lomb ...
- HIVE metastore Duplicate key name 'PCS_STATS_IDX' (state=42000,code=1061)
HDP 版本:2.4.0.0-169. 解决:将hive 所在 节点上的/usr/hdp/2.4.0.0-169/hive/script/metastore/upgrade/msql/hive-sch ...
- halcon之NCC匹配
NCC匹配 基于Normalized cross correlation(NCC)用来比较两幅图像的相似程度已经是一个常见的图像处理手段.在工业生产环节检测.监控领域对对象检测与识别均有应用.NCC算 ...
- kotlin语法使用笔记
kotlin中文文档:http://www.kotlindoc.cn/ClassesAndObjects/Classes-and-Inheritance.html 1. 声明类的构造方法 例如继承Fr ...
- 解决webdiyer:AspNetPager分页控件在IE模式下点击页号不能翻页的问题。
在网站根目录下新建ie.browser文件, 然后用记事本打开. 将以下代码粘贴进去,保存即可,目的是让其与IE11的 UserAgent 匹配,使 .net framework 认识这是一个已知的浏 ...
- 【静默】Oracle各类响应文件何在?
[静默]Oracle各类响应文件何在? --root用户下执行: find -name *.rsp / 1.创建数据库的响应文件:$ORACLE_HOME/assistants/dbca/dbca. ...
- Java开发面试题整理(2019春招)
一.Java基础部分 1. HashMap和Hashtable各有什么特点,它们有什么区别?(必背题,超级重要) HashMap和Hashtable都实现了Map接口,但决定用哪一个之前先要弄清楚它们 ...
- Tensorflow r1.8安装C++接口(兼容OpenCV3)
与之前一样,直接走medium的传送门:https://medium.com/@fanzongshaoxing/use-tensorflow-c-api-with-opencv3-bacb83ca56 ...
- VSCode远程调试Go程序方法(Attach)
set launch.json { "name": "Attach", "type": "go", "requ ...