00001 /* 00002 * Copyright 2016 The Cartographer Authors 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef CARTOGRAPHER_MAPPING_TRAJECTORY_NODE_H_ 00018 #define CARTOGRAPHER_MAPPING_TRAJECTORY_NODE_H_ 00019 00020 #include <memory> 00021 #include <vector> 00022 00023 #include "Eigen/Core" 00024 #include "absl/types/optional.h" 00025 #include "cartographer/common/time.h" 00026 #include "cartographer/mapping/proto/trajectory_node_data.pb.h" 00027 #include "cartographer/sensor/range_data.h" 00028 #include "cartographer/transform/rigid_transform.h" 00029 00030 namespace cartographer { 00031 namespace mapping { 00032 00033 struct TrajectoryNodePose { 00034 struct ConstantPoseData { 00035 common::Time time; 00036 transform::Rigid3d local_pose; 00037 }; 00038 // The node pose in the global SLAM frame. 00039 transform::Rigid3d global_pose; 00040 00041 absl::optional<ConstantPoseData> constant_pose_data; 00042 }; 00043 00044 struct TrajectoryNode { 00045 struct Data { 00046 common::Time time; 00047 00048 // Transform to approximately gravity align the tracking frame as 00049 // determined by local SLAM. 00050 Eigen::Quaterniond gravity_alignment; 00051 00052 // Used for loop closure in 2D: voxel filtered returns in the 00053 // 'gravity_alignment' frame. 00054 sensor::PointCloud filtered_gravity_aligned_point_cloud; 00055 00056 // Used for loop closure in 3D. 00057 sensor::PointCloud high_resolution_point_cloud; 00058 sensor::PointCloud low_resolution_point_cloud; 00059 Eigen::VectorXf rotational_scan_matcher_histogram; 00060 00061 // The node pose in the local SLAM frame. 00062 transform::Rigid3d local_pose; 00063 }; 00064 00065 common::Time time() const { return constant_data->time; } 00066 00067 // This must be a shared_ptr. If the data is used for visualization while the 00068 // node is being trimmed, it must survive until all use finishes. 00069 std::shared_ptr<const Data> constant_data; 00070 00071 // The node pose in the global SLAM frame. 00072 transform::Rigid3d global_pose; 00073 }; 00074 00075 proto::TrajectoryNodeData ToProto(const TrajectoryNode::Data& constant_data); 00076 TrajectoryNode::Data FromProto(const proto::TrajectoryNodeData& proto); 00077 00078 } // namespace mapping 00079 } // namespace cartographer 00080 00081 #endif // CARTOGRAPHER_MAPPING_TRAJECTORY_NODE_H_