CARLA
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
twinmodel Namespace Reference

Namespaces

namespace  geom
 

Classes

struct  BoundingBox
 
struct  ClassDefaults
 Per highway class defaults, ported from profiles.py's _EU_CLASSES. More...
 
struct  Connection
 
struct  Controller
 
struct  Elevation
 
struct  Geom
 
struct  Junction
 
struct  Lane
 One lane of a road, numbered outward from the reference line. More...
 
struct  LaneGraphOptions
 
struct  LaneLink
 
struct  LaneProfile
 The lane layout an OSM way resolves to, before it is cut at junctions. More...
 
class  LocalFrame
 WGS84 <-> local ENU metres, a transverse Mercator centred on the origin. More...
 
struct  Marking
 
struct  OsmData
 
struct  OsmMember
 
struct  OsmNode
 
struct  OsmRelation
 
struct  OsmWay
 
struct  Road
 
struct  RoadLink
 
struct  Signal
 
struct  SignalOptions
 
struct  SignalType
 
struct  TwinModelData
 Everything the OpenDRIVE writer reads. More...
 

Typedefs

using Tags = std::map< std::string, std::string >
 

Enumerations

enum class  ContactPoint { Start , End }
 
enum class  Direction { Forward , Backward , Both }
 
enum class  LaneType {
  Driving , Sidewalk , Shoulder , Parking ,
  Biking , Border , Restricted , Median ,
  None
}
 
enum class  LinkElement { Road , Junction }
 
enum class  MarkingColor { White , Yellow }
 
enum class  MarkingKind {
  None , Solid , Broken , SolidSolid ,
  SolidBroken , BrokenSolid , BrokenBroken
}
 
enum class  SignalKind {
  TrafficLight , TrafficLightPedestrian , SpeedLimit , Stop ,
  Yield , PriorityRoad , Crosswalk
}
 OpenDRIVE type/subtype follow road/SignalType.h; the crosswalk is not a signal in CARLA but an <object type="crosswalk">. More...
 

Functions

TwinModelData BuildLaneGraph (const OsmData &osm, const LocalFrame &frame, const std::string &name, const LaneGraphOptions &options=LaneGraphOptions())
 OSM ways -> roads, lanes and junctions in model space.
 
void BuildSignals (const OsmData &osm, const LocalFrame &frame, TwinModelData &model, const SignalOptions &options)
 Read traffic lights, stop and give-way signs, speed limits and crossings out of the OSM tags and attach them to the roads they govern.
 
std::string ExportXodr (const TwinModelData &model, const LocalFrame &frame)
 Serialise the model as an OpenDRIVE 1.6 document.
 
const ClassDefaults * FindClassDefaults (const std::string &highway)
 
const std::string * FindTag (const Tags &tags, const std::string &key)
 
std::vector< Geom > FitPlanView (const geom::Line3 &line, double max_offset=kMaxPlanViewOffset)
 Fit a polyline as a piecewise cubic paramPoly3 planview.
 
SignalType GetSignalType (SignalKind kind)
 
bool HasTag (const Tags &tags, const std::string &key, const std::string &value)
 
bool IsDrivable (const std::string &highway)
 True when the way carries motor traffic and should become a Road.
 
std::optional< double > ParseMaxSpeed (const std::string &value)
 Parse an OSM maxspeed value into m/s; "50", "50 km/h" and "30 mph".
 
OsmData ParseOsmXml (const std::string &xml)
 Parse an OpenStreetMap XML document.
 
LaneProfile ResolveProfile (const std::string &highway, const Tags &tags)
 Resolve the lane layout from the way's tags, falling back to the class defaults.
 
const char * ToString (ContactPoint point)
 
const char * ToString (Direction direction)
 
const char * ToString (LaneType type)
 
const char * ToString (MarkingColor color)
 
const char * ToString (MarkingKind kind)
 

Variables

constexpr double kMaxPlanViewOffset = 0.25
 A vertex whose rounding would pull the curve further than this off the polyline becomes a corner instead; export/xodr.py's MAX_PLANVIEW_OFFSET.
 

