Cartographer原始碼閱讀(8):imu_tracker
1 /* 2 * Copyright 2016 The Cartographer Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and14 * limitations under the License. 15 */ 16 17 #include "cartographer/mapping/imu_tracker.h" 18 19 #include <cmath> 20 #include <limits> 21 22 #include "cartographer/common/math.h" 23 #include "cartographer/transform/transform.h" 24 #include "glog/logging.h" 25 26 namespace cartographer {27 namespace mapping { 28 29 ImuTracker::ImuTracker(const double imu_gravity_time_constant, 30 const common::Time time) 31 : imu_gravity_time_constant_(imu_gravity_time_constant), 32 time_(time), 33 last_linear_acceleration_time_(common::Time::min()), 34 orientation_(Eigen::Quaterniond::Identity()), 35 gravity_vector_(Eigen::Vector3d::UnitZ()), 36 imu_angular_velocity_(Eigen::Vector3d::Zero()) {} 37 38 void ImuTracker::Advance(const common::Time time) { 39 CHECK_LE(time_, time); 40 const double delta_t = common::ToSeconds(time - time_); 41 const Eigen::Quaterniond rotation = 42 transform::AngleAxisVectorToRotationQuaternion( 43 Eigen::Vector3d(imu_angular_velocity_ * delta_t)); 44 orientation_ = (orientation_ * rotation).normalized(); 45 gravity_vector_ = rotation.conjugate() * gravity_vector_; 46 time_ = time; 47 } 48 49 void ImuTracker::AddImuLinearAccelerationObservation( 50 const Eigen::Vector3d& imu_linear_acceleration) { 51 // Update the 'gravity_vector_' with an exponential moving average using the 52 // 'imu_gravity_time_constant'. 53 const double delta_t = 54 last_linear_acceleration_time_ > common::Time::min() 55 ? common::ToSeconds(time_ - last_linear_acceleration_time_) 56 : std::numeric_limits<double>::infinity(); 57 last_linear_acceleration_time_ = time_; 58 const double alpha = 1. - std::exp(-delta_t / imu_gravity_time_constant_); 59 gravity_vector_ = 60 (1. - alpha) * gravity_vector_ + alpha * imu_linear_acceleration; 61 // Change the 'orientation_' so that it agrees with the current 62 // 'gravity_vector_'. 63 const Eigen::Quaterniond rotation = Eigen::Quaterniond::FromTwoVectors( 64 gravity_vector_, orientation_.conjugate() * Eigen::Vector3d::UnitZ()); 65 orientation_ = (orientation_ * rotation).normalized(); 66 CHECK_GT((orientation_ * gravity_vector_).z(), 0.); 67 CHECK_GT((orientation_ * gravity_vector_).normalized().z(), 0.99); 68 } 69 70 void ImuTracker::AddImuAngularVelocityObservation( 71 const Eigen::Vector3d& imu_angular_velocity) { 72 imu_angular_velocity_ = imu_angular_velocity; 73 } 74 75 } // namespace mapping 76 } // namespace cartographer
相關推薦
Cartographer原始碼閱讀(8):imu_tracker
1 /* 2 * Copyright 2016 The Cartographer Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use
Cartographer源碼閱讀(8):imu_tracker
require specific math erl axis copy cab gre nbsp IMU的輸入為imu_linear_acceleration 和 imu_angular_velocity 線加速和角速度。最終作為屬性輸出的是方位四元數。 Eigen
Cartographer原始碼閱讀(1):程式入口
1 [email protected]:~$ sudo apt-get install kdevelop 2 [sudo] password for yhexie: 3 Reading package lists... Done 4 Building dependency
Cartographer原始碼閱讀(2):Node和MapBuilder物件
上文提到特別注意map_builder_bridge_.AddTrajectory(x,x),檢視其中的程式碼。兩點: 首先是map_builder_.AddTrajectoryBuilder(...),呼叫了map_builder_物件的方法。其次是sensor_bridges_鍵值對的賦值。
Cartographer原始碼閱讀(5):PoseGraph位姿圖
PoseGraph位姿圖 mapping2D::PoseGraph類的註釋: // Implements the loop closure method called Sparse Pose Adjustment (SPA) from// Konolige, Kurt, et al. "E
Cartographer原始碼閱讀(3):程式邏輯結構
Cartographer早期的程式碼在進行3d製圖的時候使用了UKF方法,檢視現有的tag版本,可以轉到0.1.0和0.2.0檢視,包含kalman_filter資料夾。 資料夾中的pose_tracker類檔案在mapping_3d的檔案加下有kalman_local_trajectory_builder
Cartographer原始碼閱讀(7):軌跡推算和位姿推算的原理
其實也就是包括兩個方面的內容:類似於運動模型的位姿估計和掃描匹配,因為需要計算速度,所以時間就有必要了! 1. PoseExtrapolator解決了IMU資料、里程計和位姿資訊進行融合的問題。 該類定義了三個佇列。 1 std::deque<TimedPose> timed_pose_
Cartographer原始碼閱讀(9):圖優化的前端——閉環檢測
約束計算 閉環檢測的策略:搜尋閉環,通過匹配檢測是否是閉環,採用了分支定界法。 前已經述及PoseGraph的內容,此處繼續。位姿圖類定義了pose_graph::ConstraintBuilder constraint_builder_物件。 1.ConstraintBuilder類圖 定義了S
Cartographer原始碼閱讀(4):Node和MapBuilder物件2
MapBuilder的成員變數sensor::Collator sensor_collator_; 再次閱讀MapBuilder::AddTrajectoryBuilder方法。首先構造了mapping::GlobalTrajectoryBuilder例項,接著作為引數構造了CollatedTraj
Cartographer原始碼閱讀(6):LocalTrajectoryBuilder和PoseExtrapolator
LocalTrajectoryBuilder意思是區域性軌跡的構建,下面的類圖中方法的引數沒有畫進去。 注意其中的三個類:PoseExtrapolator類,RealTimeCorrelativeScanMatcher類和CeresScanMatcher類。 (1)PoseExtrapolator類(
Cartographer源碼閱讀(8):圖優化的前端——閉環檢測
tips 閱讀 psc style con 總結 rap mapi tex 約束計算 閉環檢測的策略:搜索閉環 分支定界法 通過匹配檢測是否是閉環 前已經述及PoseGraph的內容,此處繼續。位姿圖類定義了pose_graph::ConstraintBuilder
Spring4.3.12原始碼閱讀系列:1-環境搭建
學習任務 近期想增加部分原始碼閱讀經驗,提高自己在造輪子方面的實力,增長些在設計模式應用方面的編碼能力,以及懷著向大佬們膜拜的心情,開始有計劃地閱讀Spring原始碼 前期準備 以下幾項準備事項,算是基本的日常開發環境,就算沒有,也是動動手很快安
Tensorflow object detection API 原始碼閱讀筆記:RPN
Update: 建議先看從程式設計實現角度學習Faster R-CNN,比較直觀。這裡由於原始碼抽象程度較高,顯得比較混亂。 faster_rcnn_meta_arch.py中這兩個對應知乎文章中RPN包含的3*3和1*1卷積: rpn_box_pred
原始碼閱讀系列:為什麼要閱讀原始碼?
一.為什麼要閱讀程式碼 養成閱讀高品質程式碼的習慣,可以提高編寫程式碼的能力。 電腦科學是一門實踐性很強的學科,很多內容在書本上根本學不到。就拿專案的組織來說,沒有什麼書籍專門論述應該如何組織與管理專案的目錄結構,因為這本身就是一種見仁見智的活動,要
Tensorflow object detection API 原始碼閱讀筆記:架構
在之前的博文中介紹過用tf提供的預訓練模型進行inference,非常簡單。這裡我們深入原始碼,瞭解檢測API的程式碼架構,每個部分的深入閱讀留待後續。 '''構建自己模型的介面是虛基類DetectionModel,具體有5個抽象函式需要實現。 ''' o
Tensorflow object detection API 原始碼閱讀筆記:RFCN
有了前面Faster R-CNN的基礎,RFCN就比較容易了。 """object_detection/meta_architectures/rfcn_meta_arch.py The R-FCN
Ethzasl MSF原始碼閱讀(1):程式入口和主題訂閱
Ethz的Stephen Weiss的工作,是一個IMU鬆耦合的方法。 1.程式入口:ethzasl_msf\msf_updates\src\pose_msf\main.cpp 1 #include "pose_sensormanager.h" 2 3 int main(int argc,
Ethzasl MSF原始碼閱讀(2):百川匯海
這裡有個感覺,就是百川匯海。即IMU資料和相機的訊息資料都彙集到msf_core進行處理。接上一篇, 1. 檢視IMUHandler_ROS::IMUCallback和IMUHandler_ROS::StateCallback回撥函式。 MUHandler_ROS::IMUCallback,傳入的訊息s
Ethzasl MSF原始碼閱讀(3):MSF_Core和PoseMeasurement
1.MSF_Core的三個函式:ProcessIMU、ProcessExternallyPropagatedState和AddMeasurement MSF_Core維護了狀態佇列和觀測值佇列,這裡需要結合論文思考這個狀態佇列的作用。 ProcessIMU方法: 1 template<
jdk原始碼閱讀二:LinkedList
LinkedList介紹 LinkedList是基於連結串列來實現的List。主要特徵如下: 不僅實現了List介面,還實現了Deque,所以是一個雙端佇列。 允許儲存null物件。 非執行緒安全,如果多執行緒操作它,需要外部枷鎖,或者Collecti