Driving Simulation
These functions help in running driving simulations.
AutomotiveInteraction.keep_vehicle_subset!
— Functionfunction keep_vehicle_subset!(scene::Scene, ids::Vector{Int})
- Just keep a set of vehicles in scene as specified by
ids
(a list of vehicle ids) - Obtained from
ngsim_env/julia/src/ngsim_utils.jl
Example
scene = get_scene(1, traj_interaction)
veh_id_list = [7,10,11,18,22,25,29]
keep_vehicle_subset!(scene,veh_id_list)
AutomotiveInteraction.make_def_models
— Functionfunction make_def_models(scene)
- Takes an input
scene
and associates a default paramTim2DDriver
to all the vehicles in the scene
Examples
scene = get_scene(1,traj_interaction)
models = make_def_models(scene)
AutomotiveInteraction.make_IDM_models
— Functionfunction make_IDM_models(scene)
- Assign default parameter IDM to all vehicles in the scene
AutomotiveInteraction.make_cidm_models
— Functionfunction make_cidm_models(scene)
- Assign cooperative IDM as driver model to all vehicles in the scene
f
provides access to specific scenario i.e upper merge vs lower merge- Associated merge and main lane lane tags differ accordingly
Missing docstring for make_iidm_models
. Check Documenter's build log for details.
AutomotiveInteraction.make_TimLaneChanger_models
— Functionfunction make_TimLaneChanger_models(scene)
- Takes input
scene
and associates default param Tim2DDriver model to all vehs, with lane changer beingTimLaneChanger
Examples
scene = get_scene(traj_interaction)
models = make_TimLaneChanger_models(scene)
AutomotiveInteraction.get_hallucination_scenes
— Functionfunction get_hallucination_scenes
- Hallucinate starting from
start_step
fornsteps
usingmodels
and return a list of scenes - Used by
plot_carwise_pos_vel
to assess position and velocity traces against ground truth
Returns
halluc_scenes_list
: List containing the scenes starting with the ground truth scene atstart_step
Examples
scene_list = get_hallucination_scenes(scene,models=models,duration=6)
scenelist2video(scene_list,filename="media/driving_vid.mp4")
AutomotiveInteraction.run_vehicles
— Functionfunction run_vehicles
- Select vehicles with ids in
id_list
from frame numberstart_frame
of track information intraj
- Assign default 2D driver model to the vehicle and run it for
duration
seconds onroadway
- Writes a video to location specified by
filename
Arguments
- id_list: Vehicle ids in this list will be kept in the simulation. Others will be deleted
- traj: Vehicle traj data stored in the
Trajdata
type provided byAutomotiveDrivingModels.jl
- start_frame: Frame number of vehicle track data in
traj
- roadway: a roadway object eg:
roadway_interaction
- nomergeoverlay: If set to false then overlays the merge veh rays
Examples
scene_list = run_vehicles(id_list=[29,19,28,6,8,25,2,10,7,18,12],roadway=roadway_interaction,
filename=joinpath(@__DIR__,"julia_notebooks/media/run_test_ext_long.mp4"))
AutomotiveInteraction.compare2truth
— Functionfunction compare2truth(;idlist=[],startframe=101,duration=10,traj,roadway,filename) scenelist1 = runvehicles(idlist=idlist,startframe=start_frame,duration=duration, traj=traj,roadway=roadway)
- Compare model driven trajectory by overlaying ground truth
Examples
id_list = [6,19,28,29,34,37,40,42,43,49,50]
compare2truth(id_list=id_list,start_frame=101,traj=traj_ext,roadway=road_ext,
filename = "julia_notebooks/media/compare_startframe.mp4")
AutomotiveInteraction.run_vehicles_curvept_overlay
— Function- Written to debug the jumpy behavior by overlaying the curvepoints of roadway
Example
runvehiclescurveptoverlay(idlist=[6,8],roadway=roadext,traj=trajext, filename = "/scratch/AutomotiveInteraction/julianotebooks/media/roadext_jumpy.mp4")
AutomotiveInteraction.test_barrier_vehicle
— Functionfunction test_barrier_vehicle
- Place a vehicle that does not move to test how far IDM+MOBIL driven vehicles look ahead
Examples
test_barrier_vehicle(id_list=[20,29,19,28,6,8,25,2,10,7,18,12,100],roadway=road_ext,
traj=traj_ext,filename=joinpath(@__DIR__,"../julia_notebooks/media/barrier_test.mp4"))
AutomotiveInteraction.test_jumpy_vehicle
— Functionfunction test_jumpy_vehicle()
- Written to investigate non-smooth behavior.
- Want to assess whether having no curve points (for example when lanes are connected using
connect!
) - results in jumpy vehicle trajectory behavior
Arguments
segment_length
Length of the segment. There will be two such segments with a separation betweenseparation
Length of the break between two road segments
Examples
test_jumpy_vehicle(segment_length = 50.,separation = 5.,
filename="/scratch/AutomotiveInteraction/julia_notebooks/media/jumpy.mp4")