Typedef Documentation

◆ Tags

using twinmodel::Tags = typedef std::map<std::string, std::string>

Definition at line 18 of file Model.h.

Enumeration Type Documentation

◆ ContactPoint

enum class twinmodel::ContactPoint
strong
Enumerator
Start 
End 

Definition at line 40 of file Model.h.

◆ Direction

enum class twinmodel::Direction
strong
Enumerator
Forward 
Backward 
Both 

Definition at line 34 of file Model.h.

◆ LaneType

enum class twinmodel::LaneType
strong
Enumerator
Driving 
Sidewalk 
Shoulder 
Parking 
Biking 
Border 
Restricted 
Median 
None 

Definition at line 30 of file Model.h.

◆ LinkElement

enum class twinmodel::LinkElement
strong
Enumerator
Road 
Junction 

Definition at line 42 of file Model.h.

◆ MarkingColor

enum class twinmodel::MarkingColor
strong
Enumerator
White 
Yellow 

Definition at line 38 of file Model.h.

◆ MarkingKind

enum class twinmodel::MarkingKind
strong
Enumerator
None 
Solid 
Broken 
SolidSolid 
SolidBroken 
BrokenSolid 
BrokenBroken 

Definition at line 36 of file Model.h.

◆ SignalKind

enum class twinmodel::SignalKind
strong

OpenDRIVE type/subtype follow road/SignalType.h; the crosswalk is not a signal in CARLA but an <object type="crosswalk">.

Enumerator
TrafficLight 
TrafficLightPedestrian 
SpeedLimit 
Stop 
Yield 
PriorityRoad 
Crosswalk 

Definition at line 46 of file Model.h.

Function Documentation

◆ BuildLaneGraph()

TwinModelData twinmodel::BuildLaneGraph ( const OsmData &  osm,
const LocalFrame &  frame,
const std::string &  name,
const LaneGraphOptions &  options = LaneGraphOptions() 
)

OSM ways -> roads, lanes and junctions in model space.

The C++ port of twinmodel/lanegraph.py's build_lanegraph.

Definition at line 339 of file LaneGraph.cpp.

References twinmodel::LaneGraphOptions::clip, twinmodel::LaneGraphOptions::cluster_m, twinmodel::Connection::connecting_road, contact, twinmodel::Connection::contact_point, twinmodel::Lane::direction, Driving, End, twinmodel::TwinModelData::FindRoad(), FindTag(), Forward, twinmodel::LocalFrame::GetOriginLatitude(), twinmodel::LocalFrame::GetOriginLongitude(), twinmodel::geom::HeadingAt(), highway, twinmodel::Road::highway, twinmodel::geom::Hypot(), twinmodel::Lane::id, twinmodel::RoadLink::id, twinmodel::Road::id, twinmodel::Connection::id, twinmodel::Junction::id, twinmodel::Connection::incoming_road, IsDrivable(), Junction, junction, twinmodel::Road::junction_id, twinmodel::LaneGraphOptions::junction_radius, twinmodel::TwinModelData::junctions, twinmodel::Connection::lane_links, twinmodel::Road::lanes, twinmodel::geom::Length(), twinmodel::LaneGraphOptions::min_road_length, twinmodel::TwinModelData::name, node, twinmodel::OsmData::nodes, twinmodel::geom::NormalizeAngle(), twinmodel::TwinModelData::origin_lat, twinmodel::TwinModelData::origin_lon, point, twinmodel::Road::predecessor, twinmodel::Lane::predecessor_lane, twinmodel::Road::reference_line, ResolveProfile(), Road, road, road_id, twinmodel::TwinModelData::roads, Start, twinmodel::Road::successor, twinmodel::Lane::successor_lane, twinmodel::geom::To2D(), twinmodel::LocalFrame::ToLocal(), twinmodel::Lane::type, twinmodel::LaneGraphOptions::uturn_deg, twinmodel::OsmData::ways, twinmodel::Lane::width, x, and y.

Referenced by osm2odr::ConvertOSMToOpenDRIVE().

