CARLA
 
载入中...
搜索中...
未找到
ControllerParser.cpp
浏览该文件的文档.
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
13namespace carla {
14namespace opendrive {
15namespace 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
static void Parse(const pugi::xml_document &xml, carla::road::MapBuilder &map_builder)
void CreateController(const ContId controller_id, const std::string controller_name, const uint32_t controller_sequence, const std::set< road::SignId > &&signals)
const char_t * value() const
Definition pugixml.cpp:5215
xml_node child(const char_t *name) const
Definition pugixml.cpp:5490
xml_attribute attribute(const char_t *name) const
Definition pugixml.cpp:5500
std::string ContId
Definition RoadTypes.h:29
std::string SignId
Definition RoadTypes.h:25
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
static void log_debug(Args &&... args)
Definition Logging.h:68