Roadways

Data Types and Accessing Elements

The data structure to represent roadways can be decomposed as follows:

  • Roadway The high level type containing all the information. It contains a list of RoadSegment.
    • RoadSegment: a vector of lanes
      • Lane: A driving lane on a roadway. It identified by a LaneTag. A lane is defined by a curve which

represents a center line and a width. In addition it has attributed like speed limit. A lane can be connected to other lane in the roadway, the connection are specified in the exits and entrances fields.

Lower level types:

  • Curves: A curve is a list of CurvePt
  • CurvePt: the lowest level type. It represents a point on a curve by its global position, position along the curve, curvature at this point and derivative of the curvature at this point. Other types like CurveIndex or CurveProjection are used to identify a curve point along a curve.
AutomotiveDrivingModels.move_alongFunction
move_along(roadind::RoadIndex, road::Roadway, Δs::Float64)

Return the RoadIndex at ind's s position + Δs

source
move_along(vehstate::VehicleState, roadway::Roadway, Δs::Float64;
ϕ₂::Float64=vehstate.posF.ϕ, t₂::Float64=vehstate.posF.t, v₂::Float64=vehstate.v)

returns a vehicle state after moving vehstate of a length Δs along its lane.

source

Roadway generation

AutomotiveDrivingModels.jl provide high level functions to generate road networks by drawing straight road segment and circular curves. Two predefined road network can be generated easily: multi-lane straight roadway sections and a multi-lane stadium shaped roadway.

AutomotiveDrivingModels.gen_straight_curveFunction
gen_straight_curve(A::VecE2{T}, B::VecE2{T}, nsamples::Integer) where T<:Real

Returns a Curve corresponding to a straight line between A and B. nsamples indicates the number of points to place between A and B, if set to two, the curve will only contains A and B.

source
AutomotiveDrivingModels.gen_bezier_curveFunction
gen_bezier_curve(A::VecSE2{T}, B::VecSE2{T}, rA::T, rB::T, nsamples::Int) where T <: Real

Generate a Bezier curve going from A to B with radii specified by rA and rB. It uses cubic interpolation. nsamples specifies the number of point along the curve between A and B. The more points, the more accurate the approximation is. This is useful to generate arcs.

source
AutomotiveDrivingModels.gen_straight_roadwayFunction
gen_straight_roadway(nlanes::Int, length::Float64)

Generate a roadway with a single straight segment whose rightmost lane center starts at starts at (0,0), and proceeds in the positive x direction.

source
AutomotiveDrivingModels.gen_stadium_roadwayFunction
gen_stadium_roadway(nlanes::Int; length::Float64=100.0; width::Float64=10.0; radius::Float64=25.0)

Generate a roadway that is a rectangular racetrack with rounded corners. length = length of the x-dim straight section for the innermost (leftmost) lane [m] width = length of the y-dim straight section for the innermost (leftmost) lane [m] radius = turn radius [m]

  ______________________
 /                      \ 
|                        |
|                        |
\______________________/
source

Lane

The Lane data structure represent a driving lane in the roadway. The default lane width is 3m. It contains all the low level geometry information.

AutomotiveDrivingModels.LaneType
Lane

A driving lane on a roadway. It identified by a LaneTag. A lane is defined by a curve which represents a center line and a width. In addition it has attributed like speed limit. A lane can be connected to other lane in the roadway, the connection are specified in the exits and entrances fields.

Fields

  • tag::LaneTag
  • curve::Curve
  • width::Float64 [m]
  • speed_limit::SpeedLimit
  • boundary_left::LaneBoundary
  • boundary_right::LaneBoundary
  • exits::Vector{LaneConnection} # list of exits; put the primary exit (at end of lane) first
  • entrances::Vector{LaneConnection} # list of entrances; put the primary entrance (at start of lane) first
source
AutomotiveDrivingModels.LaneTagType
LaneTag

An identifier for a lane. The lane object can be retrieved by indexing the roadway by the lane tag:

tag = LaneTag(1, 2) # second lane segment 1
lane = roadway[tag] # returns a Lane object

Fields

  • segment::Int64 segment id
  • lane::Int64 index in segment.lanes of this lane
source
AutomotiveDrivingModels.LaneBoundaryType
LaneBoundary

Data structure to represent lanes boundaries such as double yellow lines.

Fields

- `style::Symbol` ∈ :solid, :broken, :double
- `color::Symbol` ∈ :yellow, white
source
AutomotiveDrivingModels.LaneConnectionType
LaneConnection{I <: Integer, T <: Real}

Data structure to specify the connection of a lane. It connects mylane to the point target. target would typically be the starting point of a new lane.

  • downstream::Bool
  • mylane::CurveIndex{I,T}
  • target::RoadIndex{I,T}