◆ BuildSignals()

void twinmodel::BuildSignals ( const OsmData &  osm,
const LocalFrame &  frame,
TwinModelData &  model,
const SignalOptions &  options 
)

◆ ExportXodr()

std::string twinmodel::ExportXodr ( const TwinModelData &  model,
const LocalFrame &  frame 
)

◆ FindClassDefaults()

const ClassDefaults * twinmodel::FindClassDefaults ( const std::string &  highway)

Definition at line 78 of file Profiles.cpp.

References highway.

Referenced by ResolveProfile().

◆ FindTag()

const std::string * twinmodel::FindTag ( const Tags &  tags,
const std::string &  key 
)
inline

Definition at line 20 of file Model.h.

References tags.

Referenced by BuildLaneGraph(), BuildSignals(), HasTag(), and ResolveProfile().

◆ FitPlanView()

std::vector< Geom > twinmodel::FitPlanView ( const geom::Line3 &  line,
double  max_offset = kMaxPlanViewOffset 
)

Fit a polyline as a piecewise cubic paramPoly3 planview.

Tangent directions are Catmull-Rom, magnitudes the chord length, each segment expressed in the frame rotated to its start tangent so hdg stays G1.

Definition at line 102 of file PlanView.cpp.

References twinmodel::Geom::coeffs, twinmodel::Geom::hdg, twinmodel::Geom::is_line, twinmodel::Geom::length, twinmodel::Geom::s, x, twinmodel::Geom::x, y, and twinmodel::Geom::y.

◆ GetSignalType()

SignalType twinmodel::GetSignalType ( SignalKind  kind)

◆ HasTag()

bool twinmodel::HasTag ( const Tags &  tags,
const std::string &  key,
const std::string &  value 
)
inline

Definition at line 25 of file Model.h.

References FindTag(), and tags.

◆ IsDrivable()

bool twinmodel::IsDrivable ( const std::string &  highway)

True when the way carries motor traffic and should become a Road.

Definition at line 70 of file Profiles.cpp.

References highway.

Referenced by BuildLaneGraph().

◆ ParseMaxSpeed()

std::optional< double > twinmodel::ParseMaxSpeed ( const std::string &  value)

Parse an OSM maxspeed value into m/s; "50", "50 km/h" and "30 mph".

Definition at line 84 of file Profiles.cpp.

Referenced by BuildSignals(), and ResolveProfile().

◆ ParseOsmXml()

OsmData twinmodel::ParseOsmXml ( const std::string &  xml)

◆ ResolveProfile()

LaneProfile twinmodel::ResolveProfile ( const std::string &  highway,
const Tags &  tags 
)

◆ ToString() [1/5]

const char * twinmodel::ToString ( ContactPoint  point)

Definition at line 65 of file ModelStrings.cpp.

References End, and point.

◆ ToString() [2/5]

const char * twinmodel::ToString ( Direction  direction)

Definition at line 26 of file ModelStrings.cpp.

References Backward, Both, and Forward.

◆ ToString() [3/5]

const char * twinmodel::ToString ( LaneType  type)

Definition at line 11 of file ModelStrings.cpp.

References Biking, Border, Driving, Median, None, Parking, Restricted, Shoulder, and Sidewalk.

Referenced by ExportXodr().

◆ ToString() [4/5]

const char * twinmodel::ToString ( MarkingColor  color)

Definition at line 48 of file ModelStrings.cpp.

References Yellow.

◆ ToString() [5/5]

const char * twinmodel::ToString ( MarkingKind  kind)

Definition at line 35 of file ModelStrings.cpp.

References Broken, BrokenBroken, BrokenSolid, None, Solid, SolidBroken, and SolidSolid.

Variable Documentation

◆ kMaxPlanViewOffset

constexpr double twinmodel::kMaxPlanViewOffset = 0.25
constexpr

A vertex whose rounding would pull the curve further than this off the polyline becomes a corner instead; export/xodr.py's MAX_PLANVIEW_OFFSET.

Definition at line 18 of file PlanView.h.