Validate odometry and fixed frame poses. (#588)

master
Wolfgang Hess 2017-10-16 15:59:56 +02:00 committed by GitHub
parent 6b447c4577
commit 76ed37768f
3 changed files with 15 additions and 5 deletions

View File

@ -19,6 +19,8 @@
#include "cartographer/mapping/global_trajectory_builder_interface.h" #include "cartographer/mapping/global_trajectory_builder_interface.h"
#include "glog/logging.h"
namespace cartographer { namespace cartographer {
namespace mapping { namespace mapping {
@ -61,12 +63,14 @@ class GlobalTrajectoryBuilder
} }
void AddSensorData(const sensor::OdometryData& odometry_data) override { void AddSensorData(const sensor::OdometryData& odometry_data) override {
CHECK(odometry_data.pose.IsValid()) << odometry_data.pose;
local_trajectory_builder_.AddOdometerData(odometry_data); local_trajectory_builder_.AddOdometerData(odometry_data);
sparse_pose_graph_->AddOdometerData(trajectory_id_, odometry_data); sparse_pose_graph_->AddOdometerData(trajectory_id_, odometry_data);
} }
void AddSensorData( void AddSensorData(
const sensor::FixedFramePoseData& fixed_frame_pose) override { const sensor::FixedFramePoseData& fixed_frame_pose) override {
CHECK(fixed_frame_pose.pose.IsValid()) << fixed_frame_pose.pose;
sparse_pose_graph_->AddFixedFramePoseData(trajectory_id_, fixed_frame_pose); sparse_pose_graph_->AddFixedFramePoseData(trajectory_id_, fixed_frame_pose);
} }

View File

@ -236,9 +236,7 @@ class MapById {
typename std::map<int, MapByIndex>::const_iterator current_trajectory) typename std::map<int, MapByIndex>::const_iterator current_trajectory)
: current_trajectory_(current_trajectory) {} : current_trajectory_(current_trajectory) {}
int operator*() const { int operator*() const { return current_trajectory_->first; }
return current_trajectory_->first;
}
ConstTrajectoryIterator& operator++() { ConstTrajectoryIterator& operator++() {
++current_trajectory_; ++current_trajectory_;
@ -254,13 +252,14 @@ class MapById {
return current_trajectory_ == it.current_trajectory_; return current_trajectory_ == it.current_trajectory_;
} }
bool operator!=(const ConstTrajectoryIterator& it) const { return !operator==(it); } bool operator!=(const ConstTrajectoryIterator& it) const {
return !operator==(it);
}
private: private:
typename std::map<int, MapByIndex>::const_iterator current_trajectory_; typename std::map<int, MapByIndex>::const_iterator current_trajectory_;
}; };
// Appends data to a 'trajectory_id', creating trajectories as needed. // Appends data to a 'trajectory_id', creating trajectories as needed.
IdType Append(const int trajectory_id, const DataType& data) { IdType Append(const int trajectory_id, const DataType& data) {
CHECK_GE(trajectory_id, 0); CHECK_GE(trajectory_id, 0);

View File

@ -17,6 +17,7 @@
#ifndef CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_H_ #ifndef CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_H_
#define CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_H_ #define CARTOGRAPHER_TRANSFORM_RIGID_TRANSFORM_H_
#include <cmath>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -180,6 +181,12 @@ class Rigid3 {
return out; return out;
} }
bool IsValid() const {
return !std::isnan(translation_.x()) && !std::isnan(translation_.y()) &&
!std::isnan(translation_.z()) &&
std::abs(FloatType(1) - rotation_.norm()) < FloatType(1e-3);
}
private: private:
Vector translation_; Vector translation_;
Quaternion rotation_; Quaternion rotation_;