Driving Simulation

These functions help in running driving simulations.

AutomotiveInteraction.keep_vehicle_subset!Function
function 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)
source
AutomotiveInteraction.make_def_modelsFunction
function make_def_models(scene)
  • Takes an input scene and associates a default param Tim2DDriver to all the vehicles in the scene

Examples

scene = get_scene(1,traj_interaction)
models = make_def_models(scene)
source
AutomotiveInteraction.make_cidm_modelsFunction
function 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
source
Missing docstring.

Missing docstring for make_iidm_models. Check Documenter's build log for details.

AutomotiveInteraction.make_TimLaneChanger_modelsFunction
function make_TimLaneChanger_models(scene)
  • Takes input scene and associates default param Tim2DDriver model to all vehs, with lane changer being TimLaneChanger

Examples

scene = get_scene(traj_interaction)
models = make_TimLaneChanger_models(scene)
source
AutomotiveInteraction.get_hallucination_scenesFunction
function get_hallucination_scenes
  • Hallucinate starting from start_step for nsteps using models 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 at start_step

Examples

scene_list = get_hallucination_scenes(scene,models=models,duration=6)
scenelist2video(scene_list,filename="media/driving_vid.mp4")
source
AutomotiveInteraction.run_vehiclesFunction
function run_vehicles
  • Select vehicles with ids in id_list from frame number start_frame of track information in traj
  • Assign default 2D driver model to the vehicle and run it for duration seconds on roadway
  • 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 by AutomotiveDrivingModels.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"))
source
AutomotiveInteraction.compare2truthFunction

function 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")
source
AutomotiveInteraction.run_vehicles_curvept_overlayFunction
  • 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")

source
AutomotiveInteraction.test_barrier_vehicleFunction
function 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"))
source
AutomotiveInteraction.test_jumpy_vehicleFunction
function 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 between
  • separation 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")
source