node_constants.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 
19 #include "glog/logging.h"
20 
21 namespace cartographer_ros {
22 
23 std::vector<std::string> ComputeRepeatedTopicNames(const std::string& topic,
24  const int num_topics) {
25  CHECK_GE(num_topics, 0);
26  if (num_topics == 1) {
27  return {topic};
28  }
29  std::vector<std::string> topics;
30  topics.reserve(num_topics);
31  for (int i = 0; i < num_topics; ++i) {
32  topics.emplace_back(topic + "_" + std::to_string(i + 1));
33  }
34  return topics;
35 }
36 
37 } // namespace cartographer_ros
std::vector< std::string > ComputeRepeatedTopicNames(const std::string &topic, const int num_topics)
std::string topic


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