source
AutomotiveDrivingModels.prev_laneFunction
prev_lane(lane::Lane, roadway::Roadway)

returns the lane connected to the beginning lane. If lane has several entrances, it returns the first one

source

Frenet frame

The Frenet frame is a lane relative frame to represent a position on the road network.

AutomotiveDrivingModels.FrenetType
Frenet

Represents a vehicle position and heading in a lane relative frame.

Constructors

  • Frenet(roadind::RoadIndex, roadway::Roadway; t::Float64=0.0, ϕ::Float64=0.0)
  • Frenet(roadproj::RoadProjection, roadway::Roadway)
  • Frenet(lane::Lane, s::Float64, t::Float64=0.0, ϕ::Float64=0.0)
  • Frenet(posG::VecSE2, roadway::Roadway)
  • Frenet(posG::VecSE2, lane::Lane, roadway::Roadway)

Fields

  • roadind: road index
  • s: distance along lane
  • t: lane offset, positive is to left. zero point is the centerline of the lane.
  • ϕ: lane relative heading
source

Accessing objects and projections

The main roadway object can be indexed by different object to access different elements such as lane or curve points:

  • LaneTag: indexing roadway by a lane tag will return the lane associated to the lane tag
  • RoadIndex: indexing roadway by a road index will return the curve point associated to this index
AutomotiveDrivingModels.RoadIndexType
RoadIndex{I <: Integer, T <: Real}

A data structure to index points in a roadway. Calling roadway[roadind] will return the point associated to the road index.

Fields

  • ind::CurveIndex{I,T} the index of the point in the curve
  • tag::LaneTag the lane tag of the point
source
AutomotiveDrivingModels.CurveIndexType
CurveIndex{I <: Integer, T <: Real}

Given a Curve object curve one can call curve[ind] where ind is a CurveIndex. The field t can be used to interpolate between two points in the curve.

Fields

  • i::I` index in the curve , ∈ [1:length(curve)-1]
  • t::T ∈ [0,1] for linear interpolation
source
AutomotiveDrivingModels.Vec.projMethod
proj(posG::VecSE2{T}, lane::Lane, roadway::Roadway; move_along_curves::Bool=true) where T <: Real

Return the RoadProjection for projecting posG onto the lane. This will automatically project to the next or prev curve as appropriate. if move_along_curves is false, will only project to lane.curve

source
AutomotiveDrivingModels.Vec.projMethod
proj(posG::VecSE2{T}, seg::RoadSegment, roadway::Roadway) where T <: Real

Return the RoadProjection for projecting posG onto the segment. Tries all of the lanes and gets the closest one

source
AutomotiveDrivingModels.Vec.projMethod
proj(posG::VecSE2{T}, seg::RoadSegment, roadway::Roadway) where T <: Real

Return the RoadProjection for projecting posG onto the roadway. Tries all of the lanes and gets the closest one

source
Base.getindexMethod
lane[ind::CurveIndex, roadway::Roadway]

Accessor for lanes based on a CurveIndex. Note that we extend the definition of a CurveIndex, previously ind.i ∈ [1, length(curve)-1], to:

ind.i ∈ [0, length(curve)]

where 1 ≤ ind.i ≤ length(curve)-1 is as before, but if the index is on the section between two lanes, we use:

ind.i = length(curve), ind.t ∈ [0,1] for the region between curve[end] → next
ind.i = 0,             ind.t ∈ [0,1] for the region between prev → curve[1]
source
Base.getindexMethod
Base.getindex(roadway::Roadway, segid::Int)

returns the segment associated with id segid

source
Base.getindexMethod
Base.getindex(roadway::Roadway, tag::LaneTag)

returns the lane identified by the tag LaneTag

source

Low level

AutomotiveDrivingModels.CurvePtType
CurvePt{T}

describes a point on a curve, associated with a curvature and the derivative of the curvature

  • pos::VecSE2{T} # global position and orientation
  • s::T # distance along the curve
  • k::T # curvature
  • kd::T # derivative of curvature
source
AutomotiveDrivingModels.get_curve_indexFunction
get_curve_index(curve::Curve{T}, s::T) where T <: Real

Return the CurveIndex for the closest s-location on the curve

source
get_curve_index(ind::CurveIndex, curve::Curve, Δs::T) where T <: Real

Return the CurveIndex at ind's s position + Δs

source

1D roadway

Read and Write roadways

Base.readMethod
Base.read(io::IO, ::MIME"text/plain", ::Type{Roadway})

extract roadway information from a text file and returns a roadway object.

source
Base.writeMethod
Base.write(io::IO, ::MIME"text/plain", roadway::Roadway)

write all the roadway information to a text file

source