19 #include "cartographer/common/config.h" 30 std::unique_ptr<::cartographer::common::LuaParameterDictionary>
34 std::vector<std::string>{
35 std::string(::cartographer::common::kSourceDirectory) +
36 "/configuration_files"});
37 return common::make_unique<::cartographer::common::LuaParameterDictionary>(
38 lua_code, std::move(file_resolver));
41 std::vector<cartographer::sensor::TimedPointCloudData>
44 std::vector<cartographer::sensor::TimedPointCloudData> measurements;
46 for (
double angle = 0.; angle < M_PI; angle += 0.01) {
47 for (
double height : {-0.4, -0.2, 0.0, 0.2, 0.4}) {
48 constexpr
double kRadius = 5;
49 point_cloud.emplace_back(kRadius * std::cos(angle),
50 kRadius * std::sin(angle), height, 0.);
53 const Eigen::Vector3f kDirection = Eigen::Vector3f(2., 1., 0.).normalized();
54 const Eigen::Vector3f kVelocity = travel_distance / duration * kDirection;
55 for (
double elapsed_time = 0.; elapsed_time < duration;
56 elapsed_time += time_step) {
66 time, Eigen::Vector3f::Zero(), ranges});
73 proto.mutable_submap_id()->set_trajectory_id(trajectory_id);
74 proto.mutable_submap_id()->set_submap_index(submap_index);
75 proto.mutable_submap_3d()->set_num_range_data(1);
76 *proto.mutable_submap_3d()->mutable_local_pose() =
83 proto.mutable_node_id()->set_trajectory_id(trajectory_id);
84 proto.mutable_node_id()->set_node_index(node_index);
85 proto.mutable_node_data()->set_timestamp(42);
86 *proto.mutable_node_data()->mutable_local_pose() =
92 const proto::Submap& submap) {
93 proto::PoseGraph::Constraint proto;
94 proto.mutable_submap_id()->set_submap_index(
95 submap.submap_id().submap_index());
96 proto.mutable_submap_id()->set_trajectory_id(
97 submap.submap_id().trajectory_id());
98 proto.mutable_node_id()->set_node_index(node.node_id().node_index());
99 proto.mutable_node_id()->set_trajectory_id(node.node_id().trajectory_id());
101 Eigen::Vector3d(2., 3., 4.),
102 Eigen::AngleAxisd(M_PI / 8., Eigen::Vector3d::UnitX()));
104 proto.set_translation_weight(0.2f);
105 proto.set_rotation_weight(0.1f);
106 proto.set_tag(proto::PoseGraph::Constraint::INTER_SUBMAP);
111 proto::PoseGraph* pose_graph) {
112 for (
int i = 0; i < pose_graph->trajectory_size(); ++i) {
113 proto::Trajectory* trajectory = pose_graph->mutable_trajectory(i);
114 if (trajectory->trajectory_id() == trajectory_id) {
118 proto::Trajectory* trajectory = pose_graph->add_trajectory();
119 trajectory->set_trajectory_id(trajectory_id);
125 proto::PoseGraph::LandmarkPose landmark;
126 landmark.set_landmark_id(landmark_id);
132 proto::PoseGraph* pose_graph) {
135 auto* node = trajectory->add_node();
136 node->set_timestamp(node_data.node_data().timestamp());
137 node->set_node_index(node_data.node_id().node_index());
138 *node->mutable_pose() = node_data.node_data().local_pose();
142 proto::PoseGraph* pose_graph) {
144 submap_data.submap_id().trajectory_id(), pose_graph);
145 auto* submap = trajectory->add_submap();
146 submap->set_submap_index(submap_data.submap_id().submap_index());
147 if (submap_data.has_submap_2d()) {
148 *submap->mutable_pose() = submap_data.submap_2d().local_pose();
150 *submap->mutable_pose() = submap_data.submap_3d().local_pose();
155 proto::PoseGraph* pose_graph) {
156 *pose_graph->add_constraint() = constraint;
160 proto::PoseGraph* pose_graph) {
161 *pose_graph->add_landmark_poses() = landmark;
TimedPointCloud TransformTimedPointCloud(const TimedPointCloud &point_cloud, const transform::Rigid3f &transform)
proto::PoseGraph::Constraint CreateFakeConstraint(const proto::Node &node, const proto::Submap &submap)
_Unique_if< T >::_Single_object make_unique(Args &&... args)
void AddToProtoGraph(const proto::Node &node_data, proto::PoseGraph *pose_graph)
std::vector< cartographer::sensor::TimedPointCloudData > GenerateFakeRangeMeasurements(double travel_distance, double duration, double time_step)
UniversalTimeScaleClock::time_point Time
Time FromUniversal(const int64 ticks)
Duration FromSeconds(const double seconds)
proto::Submap CreateFakeSubmap3D(int trajectory_id, int submap_index)
std::vector< Eigen::Vector4f > TimedPointCloud
proto::PoseGraph::LandmarkPose CreateFakeLandmark(const std::string &landmark_id, const transform::Rigid3d &global_pose)
proto::Node CreateFakeNode(int trajectory_id, int node_index)
std::unique_ptr<::cartographer::common::LuaParameterDictionary > ResolveLuaParameters(const std::string &lua_code)
proto::Trajectory * CreateTrajectoryIfNeeded(int trajectory_id, proto::PoseGraph *pose_graph)