21 #include "cartographer/kalman_filter/proto/pose_tracker_options.pb.h" 22 #include "cartographer/mapping_2d/scan_matching/proto/real_time_correlative_scan_matcher_options.pb.h" 23 #include "cartographer/mapping_3d/proto/local_trajectory_builder_options.pb.h" 24 #include "cartographer/mapping_3d/proto/submaps_options.pb.h" 25 #include "cartographer/mapping_3d/scan_matching/proto/ceres_scan_matcher_options.pb.h" 26 #include "glog/logging.h" 29 namespace mapping_3d {
32 const proto::LocalTrajectoryBuilderOptions& options)
35 scan_matcher_pose_estimate_(transform::
Rigid3d::Identity()),
36 motion_filter_(options.motion_filter_options()),
38 common::
make_unique<scan_matching::RealTimeCorrelativeScanMatcher>(
39 options_.kalman_local_trajectory_builder_options()
40 .real_time_correlative_scan_matcher_options())),
42 options_.ceres_scan_matcher_options())),
44 first_pose_prediction_(transform::
Rigid3f::Identity()),
45 accumulated_range_data_{Eigen::Vector3f::Zero(), {}, {}} {}
55 const Eigen::Vector3d& angular_velocity) {
57 pose_tracker_ = common::make_unique<kalman_filter::PoseTracker>(
58 options_.kalman_local_trajectory_builder_options()
59 .pose_tracker_options(),
63 pose_tracker_->AddImuLinearAccelerationObservation(time, linear_acceleration);
64 pose_tracker_->AddImuAngularVelocityObservation(time, angular_velocity);
68 pose_tracker_->GetPoseEstimateMeanAndCovariance(time, &pose_estimate,
69 &unused_covariance_estimate);
72 std::unique_ptr<KalmanLocalTrajectoryBuilder::InsertionResult>
77 LOG(INFO) <<
"PoseTracker not yet initialized.";
84 time, &pose_prediction, &unused_covariance_prediction);
96 for (
const Eigen::Vector3f&
hit : range_data_in_first_tracking.returns) {
97 const Eigen::Vector3f delta = hit - range_data_in_first_tracking.
origin;
98 const float range = delta.norm();
100 if (range <=
options_.max_range()) {
107 range_data_in_first_tracking.origin +
108 options_.max_range() / range * delta);
123 std::unique_ptr<KalmanLocalTrajectoryBuilder::InsertionResult>
127 range_data_in_tracking.
origin,
133 if (filtered_range_data.
returns.empty()) {
134 LOG(WARNING) <<
"Dropped empty range data.";
141 time, &pose_prediction, &unused_covariance_prediction);
143 const Submap*
const matching_submap =
148 options_.high_resolution_adaptive_voxel_filter_options());
151 if (
options_.kalman_local_trajectory_builder_options()
152 .use_online_correlative_scan_matching()) {
156 initial_pose, filtered_point_cloud_in_tracking,
161 ceres::Solver::Summary summary;
164 options_.low_resolution_adaptive_voxel_filter_options());
166 low_resolution_adaptive_voxel_filter.
Filter(filtered_range_data.
returns);
168 {{&filtered_point_cloud_in_tracking,
170 {&low_resolution_point_cloud_in_tracking,
172 &pose_observation_in_submap, &summary);
174 matching_submap->
local_pose() * pose_observation_in_submap;
176 time, pose_observation,
177 options_.kalman_local_trajectory_builder_options()
178 .scan_matcher_variance() *
179 kalman_filter::PoseCovariance::Identity());
188 pose_observation.
cast<
float>())};
197 options_.kalman_local_trajectory_builder_options()
198 .pose_tracker_options(),
204 options_.kalman_local_trajectory_builder_options()
205 .odometer_translational_variance(),
206 options_.kalman_local_trajectory_builder_options()
207 .odometer_rotational_variance()));
215 std::unique_ptr<KalmanLocalTrajectoryBuilder::InsertionResult>
222 const Submap*
const matching_submap =
224 std::vector<const Submap*> insertion_submaps;
225 for (
int insertion_index :
submaps_->insertion_indices()) {
226 insertion_submaps.push_back(
submaps_->Get(insertion_index));
230 pose_observation.
cast<
float>()),
232 return std::unique_ptr<InsertionResult>(
234 matching_submap, insertion_submaps});
proto::RangeDataInserterOptions options_
PointCloud TransformPointCloud(const PointCloud &point_cloud, const transform::Rigid3f &transform)
const PoseEstimate & pose_estimate() const override
std::unique_ptr< RealTimeCorrelativeScanMatcher > real_time_correlative_scan_matcher_
bool IsSimilar(common::Time time, const transform::Rigid3d &pose)
const HybridGrid & high_resolution_hybrid_grid() const
PointCloud VoxelFiltered(const PointCloud &point_cloud, const float size)
transform::Rigid3d local_pose() const
Eigen::Matrix< double, 6, 6 > PoseCovariance
UniversalTimeScaleClock::time_point Time
std::unique_ptr< scan_matching::RealTimeCorrelativeScanMatcher > real_time_correlative_scan_matcher_
RangeData TransformRangeData(const RangeData &range_data, const transform::Rigid3f &transform)
PoseCovariance BuildPoseCovariance(const double translational_variance, const double rotational_variance)
PointCloud Filter(const PointCloud &point_cloud) const
const HybridGrid & low_resolution_hybrid_grid() const
mapping_3d::Submaps * submaps() override
PoseEstimate last_pose_estimate_
std::unique_ptr< mapping_3d::Submaps > submaps_
std::vector< Eigen::Vector3f > PointCloud
void AddImuData(common::Time time, const Eigen::Vector3d &linear_acceleration, const Eigen::Vector3d &angular_velocity) override
sensor::RangeData accumulated_range_data_
transform::Rigid3d scan_matcher_pose_estimate_
const proto::LocalTrajectoryBuilderOptions options_
~KalmanLocalTrajectoryBuilder() override
transform::Rigid3f first_pose_prediction_
std::unique_ptr< InsertionResult > InsertIntoSubmap(common::Time time, const sensor::RangeData &range_data_in_tracking, const transform::Rigid3d &pose_observation)
std::unique_ptr< InsertionResult > AddRangefinderData(common::Time time, const Eigen::Vector3f &origin, const sensor::PointCloud &ranges) override
std::unique_ptr< scan_matching::CeresScanMatcher > ceres_scan_matcher_
KalmanLocalTrajectoryBuilder(const proto::LocalTrajectoryBuilderOptions &options)
std::unique_ptr< InsertionResult > AddAccumulatedRangeData(common::Time time, const sensor::RangeData &range_data_in_tracking)
_Unique_if< T >::_Single_object make_unique(Args &&...args)
MotionFilter motion_filter_
void AddOdometerData(common::Time time, const transform::Rigid3d &pose) override
std::unique_ptr< Submaps > submaps_
std::unique_ptr< kalman_filter::PoseTracker > pose_tracker_
std::unique_ptr< CeresScanMatcher > ceres_scan_matcher_