Skip to content

Instantly share code, notes, and snippets.

@nov05
Last active June 3, 2025 14:49
Show Gist options
  • Select an option

  • Save nov05/d8a9ce2e4bd991383381fcf683c6799e to your computer and use it in GitHub Desktop.

Select an option

Save nov05/d8a9ce2e4bd991383381fcf683c6799e to your computer and use it in GitHub Desktop.

βœ… Autonomous Vehicle Risk Assessment Framework, Installation in Windows 11

Repo:
https://github.com/sisl/AutonomousRiskFramework.jl

Environment:
Windows 11, VS Code, Miniconda, Jalia 1.11.5, CARLA 0.9.13, scenario_runner 0.9.13


  • Set up julia command in the PowerShell temporarily or persistently.
Set-Alias julia "D:\software\julia-1.11.5-win64\julia-1.11.5\bin\julia.exe"   

Or run notepad $PROFILE, add the following lines.

Set-Alias julia "D:\software\julia-1.11.5-win64\julia-1.11.5\bin\julia.exe"
Write-Host "Custom profile loaded."
[compat]
# CUDA = "3"
CUDA = "3, 4, 5"  ## Nov05
# Flux = "0.10, 0.11, 0.12, 0.13"
Flux = "0.10, 0.11, 0.12, 0.13, 0.14"  ## Nov05
  • On GitHub, fork the AutonomousRiskFramework.jl repo.
    In Windows PowerShell, git clone the repo to the local machine.
cd D:\\github  
git clone https://github.com/nov05/Stanford-AutonomousRiskFramework.jl.git  
cd Stanford-AutonomousRiskFramework.jl   
  • Add the following lines in the /Stanford-AutonomousRiskFramework.jl/install.jl file.
packages = [
    ## Nov05 2025-05-31
    PackageSpec(url="https://github.com/nov05/Stanford-POMDPStressTesting.jl")
]
...
Pkg.add("cuDNN")
  • Install CARLA
    Download CARLA_0.9.13.zip for Windows 11 from https://github.com/carla-simulator/carla/releases/tag/0.9.13
    Exact to D:\software and add system variable UE4_ROOT = D:\software\CARLA_0.9.13
    Install DirectX 9.29.1974.1 βœ…
    Verify the installation by run "D:\software\CARLA_0.9.13\WindowsNoEditor\CarlaUE4.exe".
    You are supposed to see the following window.

    Install scenario_runner 0.9.13

    cd D:\software\CARLA_0.9.13\WindowsNoEditor\PythonAPI
    git clone --branch v0.9.13 --depth 1 https://github.com/carla-simulator/scenario_runner.git
    conda create -n arf_py375 python=3.7.5   
    conda activate arf_py375  
    cd scenario_runner
    pip install -r requirements.txt βœ…
    cd D:\github\Stanford-AutonomousRiskFramework.jl\CARLAIntegration\adversarial_carla_env
    pip install -r requirements.txt βœ…

    Modify the setup.py as the code below.

    from setuptools import setup, find_packages  
    setup(name='adv_carla',
        version='0.0.1',
        packages=find_packages(include=['adv_carla', 'adv_carla.*']),   ## added by nov05
        install_requires=['gym']) # TODO: other reqs.
    pip install -e .  βœ… Install adv-carla-v0 gym environment
    pip install wandb
    

    Add system variables in Windows.

    CARLA_ROOT = D:\software\CARLA_0.9.13
    SCENARIO_RUNNER_ROOT = %CARLA_ROOT%\PythonAPI\scenario_runner
    PYTHONPATH (append) := ;%CARLA_ROOT%\PythonAPI\carla\agents;%CARLA_ROOT%\PythonAPI\carla;%CARLA_ROOT%\PythonAPI
    

    Add the following line to D:\software\julia-1.11.5-win64\julia-1.11.5\etc\julia\startup.jl

    # This file should contain site-specific commands to be executed on Julia startup;
    # Users may store their own personal commands in `~/.julia/config/startup.jl`.
    ENV["PYTHON"] = "D:/Users/guido/miniconda3/envs/arf_py375/python.exe"

    Restart PowerShell terminal

    cd D:\github\Stanford-AA228VProjects\project_final
    conda activate arf_py375
    julia
    julia> import Pkg; Pkg.activate(@__DIR__)  
    julia> Pkg.build("PyCall") βœ…
    julia> using PyCall; PyCall.python
        "D:/Users/guido/miniconda3/envs/arf_py375/python.exe"
    julia> pyimport("adv_carla")
        PyObject <module 'adv_carla' from 'd:\\github\\stanford-autonomousriskframework.jl\\carlaintegration\\adversarial_carla_env\\adv_carla\\__init__.py'>
    julia> pyimport("wandb")
        PyObject <module 'wandb' from 'D:\\Users\\guido\\miniconda3\\envs\\arf_py375\\lib\\site-packages\\wandb\\__init__.py'>
    
  • Install the Autonomous Risk Framework package. Check the result.

