AutomotiveSimulator.DIR_RIGHT
— ConstantLaneChangeChoice
A choice of whether to change lanes, and what direction to do it in
AutomotiveSimulator.AbstractAgentDefinition
— TypeAbstractAgentDefinition
An Agent definition represents static parameters characterizing an agent, such as its physical dimensions.
AutomotiveSimulator.AccelDesang
— TypeAccelDesang
An action type with a longitudinal acceleration and a desired heading angle
Fields
a::Float64
longitudinal acceleration [m/s^2]ϕdes::Float64
desired heading angle
AutomotiveSimulator.AccelSteeringAngle
— TypeAccelSteeringAngle
Allows driving the car in a circle based on the steering angle If steering angle less than threshold 0.01 radian, just drives straight
Fields
a::Float64
longitudinal acceleration [m/s^2]δ::Float64
Steering angle [rad]
AutomotiveSimulator.AccelTurnrate
— TypeAccelTurnrate
An action type with a longitudinal acceleration and a turn rate
Fields
a::Float64
longitudinal acceleration [m/s^2]ω::Float64
desired turn rate [rad/sec]
AutomotiveSimulator.BicycleModel
— TypeBicycleModel
BicycleModel(def::VehicleDef; a::Float64 = 1.5, b::Float64 = 1.5)
Vehicle definition representing the bicycle model
Fields
def::VehicleDef
a::Float64
distance between cg and front axle [m]b::Float64
distance between cg and rear axle [m]
AutomotiveSimulator.CPAMemory
— TypeCPAMemory
A structure to cache the bounding boxes around vehicle. It is part of the internals of the Minkowski collision checker.
Fields
vehA::ConvexPolygon
bounding box for vehicle AvehB::ConvexPolygon
bounding box for vehicle Bmink::ConvexPolygon
minkowski bounding box
AutomotiveSimulator.CollisionCallback
— TypeCollisionCallback
Terminates the simulation once a collision occurs
AutomotiveSimulator.CollisionCheckResult
— TypeCollisionCheckResult
A type to store the result of a collision checker
Fields
is_colliding::Bool
A::Int64
# index of 1st vehicleB::Int64
# index of 2nd vehicle
AutomotiveSimulator.ConvexPolygon
— TypeConvexPolygon
ConvexPolygon(npts::Int)
ConvexPolygon(pts::Vector{VecE2{Float64}})
Mutable structure to represent a convex polygon. It is used by the Minkowski sum collision checker
Fields
pts::Vector{VecE2{Float64}}
npts::Int
AutomotiveSimulator.CrossingPhase
— TypeCrossingPhase
Crossing phases for SidewalkPedestrianModel.
For a crossing pedestrian, phases go: -2, -1, 0, 1 For a non-crossing pedestrian that pauses at the crosswalk, phases go: -2, -1, 1 For a non-crossing pedestrian that does not pause at the crosswalk, phases go: -2, 1
Model based on Feliciani et al (2017) - A simulation model for non-signalized pedestrian crosswalks based on evidence from on field observation.
AutomotiveSimulator.Curve
— TypeCurve{T}
is a vector of curve points
AutomotiveSimulator.CurveIndex
— TypeCurveIndex{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
AutomotiveSimulator.CurveProjection
— TypeCurveProjection{I <: Integer, T <: Real}
The result of a point projected to a Curve
Fields
ind::CurveIndex{I, T}
t::T
lane offsetϕ::T
lane-relative heading [rad]
AutomotiveSimulator.CurvePt
— TypeCurvePt{T}
describes a point on a curve, associated with a curvature and the derivative of the curvature
pos::VecSE2{T}
# global position and orientations::T
# distance along the curvek::T
# curvaturekd::T
# derivative of curvature
AutomotiveSimulator.DriverModel
— TypeDriverModel{DriveAction}
A DriverModel represents a specific driving behavior. It specifies the action taken by the agent at a given scene. The ation will be of type DriveAction
. It can be interpreted as a distribution, the likelihood of taking a certain action in a given scene. The DriverModel type is an abstract type! Custom driver models should inherit from it.
AutomotiveSimulator.Entity
— TypeEntity{S,D,I}
Immutable data structure to represent entities (vehicle, pedestrian, ...). Entities are defined by a state, a definition, and an id. The state of an entity usually models changing values while the definition and the id should not change.
Constructor
Entity(state, definition, id)
Copy constructor that keeps the definition and id but changes the state (a new object is still created):
Entity(entity::Entity{S,D,I}, s::S)
Fields
state::S
def::D
id::I
AutomotiveSimulator.EntityAction
— TypeMapping from actions to entity ids. The main use case is for keeping track of the action history in the same way as the scene history in the simulate!
function.
Initialize as
EntityAction(a, id)
where a
is an action which can be used to propagate entities. id
is the entity identifier.
AutomotiveSimulator.EntityScene
— TypeEntityScene{S,D,I} = Scene{Entity{S,D,I}}
Alias for Scene
when the entities in the scene are of type Entity
Constructors
EntityScene(::Type{S},::Type{D},::Type{I}) where {S,D,I}
EntityScene(::Type{S},::Type{D},::Type{I},capacity::Int)
AutomotiveSimulator.Frenet
— TypeFrenet
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 indexs
: distance along lanet
: lane offset, positive is to left. zero point is the centerline of the lane.ϕ
: lane relative heading
AutomotiveSimulator.FrenetRelativePosition
— TypeFrenetRelativePosition
Contains information about the projection of a point on a lane. See get_frenet_relative_position
.
Fields
origin::RoadIndex
original roadindex used for the projection, contains the target lane ID.target::RoadIndex
roadindex reached after projectionΔs::Float64
longitudinal distance to the original roadindext::Float64
lateral distance to the original roadindex in the frame of the target laneϕ::Float64
angle with the original roadindex in the frame of the target lane
AutomotiveSimulator.IntelligentDriverModel
— TypeIntelligentDriverModel <: LaneFollowingDriver
The Intelligent Driver Model. A rule based driving model that is governed by parameter settings. The output is an longitudinal acceleration.
Here, we have extended IDM to the errorable IDM. If a standard deviation parameter is specified, then the output is a longitudinal acceleration sampled from a normal distribution around the non-errorable IDM output.
Fields
a::Float64 = NaN
the predicted acceleration i.e. the output of the modelσ::Float64 = NaN
allows errorable IDM, optional stdev on top of the model, set to zero or NaN for deterministic behaviork_spd::Float64 = 1.0
proportional constant for speed tracking when in freeflow [s⁻¹]δ::Float64 = 4.0
acceleration exponentT::Float64 = 1.5
desired time headway [s]v_des::Float64 = 29.0
desired speed [m/s]s_min::Float64 = 5.0
minimum acceptable gap [m]a_max::Float64 = 3.0
maximum acceleration ability [m/s²]d_cmf::Float64 = 2.0
comfortable deceleration m/s²d_max::Float64 = 9.0
maximum deceleration m/s²
AutomotiveSimulator.Lane
— TypeLane
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
AutomotiveSimulator.LaneBoundary
— TypeLaneBoundary
Data structure to represent lanes boundaries such as double yellow lines.
Fields
- `style::Symbol` ∈ :solid, :broken, :double
- `color::Symbol` ∈ :yellow, white
AutomotiveSimulator.LaneConnection
— TypeLaneConnection{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}
AutomotiveSimulator.LaneFollowingAccel
— TypeLaneFollowingAccel
Longitudinal acceleration. The resulting vehicle velocity is capped below at 0 (i.e. standstill). Negative velocities are not allowed.
Fields
a::Float64
longitudinal acceleration [m/s^2]
AutomotiveSimulator.LaneTag
— TypeLaneTag
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 idlane::Int64
index in segment.lanes of this lane
AutomotiveSimulator.LatLonAccel
— TypeLatLonAccel
Acceleration in the frenet frame
Fields
a_lat::Float64
Lateral acceleration [m/s^2]a_lon::Float64
Longitudinal acceleration [m/s^2]
AutomotiveSimulator.MOBIL
— TypeMOBIL
See Treiber & Kesting, 'Modeling Lane-Changing Decisions with MOBIL'
Constructor
MOBIL(;kwargs...)
The keyword arguments are the fields highlighted below.
Fields
dir::Int = DIR_MIDDLE
mlon::LaneFollowingDriver=IntelligentDriverModel()
safe_decel::Float64=2.0
politeness::Float64=0.35
advantage_threshold::Float64=0.1
AutomotiveSimulator.NeighborLongitudinalResult
— TypeNeighborLongitudinalResult
A structure to retrieve information about a neihbor in the longitudinal direction i.e. rear and front neighbors on the same lane. If the neighbor index is equal to nothing
it means there is no neighbor.
Fields
ind::Union{Nothing, Int64}
index of the neighbor in the sceneΔs::Float64
positive distance along the lane between vehicles positions
AutomotiveSimulator.PedestrianLatLonAccel
— TypePedestrianLatLonAccel
Pedestrian walking action. Acceleration in the Frenet frame, along with desired lane after crossing the street.
Fields
a_lat::Float64
lateral acceleration [m/s^2]a_lon::Float64
longitudinal accelaration [m/s^2]lane_des::Lane
desired lane to move to
AutomotiveSimulator.PrincetonDriver
— TypePrincetonDriver <: LaneFollowingDriver
A lane following driver model that controls longitudinal speed by following a front car.
Fields
a::Float64
σ::Float64 = NaN
optional stdev on top of the model, set to zero or NaN for deterministic behaviork::Float64 = 1.0
proportional constant for speed tracking [s⁻¹]v_des::Float64 = 29.0
desired speed [m/s]
AutomotiveSimulator.ProportionalLaneTracker
— TypeProportionalLaneTracker
A controller that executes the lane change decision made by the lane change models
Constructors
ProportionalLaneTracker(;σ::Float64 = NaN,kp::Float64 = 3.0,kd::Float64 = 2.0)
Fields
a::Float64 = NaN
predicted accelerationσ::Float64 = NaN
optional stdev on top of the model, set to zero or NaN for deterministic behaviorkp::Float64 = 3.0
proportional constant for lane trackingkd::Float64 = 2.0
derivative constant for lane tracking
AutomotiveSimulator.ProportionalSpeedTracker
— TypeProportionalSpeedTracker <: LaneFollowingDriver
Longitudinal proportional speed control.
Fields
a::Float64 = NaN
predicted accelerationσ::Float64 = NaN
optional stdev on top of the model, set to zero or NaN for deterministic behaviork::Float64 = 1.0
proportional constant for speed tracking [s⁻¹]v_des::Float64 = 29.0
desired speed [m/s]
AutomotiveSimulator.RoadIndex
— TypeRoadIndex{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 curvetag::LaneTag
the lane tag of the point
AutomotiveSimulator.RoadProjection
— TypeRoadProjection{I <: Integer, T <: Real}
represents the projection of a point on the roadway
Fields
curveproj::CurveProjection{I, T}
tag::LaneTag
AutomotiveSimulator.RoadSegment
— TypeRoadSegment{T}
a list of lanes forming a single road with a common direction
Fields
id::Int64
lanes::Vector{Lane{T}}
lanes are stored right to left
AutomotiveSimulator.Roadway
— TypeRoadway
The main datastructure to represent road network, it consists of a list of RoadSegment
Fields
segments::Vector{RoadSegment}
AutomotiveSimulator.Scene
— TypeScene{E}
Container to store a list of entities. The main difference from a regular array is that its size is defined at construction and is fixed. (push!
is O(1))
Constructors
Scene(arr::AbstractVector; capacity::Int=length(arr))
Scene(::Type{E}, capacity::Int=100) where {E}
Fields
To interact with Scene
object it is preferable to use functions rather than accessing the fields directly.
entities::Vector{E}
n::Int
current number of entities in the scene
AutomotiveSimulator.SidewalkPedestrianModel
— TypeSidewalkPedestrianModel
Walks along the sidewalk until approaching the crosswalk. Waits for the cars to pass, then crosses.
Fields
timestep::Float64
phase::Int = APPROACHING
ttc_threshold::Float64 = clamp(rand(Normal(4.0, 2.5)), 1.0, Inf)
crosswalk::Lane = Lane()
sw_origin::Lane = Lane()
sw_dest::Lane = Lane()
a::PedestrianLatLonAccel = PedestrianLatLonAccel(0.0, 0.0, sw_origin)
makes you turn, left/rightσ::Float64 = NaN
optional stdev on top of the model, set to zero or NaN for deterministicv_des_approach::Float64 = clamp(rand(Normal(1.28, 0.18)), 0.0, Inf)
Based on Feliciani et al. resultsv_des_appraise::Float64 = clamp(rand(Normal(0.94, 0.21)), 0.0, Inf)
v_des_cross::Float64 = clamp(rand(Normal(1.35, 0.18)), 0.0, Inf)
ped_accel::Float64 = 0.30
ped_decel::Float64 = -0.50
AutomotiveSimulator.SpeedLimit
— TypeSpeedLimit
Datastructure to represent a speed limit
Fields
lo::Float64
[m/s] lower speed limithi::Float64
[m/s] higher speed limit
AutomotiveSimulator.StaticDriver
— TypeStaticDriver{A,P<:ContinuousMultivariateDistribution} <: DriverModel{A}
A driver model where actions are always sampled by the same distribution specified by the field distribution
.
Fields
distribution::P
AutomotiveSimulator.Tim2DDriver
— TypeTim2DDriver
Driver that combines longitudinal driver and lateral driver into one model.
Constructors
Tim2DDriver(;kwargs...)
The keywords argument are the fields described below.
Fields
mlon::LaneFollowingDriver = IntelligentDriverModel()
Longitudinal driving modelmlat::LateralDriverModel = ProportionalLaneTracker()
Lateral driving modelmlane::LaneChangeModel =TimLaneChanger
Lane change model
AutomotiveSimulator.TimLaneChanger
— TypeTimLaneChanger
A simple lane change behavior that changes lanes whenever the lead car is going slower than our desired speed. Lane changes are made when there is an available lane, fore/rear gaps exceed our thresholds, we are faster than a rear vehicle in the target lane, and any lead vehicle in the target lane is faster than we can currently go.
Has not been published anywhere, so first use in a paper would have to describe this. See MOBIL if you want a lane changer you can cite.
Constructors
TimLaneChanger(v_des::Float64=29.0, threshold_fore::Float64 = 50.0,threshold_lane_change_gap_fore::Float64 = 10.0, threshold_lane_change_gap_rear::Float64 = 10.0,dir::Int=DIR_MIDDLE)
Fields
dir::Int = DIR_MIDDLE
the desired lane to go to eg: left,middle (i.e. stay in same lane) or rightv_des::Float64 = 29.0
desired velocitythreshold_fore::Float64 = 50.0
Distance from lead vehiclethreshold_lane_change_gap_fore::Float64 = 10.0
Space in frontthreshold_lane_change_gap_rear::Float64 = 10.0
Space rear
AutomotiveSimulator.VehicleDef
— TypeVehicleDef(;class::Float64, length::Float64, width::Float64)
Vehicle definition which contains a class and a bounding box.
AutomotiveSimulator.VehicleState
— TypeVehicleState
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 positionposF::Frenet
lane relative positionv::Float64
longitudinal velocity
AutomotiveSimulator.VehicleTargetPoint
— TypeVehicleTargetPoint
Defines a point on an entity that is used to measure distances. The following target points are supported and are subtypes of VehicleTargetPoint:
VehicleTargetPointFront
VehicleTargetPointCenter
VehicleTargetPointRear
The method targetpoint_delta(::VehicleTargetPoint, ::Entity)
can be used to compute the delta in the longitudinal direction to add when considering a specific target point.
AutomotiveSimulator.VehicleTargetPointCenter
— TypeVehicleTargetPointCenter <: VehicleTargetPoint
Set the target point at the center of the entity.
AutomotiveSimulator.VehicleTargetPointFront
— TypeVehicleTargetPointFront <: VehicleTargetPoint
Set the target point at the front (and center) of the entity.
AutomotiveSimulator.VehicleTargetPointRear
— TypeVehicleTargetPointFront <: VehicleTargetPoint
Set the target point at the front (and center) of the entity.
AutomotiveSimulator.Vec.get_distance
— MethodVec.get_distance(A::Entity{S,D,I}, B::Entity{S,D,I}, mem::CPAMemory=CPAMemory()) where {D<:AbstractAgentDefinition,I}
returns the euclidean distance between A and B.
AutomotiveSimulator.Vec.lerp
— MethodVec.lerp(a::VehicleState, b::VehicleState, t::Float64, roadway::Roadway)
Perform linear interpolation of the two vehicle states. Returns a VehicleState.
AutomotiveSimulator.Vec.lerp
— Methodquadratic bezier lerp
AutomotiveSimulator.Vec.lerp
— Methodcubic bezier lerp
AutomotiveSimulator.Vec.proj
— MethodVec.proj(posG::VecSE2, curve::Curve)
Return a CurveProjection obtained by projecting posG onto the curve
AutomotiveSimulator.Vec.proj
— Methodproj(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
AutomotiveSimulator.Vec.proj
— Methodproj(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
AutomotiveSimulator.Vec.proj
— Methodproj(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
AutomotiveSimulator._run_callbacks
— MethodInternals, run all callbacks
AutomotiveSimulator.acc
— Methodacc(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the history of acceleration of the entity of id vehid using finite differences on the velocity. The first element is missing
.
AutomotiveSimulator.accfs
— Methodaccfs(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the history of longitudinal acceleration in the Frenet frame of the entity of id vehid using finite differences on the velocity. The first element is missing
.
AutomotiveSimulator.accft
— Methodaccft(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the history of lateral acceleration in the Frenet frame of the entity of id vehid using finite differences on the velocity. The first element is missing
.
AutomotiveSimulator.action_type
— Methodaction_type(::DriverModel{A}) where {A}
returns the type of the actions that are sampled from the model
AutomotiveSimulator.capacity
— Methodcapacity(scene::Scene)
returns the maximum number of entities that can be put in the scene. To get the current number of entities use length
instead.
AutomotiveSimulator.class
— Methodclass(def::AbstractAgentDefinition)
return the class of the vehicle
AutomotiveSimulator.collision_checker
— Methodcollision_checker(veh_a::Entity, veh_b::Entity)
collision_checker(veh_a, veh_b, veh_a_def::AbstractAgentDefinition, veh_b_def::AbstractAgentDefinition)
return True if veh_a
and veh_b
collides. Relies on the parallel axis theorem.
AutomotiveSimulator.collision_checker
— Methodcollision_checker(scene::Scene{Entity{S,D,I}}, egoid::I) where {S, D<:AbstractAgentDefinition, I}
return true if any entity in the scene collides with the entity of id egoid
.
AutomotiveSimulator.connect!
— Methodconnect!(source::Lane, dest::Lane)
connect two lanes to each other. Useful for roadway construction.
AutomotiveSimulator.dist_to_front_neighbor
— Methoddist_to_front_neighbor(roadway::Roadway, scene::Scene, veh::Entity)
Feature function to extract the longitudinal distance to the front neighbor (in the Frenet frame). Returns missing
if there are no front neighbor.
AutomotiveSimulator.distance_to
— Methoddistance_to(egoid)
generate a feature function distancetoegoid.
distance_to_$egoid(roadway, scene, veh)
returns the distance between veh and the vehicle of id egoid in the scene.
AutomotiveSimulator.estimated_time_to_lane_crossing
— Methodestimated_time_to_lane_crossing(roadway::Roadway, veh::Entity)
minimum of the time to crossing left and time to crossing right.
AutomotiveSimulator.extract_features
— Methodextract_features(features, roadway::Roadway, scenes::Vector{<:Scene}, ids::Vector{I}) where I
Extract information from a list of scenes. It returns a dictionary of DataFrame objects.
Inputs
features
: a tuple of feature functions. The feature types supported areEntityFeature
,SceneFeature
andTemporalFeature
. Check the documentation for the list of available feature functions, and how to implement you own feature function.roadway::Roadway
: the roadway associated to the scenes.scenes::Vector{<:Scene}
: the simulation data from which we wish to extract information from. Each scene in the vector corresponds to one time step.ids::Vector{I}
: a list of entity IDs for which we want to extract the information.
Output
A dictionary mapping IDs to DataFrame
objects. For a given ID, the DataFrame's columns correspond to the name of the input feature functions. The row correspond to the feature value for each scene (time history).
Example:
roadway = gen_straight_roadway(4, 100.0)
scene_0 = Scene([
Entity(VehicleState(VecSE2( 0.0,0.0,0.0), roadway, 10.0), VehicleDef(AgentClass.CAR, 5.0, 2.0), 1),
Entity(VehicleState(VecSE2(10.0,0.0,0.0), roadway, 10.0), VehicleDef(AgentClass.CAR, 5.0, 2.0), 2),
])
scene_1 = Scene([
Entity(VehicleState(VecSE2( 10.0,0.0,0.0), roadway, 10.0), VehicleDef(AgentClass.CAR, 5.0, 2.0), 1),
Entity(VehicleState(VecSE2(20.0,0.0,0.0), roadway, 10.0), VehicleDef(AgentClass.CAR, 5.0, 2.0), 2),
])
dfs = extract_features((posgx, iscolliding), roadway, [scene_0, scene_1], [1,2])
dfs[1].posgx # history of global x position for vehicle of ID 1
AutomotiveSimulator.featuretype
— Methodfeaturetype(f::Function)
function used for dispatching feature types depending on the method of the feature function
AutomotiveSimulator.find_neighbor
— Methodfind_neighbor(scene::Scene, roadway::Roawday, ego::Entity; kwargs...)
Search through lanes and road segments to find a neighbor of ego
in the scene
. Returns a NeighborLongitudinalResult
object with the index of the neighbor in the scene and its relative distance.
Arguments
scene::Scene
the scene containing all the entitiesroadway::Roadway
the road topology on which entities are drivingego::Entity
the entity that we want to compute the neighbor of.
Keyword arguments
lane::Union{Nothing, Lane}
the lane on which to search the neighbor, if different from the ego vehicle current lane, it uses the projection of the ego vehicle on the given lane as a reference point. If nothing, returns nothing.rear::Bool = false
set to true to search for rear neighbor, search forward neighbor by defaultmax_distance::Float64 = 250.0
stop searching after this distance is reached, if the neighbor is further than max_distance, returns nothingtargetpoint_ego::VehicleTargetPoint
the point on the ego vehicle used for distance calculation, seeVehicleTargetPoint
for more infotargetpoint_neighbor::VehicleTargetPoint
the point on the neighbor vehicle used for distance calculation, seeVehicleTargetPoint
for more infoids_to_ignore::Union{Nothing, Set{I}} = nothing
a list of entity ids to ignore for the search, ego is always ignored.
AutomotiveSimulator.find_separating_axis
— Methodfind_separating_axis(poly_a::SMatrix{4, 2, Float64}, poly_b::SMatrix{4, 2, Float64})
build a list of candidate separating axes from the edges of a /!\ edges needs to be ordered
AutomotiveSimulator.front_neighbor_speed
— Methodfront_neighbor_speed(roadway::Roadway, scene::Scene, veh::Entity)
Feature function to extract the velocity of the front neighbor. Returns missing
if there are no front neighbor.
AutomotiveSimulator.gen_bezier_curve
— Methodgen_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.
AutomotiveSimulator.gen_stadium_roadway
— Methodgen_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]
______________________
/ \
| |
| |
\______________________/
AutomotiveSimulator.gen_straight_curve
— Methodgen_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.
AutomotiveSimulator.gen_straight_roadway
— Functiongen_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.
AutomotiveSimulator.gen_straight_segment
— Functiongen_straight_segment(seg_id::Integer, nlanes::Integer, length::Float64=1000.0;
Generate a straight RoadSegment
with nlanes
number of lanes of length length
.
AutomotiveSimulator.get_by_id
— Methodget_by_id(scene::EntityScene{S,D,I}, id::I) where {S,D,I}
Retrieve the entity by its id
. This function uses findfirst
which is O(n).
AutomotiveSimulator.get_center
— Methodget_center(veh::Entity{VehicleState, D, I})
returns the position of the center of the vehicle
AutomotiveSimulator.get_collision_time
— Methodget_collision_time(ray::VecSE2{Float64}, poly::ConvexPolygon, ray_speed::Float64)
returns the collision time between a ray and a polygon given ray_speed
AutomotiveSimulator.get_curve_index
— Methodget_curve_index(curve::Curve{T}, s::T) where T <: Real
Return the CurveIndex for the closest s-location on the curve
AutomotiveSimulator.get_curve_index
— Methodget_curve_index(ind::CurveIndex, curve::Curve, Δs::T) where T <: Real
Return the CurveIndex at ind's s position + Δs
AutomotiveSimulator.get_edge
— Functionget_edge(pts::Vector{VecE2{Float64}}, i::Int, npts::Int=length(pts))
returns the ith edge in pts
AutomotiveSimulator.get_first_collision
— Methodget_first_collision(scene::EntityScene{S,D,I}, mem::CPAMemory=CPAMemory()) where {S,D<:AbstractAgentDefinition,I}
Loops through the scene and finds the first collision between any two vehicles
AutomotiveSimulator.get_first_collision
— Methodget_first_collision(scene::EntityScene{S,D,I}, vehicle_indeces::AbstractVector{Int}, mem::CPAMemory=CPAMemory()) where {S,D<:AbstractAgentDefinition,I}
Loops through the scene and finds the first collision between any two vehicles in vehicle_indeces
.
AutomotiveSimulator.get_first_collision
— Methodget_first_collision(scene::EntityScene{S,D,I}, target_index::Int, mem::CPAMemory=CPAMemory()) where {S,D<:AbstractAgentDefinition,I}
Loops through the scene and finds the first collision between a vehicle and scene[target_index]
AutomotiveSimulator.get_footpoint
— Methodget_footpoint(veh::Entity{VehicleState, D, I})
returns the position of the footpoint of the vehicle
AutomotiveSimulator.get_frenet_relative_position
— Methodget_frenet_relative_position(veh_fore::Entity, veh_rear::Entity, roadway::Roadway)
return the Frenet relative position between the two vehicles. It projects the position of the first vehicle onto the lane of the second vehicle. The result is stored as a FrenetRelativePosition
.
Lower level: getfrenetrelativeposition(posG::VecSE2{Float64}, roadind::RoadIndex, roadway::Roadway; maxdistancefore::Float64 = 250.0, # max distance to search forward [m] maxdistancerear::Float64 = 250.0, # max distance to search backward [m] improvementthreshold::Float64 = 1e-4, )
Project the given point to the same lane as the given RoadIndex. This will return the projection of the point, along with the Δs along the lane from the RoadIndex. The returned type is a FrenetRelativePosition
object.
AutomotiveSimulator.get_front
— Methodget_front(veh::Entity{VehicleState, VehicleDef, I})
returns the position of the front of the vehicle
AutomotiveSimulator.get_lane
— Methodget_lane(roadway::Roadway, vehicle::Entity)
get_lane(roadway::Roadway, vehicle::VehicleState)
return the lane where vehicle
is in.
AutomotiveSimulator.get_lerp_time
— Methodget_lerp_time(A::VecE2, B::VecE2, Q::VecE2)
Get lerp time t∈[0,1] such that lerp(A, B) is as close as possible to Q
AutomotiveSimulator.get_lerp_time_unclamped
— Methodget_lerp_time_unclamped(A::VecE2, B::VecE2, Q::VecE2)
Get the interpolation scalar t for the point on the line AB closest to Q This point is P = A + (B-A)*t
AutomotiveSimulator.get_oriented_bounding_box
— Methodget_oriented_bounding_box(center::VecSE2{Float64}, len::Float64, wid::Float64) = to_oriented_bounding_box!(ConvexPolygon(4), center, len, wid)
get_oriented_bounding_box(veh::Entity{S,D,I}, center::VecSE2{Float64} = get_center(veh)) where {S,D<:AbstractAgentDefinition,I}
Returns a ConvexPolygon representing a bounding rectangle of the size specified by center, length, width
AutomotiveSimulator.get_rear
— Methodget_rear(veh::Entity{VehicleState, VehicleDef, I})
returns the position of the rear of the vehicle
AutomotiveSimulator.has_lane_left
— Methodhas_lane_left(roadway::Roadway, veh::Entity)
Return true if veh
has a lane on its left.
AutomotiveSimulator.has_lane_right
— Methodhas_lane_right(roadway::Roadway, veh::Entity)
Return true if veh
has a lane on its right.
AutomotiveSimulator.has_lanetag
— Methodhas_lanetag(roadway::Roadway, tag::LaneTag)
returns true if roadway
contains a lane identified by tag
AutomotiveSimulator.has_next
— Methodhas_next(lane::Lane)
returns true if the end of the lane is connected to another lane (i.e. if it has an exit lane)
AutomotiveSimulator.has_prev
— Methodhas_prev(lane::Lane)
returns true if another lane is connected to the beginning of that lane. (i.e. if it has an entrance lane)
AutomotiveSimulator.has_segment
— Methodhas_segment(roadway::Roadway, segid::Int)
returns true if segid
is in roadway
.
AutomotiveSimulator.index_closest_to_point
— Methodindex_closest_to_point(curve::Curve, target::AbstractVec)
returns the curve index closest to the point described by target
. target
must be [x, y].
AutomotiveSimulator.is_at_curve_end
— Methodis_at_curve_end(ind::CurveIndex, curve::Curve)
returns true if the curve index is at the end of the curve
AutomotiveSimulator.is_between_segments
— Methodis_between_segments(ind::CurveIndex, curve::Curve)
AutomotiveSimulator.is_between_segments_hi
— Methodis_between_segments_hi(ind::CurveIndex, curve::Curve)
AutomotiveSimulator.is_between_segments_lo
— Methodis_between_segments_lo(ind::CurveIndex)
AutomotiveSimulator.is_colliding
— Methodis_colliding(ray::VecSE2{Float64}, poly::ConvexPolygon)
returns true if the ray collides with the polygon
AutomotiveSimulator.is_colliding
— Methodis_colliding(A::Entity{S,D,I}, B::Entity{S,D,I}, mem::CPAMemory=CPAMemory()) where {D<:AbstractAgentDefinition,I}
returns true if the vehicles A and B are colliding. It uses Minkowski sums. is_colliding(mem::CPAMemory) returns true if vehA and vehB in mem collides.
AutomotiveSimulator.is_collision_free
— Methodis_collision_free(scene::EntityScene{S,D,I}, mem::CPAMemory=CPAMemory()) where {S,D<:AbstractAgentDefinition,I}
is_collision_free(scene::EntityScene{S,D,I}, vehicle_indeces::AbstractVector{Int}, mem::CPAMemory=CPAMemory()) where {S,D<:AbstractAgentDefinition,I}
Check that there is no collisions between any two vehicles in scene
If vehicle_indeces
is used, it only checks for vehicles within scene[vehicle_indeces]
AutomotiveSimulator.is_in_entrances
— Methodis_in_entrances(lane::Lane, target::LaneTag)
returns true if target
is in the entrances lanes of lane
.
AutomotiveSimulator.is_in_exits
— Methodis_in_exits(lane::Lane, target::LaneTag)
returns true if target
is in the exit lanes of lane
.
AutomotiveSimulator.is_potentially_colliding
— Methodis_potentially_colliding(A::Entity{S,D,I}, B::Entity{S,D,I}) where {S,D<:AbstractAgentDefinition,I}
A fast collision check to remove things clearly not colliding
AutomotiveSimulator.isaccelerating
— Methodisaccelerating(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
history of acceleration events: true when the acceleration is positive The first element is missing.
AutomotiveSimulator.isbraking
— Methodisbraking(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
history of braking events: true when the acceleration is negative. The first element is missing.
AutomotiveSimulator.iscolliding
— Methodiscolliding(roadway::Roadway, scene::Scene, veh::Entity)
returns true if the vehicle is colliding with another vehicle in the scene.
AutomotiveSimulator.iswaiting
— Methodiswaiting(roadway::Roadway, veh::Entity)
returns true if the vehicle is waiting (if the velocity is 0.0)
AutomotiveSimulator.jerk
— Methodjerk(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the jerk history of the entity of id vehid using finite differences on acceleration (which uses finite differences on velocity). The first two elements are missing.
AutomotiveSimulator.jerkfs
— Methodjerkfs(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the longitudinal jerk history in the Frenet frame of the entity of id vehid using finite differences on acceleration (which uses finite differences on velocity). The first two elements are missing.
AutomotiveSimulator.jerkft
— Methodjerkft(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the lateral jerk history in the Frenet frame of the entity of id vehid using finite differences on acceleration (which uses finite differences on velocity). The first two elements are missing.
AutomotiveSimulator.lane_curvature
— Methodlane_curvature(roadway::Roadway, veh::Entity)
Return the curvature of the lane at veh
's position. Return missing if the curvature is NaN
AutomotiveSimulator.lane_offset_left
— Methodlane_offset_left(roadway::Roadway, veh::Entity)
returns the distance to the left lane border, if there are no left lane returns missing
AutomotiveSimulator.lane_offset_right
— Methodlane_offset_right(roadway::Roadway, veh::Entity)
returns the distance to the right lane border, if there are no right lane returns missing
AutomotiveSimulator.lane_width
— Methodlane_width(roadway::Roadway, veh::Entity)
Returns the width of the lane where veh
is.
AutomotiveSimulator.lanes
— Methodlanes(roadway::Roadway{T}) where T
return a list of all the lanes present in roadway.
AutomotiveSimulator.lanetags
— Methodlanetags(roadway::Roadway)
return a list of all the lane tags present in roadway.
AutomotiveSimulator.leftlane
— Methodleftlane(roadway::Roadway, veh::Entity)
returns the lane to the left of the lane veh is currently in, returns nothing if it does not exists
AutomotiveSimulator.leftlane
— Methodleftlane(roadway::Roadway, lane::Lane)
returns the lane to the left of lane if it exists, returns nothing otherwise
AutomotiveSimulator.markerdist_left
— Methodmarkerdist_left(roadway::Roadway, veh::Entity)
distance of veh
to the left marker of the lane
AutomotiveSimulator.markerdist_right
— Methodmarkerdist_left(roadway::Roadway, veh::Entity)
distance of veh
to the right marker of the lane
AutomotiveSimulator.maximum_entities
— Methodmaximum_entities(trajdata::Vector{<:EntityScene})
return the maximum number of entities present in a given scene of the trajectory.
AutomotiveSimulator.move_along
— Methodmove_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.
AutomotiveSimulator.move_along
— Methodmove_along(roadind::RoadIndex, road::Roadway, Δs::Float64)
Return the RoadIndex at ind's s position + Δs
AutomotiveSimulator.n_lanes_left
— Methodn_lanes_left(roadway::Roadway, veh::Entity)
return the numbers of lanes to the left of veh
AutomotiveSimulator.n_lanes_left
— Methodn_lanes_left(roadway::Roadway, lane::Lane)
returns the number of lanes to the left of lane
AutomotiveSimulator.n_lanes_right
— Methodn_lanes_right(roadway::Roadway, veh::Entity)
return the numbers of lanes to the right of veh
AutomotiveSimulator.n_lanes_right
— Methodn_lanes_right(roadway::Roadway, lane::Lane)
returns the number of lanes to the right of lane
AutomotiveSimulator.next_lane
— Methodnext_lane(lane::Lane, roadway::Roadway)
returns the lane connected to the end lane
. If lane
has several exits, it returns the first one
AutomotiveSimulator.next_lane_point
— Methodnext_lane_point(lane::Lane, roadway::Roadway)
returns the point of connection between lane
and its first exit
AutomotiveSimulator.observe!
— Functionobserve!(model::DriverModel, scene, roadway, egoid)
Observes the scene and updates the model states accordingly.
AutomotiveSimulator.observe_from_history!
— Functionobserve_from_history!(model::DriverModel, roadway::Roadway, trajdata::Vector{<:EntityScene}, egoid, start::Int, stop::Int)
Given a prerecorded trajectory trajdata
, run the observe function of a driver model for the scenes between start
and stop
for the vehicle of id egoid
. The ego vehicle does not take any actions, it just observe the scenes,
AutomotiveSimulator.overlap
— Methodoverlap(poly_a::SMatrix{4, 2, Float64}, poly_b::SMatrix{4, 2, Float64})
Check if two convex polygons overlap, using the parallel axis theorem a polygon is a nx2 matrix where n in the number of verteces http://gamemath.com/2011/09/detecting-whether-two-convex-polygons-overlap/ /!\ edges needs to be ordered
AutomotiveSimulator.polygon
— Methodpolygon(pos::VecSE2{Float64}, veh_def::AbstractAgentDefinition)
polygon(x::Float64,y::Float64,theta::Float64, length::Float64, width::Float64)
returns a 4x2 static matrix corresponding to a rectangle around a car centered at pos
and of dimensions specified by veh_def
AutomotiveSimulator.polygon_projection
— Methodpolygon_projection(poly::SMatrix{4, 2, Float64}, axis::Vector{Float64})
return the projection interval for the polygon poly over the axis axis
AutomotiveSimulator.posf
— Functionposf(state)
returns the coordinates of the state in the Frenet frame. The return type is expected to be Frenet
.
AutomotiveSimulator.posfs
— Methodposfs(roadway::Roadway, veh::Entity)
returns longitudinal position in Frenet frame
AutomotiveSimulator.posft
— Methodposft(roadway::Roadway, veh::Entity)
returns lateral position in Frenet frame
AutomotiveSimulator.posfϕ
— Methodposfϕ(roadway::Roadway, veh::Entity)
returns heading relative to centerline of the lane
AutomotiveSimulator.posg
— Functionposg(state)
returns the coordinates of the state in the global (world) frame. The return type is expected to be a VecSE2.
AutomotiveSimulator.posg
— Methodposg(frenet::Frenet, roadway::Roadway)
projects the Frenet position into the global frame
AutomotiveSimulator.posgx
— Methodposgx(roadway::Roadway, veh::Entity)
returns x position in the global frame
AutomotiveSimulator.posgy
— Methodposgy(roadway::Roadway, veh::Entity)
returns y position in the global frame
AutomotiveSimulator.posgθ
— Methodposgθ(roadway::Roadway, veh::Entity)
returns heading in the global frame
AutomotiveSimulator.prev_lane
— Methodprev_lane(lane::Lane, roadway::Roadway)
returns the lane connected to the beginning lane
. If lane
has several entrances, it returns the first one
AutomotiveSimulator.prev_lane_point
— Methodprev_lane_point(lane::Lane, roadway::Roadway)
returns the point of connection between lane
and its first entrance
AutomotiveSimulator.propagate
— Methodpropagate vehicle forward in time given a desired acceleration and steering angle. If steering angle higher than 0.1 radian, the vehicle drives in a circle
AutomotiveSimulator.propagate
— Methodpropagate(veh::Entity{VehicleState,D,I}, action::AccelDesang, roadway::Roadway, Δt::Float64; n_integration_steps::Int=4) where {D,I}
Propagate vehicle forward in time using a desired acceleration and heading angle
AutomotiveSimulator.propagate
— MethodPropagate vehicle forward in time using a desired acceleration and turn rate
AutomotiveSimulator.propagate
— Methodpropagate(veh::Entity{S,D,I}, action::A, roadway::R, Δt::Float64) where {S,D,I,A,R}
Take an entity of type {S,D,I} and move it over Δt seconds to produce a new entity based on the action on the given roadway.
reset_hidden_state!(model::DriverModel)
Resets the hidden states of the model.
reset_hidden_states!(models::Dict{I,M}) where {M<:DriverModel}
reset hidden states of all driver models in models
AutomotiveSimulator.rightlane
— Methodrightlane(roadway::Roadway, veh::Entity)
returns the lane to the right of the lane veh is currently in, returns nothing if it does not exists
AutomotiveSimulator.rightlane
— Methodrightlane(roadway::Roadway, lane::Lane)
returns the lane to the right of lane if it exists, returns nothing otherwise
AutomotiveSimulator.road_edge_dist_left
— Methodroad_edge_dist_left(roadway::Roadway, veh::Entity)
feature function, extract the lateral distance to the left edge of the road
AutomotiveSimulator.road_edge_dist_right
— Methodroad_edge_dist_right(roadway::Roadway, veh::Entity)
feature function, extract the lateral distance to the right edge of the road
AutomotiveSimulator.run_callback
— Functionrun_callback(callback, scenes::Vector{EntityScene}, actions::Union{Nothing, Vector{A}}, roadway::Roadway, models::Dict{I, DriverModel}, tick::Int64)
Given a callback type, run_callback
will be run at every step of a simulation run using simulate
. By overloading the run_callback
method for a custom callback type one can log information or interrupt a simulation. The run_callback
function is expected to return a boolean. If true
the simulation is stopped.
Inputs:
callback
the custom callback type used for dispatchscenes
where the simulation data is stored, note that it is only filled up to the current time step (scenes[1:tick+1]
)actions
where the actions are stored, it is only filled up toactions[tick]
roadway
the roadway where entities are movingmodels
a dictionary mapping entity IDs to driver modelstick
the index of the current time step
AutomotiveSimulator.set_desired_speed!
— Functionset_desired_speed!(model::DriverModel, v_des::Float64)
Sets a desired speed. This method is relevant for models like IDM where the vehicle tracks a nominal speed.
AutomotiveSimulator.set_desired_speed!
— MethodSet the desired speed of the longitudinal model within MOBIL
AutomotiveSimulator.simulate!
— Methodsimulate!(
scene::Scene{E}, roadway::R, models::Dict{I,M},
nticks::Int64, timestep::Float64,
scenes::Vector{Scene{E}}, actions::Union{Nothing, Vector{Scene{A}}} = nothing;
rng::AbstractRNG = Random.GLOBAL_RNG, callbacks = nothing
) where {E<:Entity,A<:EntityAction,R,I,M<:DriverModel}
Simulate the entities in scene
along a roadway
for a maximum of nticks
time steps of size timestep
. Returns the number of successfully performed timesteps.
At each time step, models
is used to determine the action for each agent. scenes
and actions
are pre-allocated vectors of Scene
s containing either Entity
s (for scenes) or EntityAction
s (for actions). If actions
is equal to nothing
(default), the action history is not tracked. scenes
must always be provided.
callbacks
is an array of callback functions which are invoked before the simulation starts and after every simulation step. Any callback function can cause an early termination by returning true
(the default return value for callback functions should be false
). The random number generator for the simulation can be provided using the rng
keyword argument, it defaults to Random.GLOBAL_RNG
.
AutomotiveSimulator.simulate
— Methodsimulate(
scene::Scene{E}, roadway::R, models::Dict{I,M}, nticks::Int64, timestep::Float64;
rng::AbstractRNG = Random.GLOBAL_RNG, callbacks = nothing
) where {E<:Entity,A,R,I,M<:DriverModel}
Simulate a scene
. For detailed information, consult the documentation of simulate!
. By default, returns a vector containing one scene per time step.
AutomotiveSimulator.simulate_from_history!
— Methodsimulate_from_history!(model::DriverModel, roadway::Roadway, trajdata::Vector{Scene{E}}, egoid, timestep::Float64,
start::Int, stop::Int, scenes::Vector{Scene{E}};
actions::Union{Nothing, Vector{Scene{A}}} = nothing, rng::AbstractRNG = Random.GLOBAL_RNG) where {E<:Entity}
Replay the given trajectory except for the entity egoid
which follows the given driver model. The resulting trajectory is stored in scenes
, the actions of the ego vehicle are stored in actions
.
AutomotiveSimulator.simulate_from_history
— Methodsimulate_from_history(model::DriverModel, roadway::Roadway, trajdata::Vector{Scene{E}}, egoid, timestep::Float64,
start::Int = 1, stop::Int = length(trajdata);
rng::AbstractRNG = Random.GLOBAL_RNG) where {E<:Entity}
Replay the given trajectory except for the entity egoid
which follows the given driver model. See simulate_from_history!
if you want to provide a container for the results or log actions.
AutomotiveSimulator.time_to_collision
— Methodtime_to_collision(roadway::Roadway, scene::Scene, veh::Entity)
Feature function to extract the time to collision with the front neighbor. Returns missing
if there are no front neighbor.
AutomotiveSimulator.time_to_crossing_left
— Methodtime_to_crossing_left(roadway::Roadway, veh::Entity)
time before crossing the left lane marker assuming constant lateral speed.
AutomotiveSimulator.time_to_crossing_right
— Methodtime_to_crossing_right(roadway::Roadway, veh::Entity)
time before crossing the right lane marker assuming constant lateral speed.
AutomotiveSimulator.to_oriented_bounding_box!
— Methodto_oriented_bounding_box!(retval::ConvexPolygon, center::VecSE2{Float64}, len::Float64, wid::Float64)
to_oriented_bounding_box!(retval::ConvexPolygon, veh::Entity{S,D,I}, center::VecSE2{Float64} = get_center(veh))
Fills in the vertices of retval
according to the rectangle specification: center, length, width
AutomotiveSimulator.turn_rate_f
— Methodturn_rate_g(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the turn rate history in the Frenet frame of the entity of id vehid using finite differences on heading in the Frenet frame. The first element is missing.
AutomotiveSimulator.turn_rate_g
— Methodturn_rate_g(roadway::Roadway, scenes::Vector{<:Scene}, vehid)
returns the turn rate history in the Frenet frame of the entity of id vehid using finite differences on global heading. The first element is missing.
AutomotiveSimulator.vel
— Functionvel(state)
returns the norm of the longitudinal velocity.
AutomotiveSimulator.vel
— Methodvel(roadway::Roadway, veh::Entity)
returns the velocity of veh
AutomotiveSimulator.velf
— Functionvelf(state)
returns the velocity of the state in the Frenet frame.
AutomotiveSimulator.velfs
— Methodvelfs(roadway::Roadway, veh::Entity)
returns the longitudinal velocity in the Frenet frame
AutomotiveSimulator.velft
— Methodvelft(roadway::Roadway, veh::Entity)
returns the lateral velocity in the Frenet frame
AutomotiveSimulator.velg
— Functionvelg(state)
returns the velocity of the state in the global (world) frame.
AutomotiveSimulator.velgx
— Methodvelgx(roadway::Roadway, veh::Entity)
returns the velocity in the x direction of the global frame
AutomotiveSimulator.velgy
— Methodvelgy(roadway::Roadway, veh::Entity)
returns the velocity in the y direction of the global frame
AutomotiveSimulator.width
— Methodwidth(def::AbstractAgentDefinition)
return the width of the vehicle
Base.convert
— MethodBase.convert(::Type{AccelDesang}, v::Vector{Float64})
Convert a vector containing the acceleration and desired heading angle into AccelDesang type
Base.convert
— MethodTake a vector containing acceleration and desired steering angle and convert to AccelSteeringAngle
Base.convert
— MethodConvert an input vector containing desired acceleration and turn rate into the AccelTurnrate type
Base.convert
— MethodBase.convert(::Type{Entity{S, VehicleDef, I}}, veh::Entity{S, D, I}) where {S,D<:AbstractAgentDefinition,I}
Converts the definition of an entity
Base.copyto!
— MethodBase.copyto!(v::Vector{Float64}, a::AccelDesang)
Extract the AccelDesang components into a vector and return the vector
Base.copyto!
— MethodExtract acceleration and steering angle components from AccelSteeringAngle and return them into a vector
Base.copyto!
— MethodReturn a vector containing the desired acceleration and turn rate
Base.getindex
— MethodBase.getindex(roadway::Roadway, segid::Int)
returns the segment associated with id segid
Base.getindex
— MethodBase.getindex(roadway::Roadway, tag::LaneTag)
returns the lane identified by the tag LaneTag
Base.getindex
— MethodBase.getindex(roadway::Roadway, roadind::RoadIndex)
returns the CurvePt on the roadway associated to roadind
Base.getindex
— Methodlane[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]
Base.length
— Methodlength(def::AbstractAgentDefinition)
return the length of the vehicle
Base.rand
— Methodrand(model::DriverModel)
rand(rng::AbstractRNG, model::DriverModel)
Samples an action from the model.
Base.read
— MethodBase.read(io::IO, ::Type{Roadway})
extract roadway information from a text file and returns a roadway object.
Base.write
— MethodBase.write(io::IO, roadway::Roadway)
write all the roadway information to a text file