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"
|
2018-02-02 00:19:15 +08:00
|
|
|
#include "cartographer_grpc/framework/client.h"
|
|
|
|
#include "cartographer_grpc/handlers/get_all_submap_poses.h"
|
|
|
|
#include "cartographer_grpc/handlers/get_constraints_handler.h"
|
|
|
|
#include "cartographer_grpc/handlers/get_local_to_global_transform_handler.h"
|
|
|
|
#include "cartographer_grpc/handlers/get_trajectory_node_poses_handler.h"
|
|
|
|
#include "cartographer_grpc/handlers/run_final_optimization_handler.h"
|
2017-12-13 22:53:47 +08:00
|
|
|
#include "glog/logging.h"
|
|
|
|
|
|
|
|
namespace cartographer_grpc {
|
|
|
|
namespace mapping {
|
|
|
|
|
2018-02-02 00:19:15 +08:00
|
|
|
PoseGraphStub::PoseGraphStub(std::shared_ptr<grpc::Channel> client_channel)
|
|
|
|
: client_channel_(client_channel) {}
|
2017-12-13 22:53:47 +08:00
|
|
|
|
2018-01-26 00:31:03 +08:00
|
|
|
void PoseGraphStub::RunFinalOptimization() {
|
|
|
|
google::protobuf::Empty request;
|
2018-02-02 00:19:15 +08:00
|
|
|
framework::Client<handlers::RunFinalOptimizationHandler> client(
|
|
|
|
client_channel_);
|
|
|
|
CHECK(client.Write(request));
|
2018-01-26 00:31:03 +08:00
|
|
|
}
|
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
|
|
|
google::protobuf::Empty request;
|
2018-02-02 00:19:15 +08:00
|
|
|
framework::Client<handlers::GetAllSubmapPosesHandler> client(client_channel_);
|
|
|
|
CHECK(client.Write(request));
|
2018-01-08 22:34:00 +08:00
|
|
|
cartographer::mapping::MapById<
|
|
|
|
cartographer::mapping::SubmapId,
|
|
|
|
cartographer::mapping::PoseGraphInterface::SubmapPose>
|
|
|
|
submap_poses;
|
2018-02-02 00:19:15 +08:00
|
|
|
for (const auto& submap_pose : client.response().submap_poses()) {
|
2018-01-08 22:34:00 +08:00
|
|
|
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
|
|
|
proto::GetLocalToGlobalTransformRequest request;
|
|
|
|
request.set_trajectory_id(trajectory_id);
|
2018-02-02 00:19:15 +08:00
|
|
|
framework::Client<handlers::GetLocalToGlobalTransformHandler> client(
|
|
|
|
client_channel_);
|
|
|
|
CHECK(client.Write(request));
|
|
|
|
return cartographer::transform::ToRigid3(client.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
|
|
|
google::protobuf::Empty request;
|
2018-02-02 00:19:15 +08:00
|
|
|
framework::Client<handlers::GetTrajectoryNodePosesHandler> client(
|
|
|
|
client_channel_);
|
|
|
|
CHECK(client.Write(request));
|
2018-01-08 21:19:39 +08:00
|
|
|
cartographer::mapping::MapById<cartographer::mapping::NodeId,
|
|
|
|
cartographer::mapping::TrajectoryNodePose>
|
|
|
|
node_poses;
|
2018-02-02 00:19:15 +08:00
|
|
|
for (const auto& node_pose : client.response().node_poses()) {
|
2018-01-08 21:19:39 +08:00
|
|
|
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
|
|
|
google::protobuf::Empty request;
|
2018-02-02 00:19:15 +08:00
|
|
|
framework::Client<handlers::GetConstraintsHandler> client(client_channel_);
|
|
|
|
CHECK(client.Write(request));
|
|
|
|
return cartographer::mapping::FromProto(client.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
|