Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer/cloud/internal/mapping/serialization.h"
00018
00019 #include "cartographer/common/port.h"
00020
00021 namespace cartographer {
00022 namespace cloud {
00023 namespace {
00024
00025 using TrajectoryState =
00026 ::cartographer::mapping::PoseGraphInterface::TrajectoryState;
00027
00028 }
00029
00030 proto::TrajectoryState ToProto(const TrajectoryState& trajectory_state) {
00031 switch (trajectory_state) {
00032 case TrajectoryState::ACTIVE:
00033 return proto::TrajectoryState::ACTIVE;
00034 case TrajectoryState::FINISHED:
00035 return proto::TrajectoryState::FINISHED;
00036 case TrajectoryState::FROZEN:
00037 return proto::TrajectoryState::FROZEN;
00038 case TrajectoryState::DELETED:
00039 return proto::TrajectoryState::DELETED;
00040 default:
00041 LOG(FATAL) << "Unknown TrajectoryState";
00042 }
00043 }
00044
00045 TrajectoryState FromProto(const proto::TrajectoryState& proto) {
00046 switch (proto) {
00047 case proto::TrajectoryState::ACTIVE:
00048 return TrajectoryState::ACTIVE;
00049 case proto::TrajectoryState::FINISHED:
00050 return TrajectoryState::FINISHED;
00051 case proto::TrajectoryState::FROZEN:
00052 return TrajectoryState::FROZEN;
00053 case proto::TrajectoryState::DELETED:
00054 return TrajectoryState::DELETED;
00055 default:
00056 LOG(FATAL) << "Unknown proto::TrajectoryState";
00057 }
00058 }
00059
00060 proto::TrajectoryRemapping ToProto(
00061 const std::map<int, int>& trajectory_remapping) {
00062 proto::TrajectoryRemapping proto;
00063 *proto.mutable_serialized_trajectories_to_trajectories() =
00064 google::protobuf::Map<int32, int32>(trajectory_remapping.begin(),
00065 trajectory_remapping.end());
00066 return proto;
00067 }
00068
00069 std::map<int, int> FromProto(const proto::TrajectoryRemapping& proto) {
00070 return std::map<int, int>(
00071 proto.serialized_trajectories_to_trajectories().begin(),
00072 proto.serialized_trajectories_to_trajectories().end());
00073 }
00074
00075 }
00076 }