118 std::vector<Road> roads;
121 Road road { 0,
"", 0.0, -1, 0, 0,
true, {}, {}, {} };
124 road.id = node_road.attribute(
"id").as_uint();
125 road.name = node_road.attribute(
"name").value();
126 road.length = node_road.attribute(
"length").as_double();
127 road.junction_id = node_road.attribute(
"junction").as_int();
128 std::string rule = node_road.attribute(
"rule") ? node_road.attribute(
"rule").value():
"RHT";
131 }
else if (rule ==
"LHT") {
134 std::cout <<
"Detected rule '" << rule <<
"' for road '" <<
road.id <<
"'. Defaulting to RHT." << std::endl;
140 if (link.
child(
"predecessor")) {
143 if (link.
child(
"successor")) {
152 type.
s = node_type.attribute(
"s").as_double();
153 type.type = node_type.attribute(
"type").value();
163 road.speed.emplace_back(type);
167 for (
pugi::xml_node node_offset : node_road.child(
"lanes").children(
"laneOffset")) {
168 LaneOffset offset { 0.0, 0.0, 0.0, 0.0, 0.0 };
169 offset.
s = node_offset.attribute(
"s").as_double();
170 offset.a = node_offset.attribute(
"a").as_double();
171 offset.b = node_offset.attribute(
"b").as_double();
172 offset.c = node_offset.attribute(
"c").as_double();
173 offset.d = node_offset.attribute(
"d").as_double();
174 road.section_offsets.emplace_back(offset);
177 if(
road.section_offsets.size() == 0) {
178 LaneOffset offset { 0.0, 0.0, 0.0, 0.0, 0.0 };
179 road.section_offsets.emplace_back(offset);
183 for (
pugi::xml_node node_section : node_road.child(
"lanes").children(
"laneSection")) {
186 section.
s = node_section.attribute(
"s").as_double();
189 for (
pugi::xml_node node_lane : node_section.child(
"left").children(
"lane")) {
192 lane.
id = node_lane.attribute(
"id").as_int();
194 lane.level = node_lane.attribute(
"level").as_bool();
199 if (link2.
child(
"predecessor")) {
202 if (link2.
child(
"successor")) {
208 section.lanes.emplace_back(lane);
212 for (
pugi::xml_node node_lane : node_section.child(
"center").children(
"lane")) {
215 lane.
id = node_lane.attribute(
"id").as_int();
217 lane.level = node_lane.attribute(
"level").as_bool();
222 if (link2.
child(
"predecessor")) {
225 if (link2.
child(
"successor")) {
231 section.lanes.emplace_back(lane);
235 for (
pugi::xml_node node_lane : node_section.child(
"right").children(
"lane")) {
238 lane.
id = node_lane.attribute(
"id").as_int();
240 lane.level = node_lane.attribute(
"level").as_bool();
245 if (link2.
child(
"predecessor")) {
248 if (link2.
child(
"successor")) {
254 section.lanes.emplace_back(lane);
258 road.sections.emplace_back(section);
262 roads.emplace_back(
road);
299 for (
const auto& r : roads) {
309 for (
const auto& s : r.speed) {
314 for (
const auto& s : r.section_offsets) {
320 for (
const auto& s : r.sections) {
324 for (
const auto& l : s.lanes) {
326 static_cast<uint32_t
>(l.type), l.level, l.predecessor, l.successor);
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)
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, const bool is_rht)