CARLA
Loading...
Searching...
No Matches
Profiles.h
Go to the documentation of this file.
1// Copyright (c) 2026 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
7#pragma once
8
9#include <optional>
10#include <string>
11
12#include "Model.h"
13
14namespace twinmodel {
15
16 /// Per highway class defaults, ported from profiles.py's _EU_CLASSES. The
17 /// urban classes sit at 3.5-3.6 m because CARLA's fire truck is 2.90 m wide.
19 double lane_width = 3.5;
20 int lanes = 2;
21 std::optional<double> sidewalk_width;
22 std::optional<double> shoulder;
23 std::optional<double> shoulder_inner;
24 };
25
26 /// The lane layout an OSM way resolves to, before it is cut at junctions.
27 struct LaneProfile {
30 double lane_width = 3.5;
31 std::optional<double> sidewalk_width;
32 std::optional<double> shoulder;
33 std::optional<double> shoulder_inner;
34 std::optional<double> speed_limit;
35 bool oneway = false;
36 };
37
38 /// True when the way carries motor traffic and should become a Road.
39 bool IsDrivable(const std::string &highway);
40
41 const ClassDefaults *FindClassDefaults(const std::string &highway);
42
43 /// Resolve the lane layout from the way's tags, falling back to the class
44 /// defaults. Honours lanes, lanes:forward/backward, oneway, width, maxspeed.
45 LaneProfile ResolveProfile(const std::string &highway, const Tags &tags);
46
47 /// Parse an OSM maxspeed value into m/s; "50", "50 km/h" and "30 mph".
48 std::optional<double> ParseMaxSpeed(const std::string &value);
49
50} // namespace twinmodel
std::string highway
Definition LaneGraph.cpp:24
Tags tags
Definition LaneGraph.cpp:25
std::optional< double > ParseMaxSpeed(const std::string &value)
Parse an OSM maxspeed value into m/s; "50", "50 km/h" and "30 mph".
Definition Profiles.cpp:84
LaneProfile ResolveProfile(const std::string &highway, const Tags &tags)
Resolve the lane layout from the way's tags, falling back to the class defaults.
Definition Profiles.cpp:96
bool IsDrivable(const std::string &highway)
True when the way carries motor traffic and should become a Road.
Definition Profiles.cpp:70
std::map< std::string, std::string > Tags
Definition Model.h:18
const ClassDefaults * FindClassDefaults(const std::string &highway)
Definition Profiles.cpp:78
Per highway class defaults, ported from profiles.py's _EU_CLASSES.
Definition Profiles.h:18
std::optional< double > shoulder
Definition Profiles.h:22
std::optional< double > sidewalk_width
Definition Profiles.h:21
std::optional< double > shoulder_inner
Definition Profiles.h:23
The lane layout an OSM way resolves to, before it is cut at junctions.
Definition Profiles.h:27
std::optional< double > speed_limit
Definition Profiles.h:34
std::optional< double > shoulder_inner
Definition Profiles.h:33
std::optional< double > sidewalk_width
Definition Profiles.h:31
std::optional< double > shoulder
Definition Profiles.h:32