CARLA
ControllerParser.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
8 
10 
11 #include <pugixml/pugixml.hpp>
12 
13 namespace carla {
14 namespace opendrive {
15 namespace parser {
16 
18  const pugi::xml_document &xml,
19  carla::road::MapBuilder &map_builder) {
20 
21  // Extracting the OpenDRIVE
22  const pugi::xml_node opendrive_node = xml.child("OpenDRIVE");
23  for (pugi::xml_node controller_node = opendrive_node.child("controller");
24  controller_node;
25  controller_node = controller_node.next_sibling("controller")) {
26 
27  const road::ContId controller_id = controller_node.attribute("id").value();
28  const std::string controller_name = controller_node.attribute("name").value();
29  const uint32_t controller_sequence = controller_node.attribute("sequence").as_uint();
30 
31  log_debug("Controller: ",
32  controller_id,
33  controller_name,
34  controller_sequence);
35 
36  std::set<road::SignId> signals;
37 
38  for (pugi::xml_node control_node : controller_node.children("control")) {
39  const road::SignId signal_id = control_node.attribute("signalId").value();
40  // The controller_type is included in the OpenDrive format but not used yet
41  // const std::string controller_type = control_node.attribute("type").value();
42  signals.insert(signal_id);
43  }
44 
45  map_builder.CreateController(
46  controller_id,
47  controller_name,
48  controller_sequence,
49  std::move(signals)
50  );
51  }
52 
53  }
54 
55 } // namespace parser
56 } // namespace opendrive
57 } // namespace carla
const char_t * value() const
Definition: pugixml.cpp:5215
std::string SignId
Definition: RoadTypes.h:25
xml_node next_sibling() const
Definition: pugixml.cpp:5521
void CreateController(const ContId controller_id, const std::string controller_name, const uint32_t controller_sequence, const std::set< road::SignId > &&signals)
Definition: MapBuilder.cpp:906
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
xml_attribute attribute(const char_t *name) const
Definition: pugixml.cpp:5500
static void log_debug(Args &&...)
Definition: Logging.h:75
xml_node child(const char_t *name) const
Definition: pugixml.cpp:5490
static void Parse(const pugi::xml_document &xml, carla::road::MapBuilder &map_builder)
std::string ContId
Definition: RoadTypes.h:29
xml_object_range< xml_node_iterator > children() const
Definition: pugixml.cpp:5425