87 std::vector<RoadTypeSpeed>
speed;
102 if (str ==
"driving") {
104 }
else if (str ==
"stop") {
106 }
else if (str ==
"shoulder") {
108 }
else if (str ==
"biking") {
110 }
else if (str ==
"sidewalk") {
112 }
else if (str ==
"border") {
114 }
else if (str ==
"restricted") {
116 }
else if (str ==
"parking") {
118 }
else if (str ==
"bidirectional") {
120 }
else if (str ==
"median") {
122 }
else if (str ==
"special1") {
124 }
else if (str ==
"special2") {
126 }
else if (str ==
"special3") {
128 }
else if (str ==
"roadworks") {
130 }
else if (str ==
"tram") {
132 }
else if (str ==
"rail") {
134 }
else if (str ==
"entry") {
136 }
else if (str ==
"exit") {
138 }
else if (str ==
"offramp") {
140 }
else if (str ==
"onramp") {
151 std::vector<Road> roads;
154 Road road { 0,
"", 0.0, -1, 0, 0, {}, {}, {} };
157 road.
id = node_road.attribute(
"id").as_uint();
158 road.name = node_road.attribute(
"name").value();
159 road.length = node_road.attribute(
"length").as_double();
160 road.junction_id = node_road.attribute(
"junction").as_int();
165 if (link.
child(
"predecessor")) {
168 if (link.
child(
"successor")) {
177 type.
s = node_type.attribute(
"s").as_double();
178 type.type = node_type.attribute(
"type").value();
188 road.speed.emplace_back(type);
193 LaneOffset offset { 0.0, 0.0, 0.0, 0.0, 0.0 };
194 offset.
s = node_offset.attribute(
"s").as_double();
195 offset.a = node_offset.attribute(
"a").as_double();
196 offset.b = node_offset.attribute(
"b").as_double();
197 offset.c = node_offset.attribute(
"c").as_double();
198 offset.d = node_offset.attribute(
"d").as_double();
199 road.section_offsets.emplace_back(offset);
202 if(road.section_offsets.size() == 0) {
203 LaneOffset offset { 0.0, 0.0, 0.0, 0.0, 0.0 };
204 road.section_offsets.emplace_back(offset);
211 section.
s = node_section.attribute(
"s").as_double();
217 lane.id = node_lane.attribute(
"id").as_int();
219 lane.level = node_lane.attribute(
"level").as_bool();
224 if (link2.
child(
"predecessor")) {
227 if (link2.
child(
"successor")) {
233 section.lanes.emplace_back(lane);
240 lane.id = node_lane.attribute(
"id").as_int();
242 lane.level = node_lane.attribute(
"level").as_bool();
247 if (link2.
child(
"predecessor")) {
250 if (link2.
child(
"successor")) {
256 section.lanes.emplace_back(lane);
263 lane.id = node_lane.attribute(
"id").as_int();
265 lane.level = node_lane.attribute(
"level").as_bool();
270 if (link2.
child(
"predecessor")) {
273 if (link2.
child(
"successor")) {
279 section.lanes.emplace_back(lane);
283 road.sections.emplace_back(section);
287 roads.emplace_back(road);
324 for (
auto const r : roads) {
333 for (
auto const s : r.speed) {
338 for (
auto const s : r.section_offsets) {
344 for (
auto const s : r.sections) {
348 for (
auto const l : s.lanes) {
350 static_cast<uint32_t
>(l.type), l.level, l.predecessor, l.successor);
static void ToLower(WritableRangeT &str)
static void Parse(const pugi::xml_document &xml, carla::road::MapBuilder &map_builder)
解析XML文档中的道路信息,并将其用于构建道路地图 该函数读取XML文档中的道路数据,如道路几何形状、车道信息、交叉口等 并使用这些数据来构建或更新道路地图
carla::road::Lane * AddRoadSectionLane(carla::road::LaneSection *section, const LaneId lane_id, const uint32_t lane_type, const bool lane_level, const LaneId predecessor, const LaneId successor)
void CreateRoadSpeed(Road *road, const double s, const std::string type, const double max, const std::string unit)
carla::road::Road * AddRoad(const RoadId road_id, const std::string name, const double length, const JuncId junction_id, const RoadId predecessor, const RoadId successor)
void CreateSectionOffset(Road *road, const double s, const double a, const double b, const double c, const double d)
carla::road::LaneSection * AddRoadSection(carla::road::Road *road, const SectionId id, const double s)
int as_int(int def=0) const
double as_double(double def=0) const
unsigned int as_uint(unsigned int def=0) const
const char_t * value() const
xml_node child(const char_t *name) const
xml_object_range< xml_node_iterator > children() const
xml_attribute attribute(const char_t *name) const
static road::Lane::LaneType StringToLaneType(std::string &&str)
std::vector< Lane > lanes
road::Lane::LaneType type
std::vector< LaneOffset > section_offsets
std::vector< RoadTypeSpeed > speed
std::vector< LaneSection > sections