configuration.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 "Eigen/Core"
20 #include "Eigen/Geometry"
21 #include "cartographer/sensor/proto/configuration.pb.h"
22 #include "cartographer/transform/proto/transform.pb.h"
25 #include "glog/logging.h"
26 
27 namespace cartographer {
28 namespace sensor {
29 
30 proto::Configuration::Sensor CreateSensorConfiguration(
31  common::LuaParameterDictionary* const parameter_dictionary) {
32  proto::Configuration::Sensor sensor;
33  sensor.set_frame_id(parameter_dictionary->GetString("frame_id"));
34  *sensor.mutable_transform() = transform::ToProto(transform::FromDictionary(
35  parameter_dictionary->GetDictionary("transform").get()));
36  return sensor;
37 }
38 
39 proto::Configuration CreateConfiguration(
40  common::LuaParameterDictionary* const parameter_dictionary) {
41  proto::Configuration configuration;
42  for (auto& sensor_parameter_dictionary :
43  parameter_dictionary->GetArrayValuesAsDictionaries()) {
44  *configuration.add_sensor() =
45  CreateSensorConfiguration(sensor_parameter_dictionary.get());
46  }
47  return configuration;
48 }
49 
50 bool IsEnabled(const string& frame_id,
51  const sensor::proto::Configuration& sensor_configuration) {
52  for (const auto& sensor : sensor_configuration.sensor()) {
53  if (sensor.frame_id() == frame_id) {
54  return true;
55  }
56  }
57  return false;
58 }
59 
61  const string& frame_id,
62  const sensor::proto::Configuration& sensor_configuration) {
63  for (const auto& sensor : sensor_configuration.sensor()) {
64  if (sensor.frame_id() == frame_id) {
65  return transform::ToRigid3(sensor.transform());
66  }
67  }
68  LOG(FATAL) << "No configuration found for sensor with frame ID '" << frame_id
69  << "'.";
70 }
71 
72 } // namespace sensor
73 } // namespace cartographer
proto::Configuration::Sensor CreateSensorConfiguration(common::LuaParameterDictionary *const parameter_dictionary)
std::vector< std::unique_ptr< LuaParameterDictionary > > GetArrayValuesAsDictionaries()
proto::Configuration CreateConfiguration(common::LuaParameterDictionary *const parameter_dictionary)
transform::Rigid3d ToRigid3(const proto::Rigid3d &rigid)
Definition: transform.cc:67
proto::Rigid2d ToProto(const transform::Rigid2d &transform)
Definition: transform.cc:44
transform::Rigid3d GetTransformToTracking(const string &frame_id, const sensor::proto::Configuration &sensor_configuration)
transform::Rigid3d FromDictionary(common::LuaParameterDictionary *dictionary)
std::unique_ptr< LuaParameterDictionary > GetDictionary(const string &key)
bool IsEnabled(const string &frame_id, const sensor::proto::Configuration &sensor_configuration)


cartographer
Author(s):
autogenerated on Wed Jun 5 2019 21:57:58