VariaSimDeveloper guide

Simulation for autonomous vehicles

Test model changes on thousands of cases like double cut-ins, sudden slowdowns, lane changes and signalized turns.

Vary traffic speeds, gaps and maneuver timing. Run both planner revisions on the same seeds to see which collisions your change prevents and which it introduces.

Illustration of driving paths sweeping together before branching in two directions

Simulation throughput

Actor updates per CPU second
≈1 million

About one microsecond per actor per tick from 50 to 200 actors.

CPU time per actor per tick
  • 50 actors0.89 µs
  • 100 actors0.97 µs
  • 200 actors1.00 µs
100 Hz benchmark
Simulated time per engine CPU second
≈92 seconds

Measured with the built-in driver. Model inference adds to the run time. Traffic benchmark

Find gaps in model coverage

Which gaps give your planner trouble? This sweep groups 40 lane changes by direction and requested rear gap. Select a bin to see the collisions, then use those cases to test the next revision.

Lane-change direction × requested rear gap
Side0–2 m2–4 m4–6 m6–8 m

● Run   × Collision

Search command

Start from the scenario library

Choose a test derived from Euro NCAP protocols, UN Regulations 152 and 157, or NHTSA’s pre-crash scenarios.

For a multi-actor test, try the double cut-in. Two cars merge into the same gap from opposite sides. Vary their arrival times to test which threat your planner responds to first.

Download double_cut_in.osc
Two slower cars merge from opposite sides ahead of the ego vehicle. The car on the right enters closer to ego. egonear · 1.2 sfar · 2.8 s
Double cut-in · time to collision at merge onset Write a scenario →

ODD profiles

Run a scenario on a synthetic map or import a real road from OpenStreetMap. To test a U.S. road, choose the section by bounding box. The U.S. interstate profile filters candidate lanes by road class, lane width and posted speed before the scenario runs.

On a 2.5D map, vehicles on an overpass stay on their own deck as traffic passes underneath. Watch the crossing

Import a road section

Drive a figure-eight overpass

Cherry takes the inside lane and turns left. At 18.42 seconds it passes beneath the ego car with 6 m of clearance between road surfaces. The ego car then stops at red, turns right onto the side street, and circles back through the junction.

Select a car to follow it through the junction. At 43 seconds, compare its yaw rate with the estimated steering angle. The Y vector measures motion along the ego car’s left axis.

Replay command

Download the run bundle below. From its directory, generate an offline report and open replay.html.

Shell
variasim view stacked_crossing.bundle.json -o replay.html

Put your planner in the loop

Keep your model in your simulator. Each tick, VariaSim sends the surrounding traffic states. Your simulator runs the driving policy and returns the ego vehicle’s new state. Save a failing seed alongside the model revision so you can rerun it after a change.

Python integration example

When a case fails to fit

Interval constraint propagation and seeded search test each instance against the map. A double cut-in on the built-in urban street returns E315.

no driving lane with a left neighbour and a right neighbour

Implausible draws can be filtered with a warning. Scenarios that deliberately model a collision can declare avoid_collisions(false).

Native builds for Linux and macOS

Use the C++17 engine from the Python API or CLI. Choose a platform wheel for your operating system and processor.

Run with the native engine
Linux
x86-64 · ARM64
Ubuntu 18.10+ · Debian 10+
RHEL 8+ · Fedora 29+
macOS
Apple silicon
macOS 11+ · ARM64

Start with one seed

Run the braking scenario on the built-in highway. Inspect the speed trace, then sweep the starting speed and gap to test where your model’s response changes.