cd D:\github\Stanford-AutonomousRiskFramework.jl ❌
julia install.jl ❌ This would install all the pacakges in the Julia v1.11 environment.   
cd D:\github\Stanford-AA228VProjects\project_final
julia
julia> Pkg.activate("D:\\github\\Stanford-AutonomousRiskFramework.jl") ❌
julia> cd("D:/github/Stanford-AA228VProjects/project_final")
julia> import Pkg; Pkg.activate(@__DIR__) βœ… This would create Project.toml and Manifest.toml in this dir.  
julia> import Pkg; Pkg.upgrade_manifest()
     Updated Format of manifest file at `D:\github\Stanford-AA228VProjects\project_final\Manifest.toml` updated from v1.0 to v2.0
julia> include("D:/github/Stanford-AutonomousRiskFramework.jl/install.jl")

  • Rebuild
import Pkg
Pkg.instantiate() 
Pkg.precompile()
Pkg.status()
@nov05
Copy link
Copy Markdown
Author

nov05 commented Jun 1, 2025

βœ… No errors, with question marks.

julia> import Pkg

julia> Pkg.precompile()
Precompiling project...
  ? RiskSimulator
  ? ScenarioSelection
  ? AutonomousRiskFramework

julia> Pkg.status()
Status `D:\github\Stanford-AA228VProjects\project_final\Project.toml`
  [d250a79e] AVExperiments v0.1.0 `D:\github\Stanford-AutonomousRiskFramework.jl\AVExperiments.jl`
  [0f7eb3e9] AdversarialDriving v0.1.0 `D:\Users\guido\.julia\dev\AdversarialDriving`
  [f30adb48] AutonomousRiskFramework v0.1.0 `D:\github\Stanford-AutonomousRiskFramework.jl`
  [fbb218c0] BSON v0.3.9
  [e51cc422] Crux v0.1.2 `D:\Users\guido\.julia\dev\Crux`
  [e3df1716] D3Trees v0.3.3
  [31c24e10] Distributions v0.25.120
βŒƒ [587475ba] Flux v0.14.25
  [0d2f0bec] ImportanceWeightedRiskMetrics v0.1.0 `D:\Users\guido\.julia\dev\ImportanceWeightedRiskMetrics`
  [5903a43b] Infiltrator v1.9.1
  [7d69903b] IntelligentDriving v0.1.0 `D:\github\Stanford-AutonomousRiskFramework.jl\IntelligentDriving.jl`
  [e12ccd36] MCTS v0.5.6
  [36e58220] ObservationModels v0.1.0 `D:\github\Stanford-AutonomousRiskFramework.jl\ObservationModels.jl`
  [bac558e1] OrderedCollections v1.8.1
  [23110f14] POMDPGym v0.1.0 `D:\Users\guido\.julia\dev\POMDPGym`
  [08074719] POMDPModelTools v0.3.13
  [182e52fb] POMDPPolicies v0.4.3
  [e0d0a172] POMDPSimulators v0.3.14
  [6fc570d8] POMDPStressTesting v1.0.2 `D:\Users\guido\.julia\dev\POMDPStressTesting`
βŒ… [a93abf59] POMDPs v0.9.6
  [d96e819e] Parameters v0.12.3
  [92933f4c] ProgressMeter v1.10.4
  [438e738f] PyCall v1.96.4
  [d80ce8e1] RiskSimulator v0.1.0 `D:\github\Stanford-AutonomousRiskFramework.jl\RiskSimulator.jl`
  [6ababdf7] STLCG v0.1.0 `D:\github\Stanford-AutonomousRiskFramework.jl\STLCG.jl`
  [3cd2cbe0] ScenarioSelection v0.1.0 `D:\github\Stanford-AutonomousRiskFramework.jl\ScenarioSelection.jl`
  [2746dd70] SpAutoDiff v0.1.0 `D:\Users\guido\.julia\dev\SpAutoDiff`
  [07d9af09] TreeImportanceSampling v0.1.0 `D:\Users\guido\.julia\dev\TreeImportanceSampling`
  [44eeaf0b] Vec v2.0.2 `D:\Users\guido\.julia\dev\Vec`
  [02a925ec] cuDNN v1.4.3
