submap.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
23 #include "cartographer_ros_msgs/StatusCode.h"
24 #include "cartographer_ros_msgs/SubmapQuery.h"
25 
26 namespace cartographer_ros {
27 
28 std::unique_ptr<::cartographer::io::SubmapTextures> FetchSubmapTextures(
29  const ::cartographer::mapping::SubmapId& submap_id,
30  ros::ServiceClient* client) {
31  ::cartographer_ros_msgs::SubmapQuery srv;
32  srv.request.trajectory_id = submap_id.trajectory_id;
33  srv.request.submap_index = submap_id.submap_index;
34  if (!client->call(srv) ||
35  srv.response.status.code != ::cartographer_ros_msgs::StatusCode::OK) {
36  return nullptr;
37  }
38  if (srv.response.textures.empty()) {
39  return nullptr;
40  }
41  auto response =
42  ::cartographer::common::make_unique<::cartographer::io::SubmapTextures>();
43  response->version = srv.response.submap_version;
44  for (const auto& texture : srv.response.textures) {
45  const std::string compressed_cells(texture.cells.begin(),
46  texture.cells.end());
47  response->textures.emplace_back(::cartographer::io::SubmapTexture{
48  ::cartographer::io::UnpackTextureData(compressed_cells, texture.width,
49  texture.height),
50  texture.width, texture.height, texture.resolution,
51  ToRigid3d(texture.slice_pose)});
52  }
53  return response;
54 }
55 
56 } // namespace cartographer_ros
Rigid3d ToRigid3d(const geometry_msgs::TransformStamped &transform)
bool call(MReq &req, MRes &res)
std::unique_ptr<::cartographer::io::SubmapTextures > FetchSubmapTextures(const ::cartographer::mapping::SubmapId &submap_id, ros::ServiceClient *client)
Definition: submap.cc:28
const std::string response


cartographer_ros
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:06:05