States

In this section of the documentation we explain the default vehicle state type provided by AutomotiveDrivingModels as well as the data types used to represent a driving scene. Most of the underlying structures are defined in Records.jl. The data structures provided in ADM.jl are concrete instances of parametric types defined in Records. It is possible in principle to define your custom state definition and use the interface defined in ADM.jl.

Entity state

Entities are represented by the Entity data type provided by Records.jl (https://github.com/sisl/Records.jl/blob/master/src/entities.jl). The Entity data type has three fields: a state, a definition and an id.

The state of an entity usually describes physical quantity such as position and velocity.

Two state data structures are provided.

Defining your own state type

You can define your own state type if the provided VehicleState does not contain the right information. There are a of couple functions that need to be defined such that other functions in AutomotiveDrivingModels can work smoothly with your custom state type.

Example of a custom state type containing acceleration:


# you can use composition to define your custom state type based on existing ones
struct MyVehicleState
    veh::VehicleState
    acc::Float64
end

# define the functions from the interface 
posg(s::MyVehicleState) = posg(s.veh) # those functions are implemented for the `VehicleState` type
posf(s::MyVehicleState) = posf(s.veh)
velg(s::MyVehicleState) = velg(s.veh)
velf(s::MyVehicleState) = velf(s.veh)
vel(s::MyVehicleState) = vel(s.veh)

1D states and vehicles

2D states and vehicles

Here we list useful functions to interact with vehicle states and retrieve interesting information like the position of the front of the vehicle or the lane to which the vehicle belongs.

AutomotiveDrivingModels.VehicleStateType
VehicleState

A default type to represent an agent physical state (position, velocity). It contains the position in the global frame, Frenet frame and the longitudinal velocity

constructors

VehicleState(posG::VecSE2{Float64}, v::Float64) 
VehicleState(posG::VecSE2{Float64}, roadway::Roadway, v::Float64)
VehicleState(posG::VecSE2{Float64}, lane::Lane, roadway::Roadway, v::Float64)
VehicleState(posF::Frenet, roadway::Roadway, v::Float64)

fields

  • posG::VecSE2{Float64} global position
  • posF::Frenet lane relative position
  • v::Float64 longitudinal velocity
source
AutomotiveDrivingModels.Vec.lerpMethod
Vec.lerp(a::VehicleState, b::VehicleState, t::Float64, roadway::Roadway)

Perform linear interpolation of the two vehicle states. Returns a VehicleState.

source
AutomotiveDrivingModels.move_alongMethod
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
AutomotiveDrivingModels.VehicleType
Vehicle

A specific instance of the Entity type defined in Records to represent Vehicles with state VehicleState , definition VehicleDef and id Int64

source
Base.convertMethod
Base.convert(::Type{Vehicle}, veh::Entity{VehicleState, D, Int64}) where D<:AbstractAgentDefinition

Converts an entity in Vehicle (it is converting the agent definition only)

source

Scenes

A Scene represents a collection of vehicles at a given time.

AutomotiveDrivingModels.SceneType
Scene

A Scene is a specific instance of the Frame type defined in Records. It represents a collection of vehicles at a given time.

Constructors

- `Scene(n::Int=100)`
- `Scene(arr::Vector{Vehicle})`
source
AutomotiveDrivingModels.SceneRecordType
SceneRecord

A SceneRecord is a specific instance of the QueueRecord type defined in Records.jl. It represents a collection of Scenes.

constructor

SceneRecord(capacity::Int, timestep::Float64, frame_capacity::Int=100)
source