Info Packages marked with βŒƒ and βŒ… have new versions available. Those with βŒƒ may be upgradable, but those with βŒ… are restricted by compatibility constraints from upgrading. To see why use `status --outdated`

@nov05
Copy link
Copy Markdown
Author

nov05 commented Jun 1, 2025

βœ… code change

  • D:\github\Stanford-AutonomousRiskFramework.jl\AVExperiments.jl\src\AVExperiments.jl
    ## Changed by Nov05
    ## https://github.com/shubhg1996/TreeImportanceSampling.jl/commit/b1f6034ec914c60f033445c5ed15c0f272cef247
    function new_planner()
        tree_mdp = TreeMDP(rmdp, 1.0, [], [], disturbance, "sum")
        # c = 0.0 # exploration bonus (NOTE: keep at 0)
        # Ξ± = rmdp.Ξ± # VaR/CVaR risk parameter
        # return TreeImportanceSampling.mcts_isdpw(tree_mdp; N, c, Ξ±)
        params = TreeImportanceSampling.TreeISParams(1.0, 0.1, 0.0, 0.0, typemax(Int), 0.0)
        TreeImportanceSampling.mcts_isdpw(tree_mdp, params; N=10)
    end
  • Git history

shubhg1996/TreeImportanceSampling.jl@b1f6034

@nov05
Copy link
Copy Markdown
Author

nov05 commented Jun 1, 2025

⚠️ Issue: redefining of function causes precompile errors.

  • D:\github\Stanford-AutonomousRiskFramework.jl\RiskSimulator.jl\src\scenarios\merging_roadway.jl redefine a function
function AutomotiveSimulator.propagate(veh::Entity{BlinkerState, D, I}, action::BlinkerVehicleControl, roadway::Roadway, Ξ”t::Float64) where {D,I}
    starting_lane = laneid(vs)
    # @assert starting_lane == laneid(bs) # TODO: Merge into master.

In the package D:\Users\guido\.julia\dev\AdversarialDriving\src\driving_models.jl

function AutomotiveSimulator.propagate(veh::Entity{BlinkerState, D, I}, action::BlinkerVehicleControl, roadway::Roadway, Ξ”t::Float64) where {D,I}
    starting_lane = laneid(vs)
    @assert starting_lane == laneid(bs)

Find the repo from D:\github\Stanford-AutonomousRiskFramework.jl\install.jl

