2017-12-13 22:53:47 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2017 The Cartographer Authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cartographer_grpc/mapping/pose_graph_stub.h"
|
|
|
|
|
2018-01-09 21:25:28 +08:00
|
|
|
#include "cartographer/mapping/pose_graph.h"
|
2017-12-13 22:53:47 +08:00
|
|
|
#include "glog/logging.h"
|
|
|
|
|
|
|
|
namespace cartographer_grpc {
|
|
|
|
namespace mapping {
|
|
|
|
|
|
|
|
PoseGraphStub::PoseGraphStub(std::shared_ptr<grpc::Channel> client_channel,
|
|
|
|
proto::MapBuilderService::Stub* stub)
|
|
|
|
: client_channel_(client_channel), stub_(stub) {}
|
|
|
|
|
2018-01-26 00:31:03 +08:00
|
|
|
void PoseGraphStub::RunFinalOptimization() {
|
|
|
|
grpc::ClientContext client_context;
|
|
|
|
google::protobuf::Empty request;
|
|
|
|
google::protobuf::Empty response;
|
|
|
|
CHECK(stub_->RunFinalOptimization(&client_context, request, &response).ok());
|
|
|
|
}
|
2017-12-13 22:53:47 +08:00
|
|
|
|
|
|
|
cartographer::mapping::MapById<
|
|
|
|
cartographer::mapping::SubmapId,
|
|
|
|
cartographer::mapping::PoseGraphInterface::SubmapData>
|
2017-12-18 22:57:49 +08:00
|
|
|
PoseGraphStub::GetAllSubmapData() {
|
2017-12-13 22:53:47 +08:00
|
|
|
LOG(FATAL) << "Not implemented";
|
|
|
|
}
|
|
|
|
|
2018-01-05 21:19:08 +08:00
|
|
|
cartographer::mapping::MapById<
|
|
|
|
cartographer::mapping::SubmapId,
|
|
|
|
cartographer::mapping::PoseGraphInterface::SubmapPose>
|
|
|
|
PoseGraphStub::GetAllSubmapPoses() {
|
2018-01-08 22:34:00 +08:00
|
|
|
grpc::ClientContext client_context;
|
|
|
|
google::protobuf::Empty request;
|
|
|
|
proto::GetAllSubmapPosesResponse response;
|
|
|
|
stub_->GetAllSubmapPoses(&client_context, request, &response);
|
|
|
|
cartographer::mapping::MapById<
|
|
|
|
cartographer::mapping::SubmapId,
|
|
|
|
cartographer::mapping::PoseGraphInterface::SubmapPose>
|
|
|
|
submap_poses;
|
|
|
|
for (const auto& submap_pose : response.submap_poses()) {
|
|
|
|
submap_poses.Insert(
|
|
|
|
cartographer::mapping::SubmapId{submap_pose.submap_id().trajectory_id(),
|
|
|
|
submap_pose.submap_id().submap_index()},
|
|
|
|
cartographer::mapping::PoseGraphInterface::SubmapPose{
|
|
|
|
submap_pose.submap_version(),
|
|
|
|
cartographer::transform::ToRigid3(submap_pose.global_pose())});
|
|
|
|
}
|
|
|
|
return submap_poses;
|
2018-01-05 21:19:08 +08:00
|
|
|
}
|
|
|
|
|
2017-12-13 22:53:47 +08:00
|
|
|
cartographer::transform::Rigid3d PoseGraphStub::GetLocalToGlobalTransform(
|
|
|
|
int trajectory_id) {
|
2018-01-08 23:28:41 +08:00
|
|
|
grpc::ClientContext client_context;
|
|
|
|
proto::GetLocalToGlobalTransformRequest request;
|
|
|
|
request.set_trajectory_id(trajectory_id);
|
|
|
|
proto::GetLocalToGlobalTransformResponse response;
|
|
|
|
CHECK(stub_->GetLocalToGlobalTransform(&client_context, request, &response)
|
|
|
|
.ok());
|
|
|
|
return cartographer::transform::ToRigid3(response.local_to_global());
|
2017-12-13 22:53:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
cartographer::mapping::MapById<cartographer::mapping::NodeId,
|
|
|
|
cartographer::mapping::TrajectoryNode>
|
2017-12-18 22:57:49 +08:00
|
|
|
PoseGraphStub::GetTrajectoryNodes() {
|
2017-12-13 22:53:47 +08:00
|
|
|
LOG(FATAL) << "Not implemented";
|
|
|
|
}
|
|
|
|
|
2018-01-08 16:13:51 +08:00
|
|
|
cartographer::mapping::MapById<cartographer::mapping::NodeId,
|
|
|
|
cartographer::mapping::TrajectoryNodePose>
|
|
|
|
PoseGraphStub::GetTrajectoryNodePoses() {
|
2018-01-08 21:19:39 +08:00
|
|
|
grpc::ClientContext client_context;
|
|
|
|
google::protobuf::Empty request;
|
|
|
|
proto::GetTrajectoryNodePosesResponse response;
|
|
|
|
stub_->GetTrajectoryNodePoses(&client_context, request, &response);
|
|
|
|
cartographer::mapping::MapById<cartographer::mapping::NodeId,
|
|
|
|
cartographer::mapping::TrajectoryNodePose>
|
|
|
|
node_poses;
|
|
|
|
for (const auto& node_pose : response.node_poses()) {
|
|
|
|
node_poses.Insert(
|
|
|
|
cartographer::mapping::NodeId{node_pose.node_id().trajectory_id(),
|
|
|
|
node_pose.node_id().node_index()},
|
|
|
|
cartographer::mapping::TrajectoryNodePose{
|
|
|
|
node_pose.has_constant_data(),
|
|
|
|
cartographer::transform::ToRigid3(node_pose.global_pose())});
|
|
|
|
}
|
|
|
|
return node_poses;
|
2018-01-08 16:13:51 +08:00
|
|
|
}
|
|
|
|
|
2017-12-13 22:53:47 +08:00
|
|
|
bool PoseGraphStub::IsTrajectoryFinished(int trajectory_id) {
|
|
|
|
LOG(FATAL) << "Not implemented";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<cartographer::mapping::PoseGraphInterface::Constraint>
|
|
|
|
PoseGraphStub::constraints() {
|
2018-01-09 21:25:28 +08:00
|
|
|
grpc::ClientContext client_context;
|
|
|
|
google::protobuf::Empty request;
|
|
|
|
proto::GetConstraintsResponse response;
|
|
|
|
stub_->GetConstraints(&client_context, request, &response);
|
|
|
|
return cartographer::mapping::FromProto(response.constraints());
|
2017-12-13 22:53:47 +08:00
|
|
|
}
|
|
|
|
|
2018-01-12 20:55:14 +08:00
|
|
|
cartographer::mapping::proto::PoseGraph PoseGraphStub::ToProto() {
|
|
|
|
LOG(FATAL) << "Not implemented";
|
|
|
|
}
|
|
|
|
|
2017-12-13 22:53:47 +08:00
|
|
|
} // namespace mapping
|
|
|
|
} // namespace cartographer_grpc
|