packages = [
    # [deps] ObservationModel.jl
    PackageSpec(url="https://github.com/sisl/AdversarialDriving.jl"),
    PackageSpec(url="https://github.com/sisl/Vec.jl"),

@nov05
Copy link
Copy Markdown
Author

nov05 commented Jun 1, 2025

🟒 The change is no longer needed for Project.toml and Manifest.toml have been copied to the installation folder.

βœ… code change

function AutomotiveSimulator.propagate(veh::Entity{BlinkerState, D, I}, action::BlinkerVehicleControl, roadway::Roadway, Ξ”t::Float64) where {D,I}
    # starting_lane = laneid(vs)  ## nov05
    # @assert starting_lane == laneid(bs)  ## nov05
  • commented out the redefinition of the function AutomotiveSimulator.propagate().

  • generate UUID for the fork: b0df4e1a-129a-4f30-854a-a9672dfa1df1 in the Project.toml

julia> using Pkg.TOML
julia> Pkg.TOML.parsefile("D:\\github\\Stanford-AdversarialDriving.jl\\Project.toml")
Dict{String, Any} with 5 entries:
  "deps"    => Dict{String, Any}("POMDPModelTools"=>"08074719-1b2a-587c-a292-00f91cc44415", "Distributions"=>"31c24e10-a181-5473-b8eb-79…
  "name"    => "AdversarialDriving"
  "uuid"    => "0f7eb3e9-d51f-47f4-b915-6157e1c8ce29"
  "authors" => ["Anthony Corso <anthonycorso92@gmail.com>"]
  "version" => "0.1.0"
julia> using UUIDs; uuid4()
  • change D:\github\Stanford-AutonomousRiskFramework.jl\install.jl
packages = [
    # [deps] ObservationModel.jl
    # PackageSpec(url="https://github.com/sisl/AdversarialDriving.jl"),  ## removed by nov05
    PackageSpec(url="https://github.com/nov05/Stanford-AdversarialDriving.jl"),  ## added by nov05
...
]
  • rebuild
julia> cd("D:/github/Stanford-AA228VProjects/project_final")
julia> import Pkg; Pkg.activate(@__DIR__)
julia> Pkg.rm("AdversarialDriving")
julia> rm("D:\\Users\\guido\\.julia\\dev\\AdversarialDriving"; force=true, recursive=true)
julia> rm("D:\\Users\\guido\\.julia\\packages\\AdversarialDriving"; force=true, recursive=true)
julia> include("D:/github/Stanford-AutonomousRiskFramework.jl/install.jl")
julia> using AdversarialDriving

@nov05
Copy link
Copy Markdown
Author

nov05 commented Jun 2, 2025

🟒 Issue no longer exists for Project.toml and Manifest.toml have been copied to the installation folder.

packages = [
    PackageSpec(url="https://github.com/nov05/JuliaPOMDPSimulators.jl.git"),
...
]
  • rebuild
julia> Pkg.rm("POMDPSimulators")
    Updating `D:\github\Stanford-AA228VProjects\project_final\Project.toml`
  [e0d0a172] - POMDPSimulators v0.3.14
  No Changes to `D:\github\Stanford-AA228VProjects\project_final\Manifest.toml`

julia> Pkg.gc()  # garbage collect
      Active manifest files: 22 found
      Active artifact files: 209 found
      Active scratchspaces: 10 found
     Deleted no artifacts, repos, packages or scratchspaces

rm("D:\\Users\\guido\\.julia\\dev\\POMDPSimulators"; force=true, recursive=true)
rm("D:\\Users\\guido\\.julia\\packages\\POMDPSimulators"; force=true, recursive=true)

julia> include("D:/github/Stanford-AutonomousRiskFramework.jl/install.jl")
     Cloning git-repo `https://github.com/JuliaPOMDP/POMDPSimulators.jl.git`
   Resolving package versions...
   Installed BeliefUpdaters ─ v0.2.3
    Updating `D:\github\Stanford-AA228VProjects\project_final\Project.toml`
  [e0d0a172] + POMDPSimulators v0.3.13 `https://github.com/JuliaPOMDP/POMDPSimulators.jl.git#v0.3.13`
    Updating `D:\github\Stanford-AA228VProjects\project_final\Manifest.toml`
  [8bb6e9a1] + BeliefUpdaters v0.2.3
  [e0d0a172] ~ POMDPSimulators v0.3.14 β‡’ v0.3.13 `https://github.com/JuliaPOMDP/POMDPSimulators.jl.git#v0.3.13`

⚠️🟒 Issue solved: Deprecated package causes errors.

ulia> planner = setup_ast(sut=system, scenario=scenario)
[ Info: Training observation model.
ERROR: UndefVarError: `simulate` not defined in `POMDPSimulators`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name may be made accessible by importing AutomotiveSimulator in the current active module Main
Hint: a global variable of this name may be made accessible by importing POMDPs in the current active module Main
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name may be made accessible by importing AutomotiveSimulator in the current active module Main
Hint: a global variable of this name may be made accessible by importing POMDPs in the current active module Main
Stacktrace:
 [1] getproperty
   @ .\Base.jl:42 [inlined]
 [2] training_phase(simx::AutoRiskSim; seed::Int64, epochs::Int64)
   @ RiskSimulator D:\github\Stanford-AutonomousRiskFramework.jl\RiskSimulator.jl\src\training_phase.jl:11
 [3] training_phase
   @ D:\github\Stanford-AutonomousRiskFramework.jl\RiskSimulator.jl\src\training_phase.jl:1 [inlined]
 [4]
   @ RiskSimulator D:\github\Stanford-AutonomousRiskFramework.jl\RiskSimulator.jl\src\ast.jl:268
 [5] top-level scope
   @ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.

@nov05
Copy link
Copy Markdown
Author

nov05 commented Jun 3, 2025

⚠️

153 Base.run(queue::AbstractVector) = run(default_process, queue)

β”Œ AdversarialDriving
β”‚  WARNING: Method definition run(AbstractArray{T, 1} where T) in module Simulators at D:\Users\guido\.julia\packages\POMDPTools\7Rekv\src\Simulators\parallel.jl:153 overwritten in module POMDPSimulators at D:\Users\guido\.julia\packages\POMDPSimulators\zxTz3\src\parallel.jl:153.
β”‚  ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.
β””

ChatGPT

using POMDPSimulators  # or POMDPTools, whichever you're keeping

Base.@eval begin
    # Check if not already defined
    if !isdefined(Base, :run) || !hasmethod(Base.run, Tuple{AbstractVector})
        Base.run(queue::AbstractVector) = run(default_process, queue)
    end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment