Skip to content

Farm Actors#

Put other actors on the farm. Add cars on the highway, farm vehicles and workers. Add scripted persons, trucks, tractors and cars on the path of your vehicle. The game and ACRES Core run the same actor scripts.

Before you start

Select the Actors#

Actors Where How Use
Farm traffic and workers The game -NpcTraffic=, -NpcVehicles, -NpcWorkers A living farm in the background
Objects on the path The game, ACRES Core, acres_simulator A scenario: -PathObjects= or Skills.set_scenario Repeatable tests of the vehicle software
Single objects ACRES Core Batch.set_objects Your own tests in Python

Add Farm Traffic and Workers#

Packaged/Linux/Acres.sh -VehicleDemo -Vehicle=polaris -NpcVehicles -NpcWorkers

Expected result

ACRES_NPC_TRAFFIC cars=16 models=9 road_m=1536
ACRES_NPC_READY road_nodes=2684 spots=34 empty_fields=4 service=4 npcs=36
Option Function
-NpcTraffic=<n> n cars on the highway US 52, 0 to 200
-NpcVehicles Pickups on the farm roads and tractors in the fields. Also 16 highway cars.
-NpcWorkers Workers who walk on the farm

The farm vehicles drive from parking spots to fields and back. A worker gives way to a vehicle. The Farm Traffic and Workers page explains the behaviour.

One or the other

A session with a scenario file (-PathObjects=) has no farm traffic. The scenario actors then are the only moving actors, thus each run is repeatable.

Put Actors on the Path#

A scenario is a list of actors with scripts, placed along the route of a mission. A seed gives the same actors each time.

Pattern What the Actor Does
static Stands on the path for the full episode
temporary Stands on the path, then moves to the side after the vehicle comes near
crossing Goes across the path at a right angle
along Moves along the path, in the direction of the vehicle or against it
walk A person walks along the lane
stand A person goes onto the lane, stands, then goes on
emerge A person comes out from behind a parked machine
headland A tractor makes its headland turn across the lane
back_out A truck backs out of a yard
lead A vehicle drives in front of your vehicle at a lower speed
pull_out A parked vehicle starts to move onto the lane

The kinds are person, truck, tractor and car. The configuration Learning/acres_learn/configs/path_objects_v1.json gives the distances, the speeds and the kinds of each pattern.

  1. Write the script actors.py.

    actors.py
    """A static actor on the route to F56: the shield stops the vehicle, and the skill ends "blocked"."""
    import acres_simulator as acres
    from acres_simulator import plans, scenarios
    
    route = plans.route("F56")
    scenario = scenarios.generate(route, ["static"], seed=3, mission="single-F56", count=1)
    for actor in scenario["objects"]:
        print("actor:", actor["kind"], actor["scenario"], f"at x {actor['x']:.1f}, y {actor['y']:.1f}")
    scenarios.save(scenario, "actor_f56.json")              # the same file is a scenario of the game: -PathObjects=
    
    world = acres.Core(num_envs=1, threads=2)
    skills = acres.Skills(world, agent=0)
    skills.set_scenario(scenario)
    result = skills.scout("F56")
    holds = [e for e in skills.events() if e["type"] == "shield_hold"]
    print(len(holds), "shield holds")
    print(result.code, "-", result.cause)
    if result.code == "blocked":
        print("held by", result.counterexample["rules"], f"at {result.counterexample['obstacle_m']:.1f} m from the actor")
    
  2. Run the script.

    python actors.py
    

    Expected result

    The seed puts a standing person on the scout loop of F56. The shield stops the vehicle 2.7 m before the person. After 10 s of hold, the skill ends with blocked.

    actor: person static at x 226.9, y -125.3
    1 shield holds
    blocked - the shield held the vehicle at a stop for 10 s (obstacle)
    held by ['obstacle'] at 2.7 m from the actor
    
  3. Show the same scenario in the game.

    Packaged/Linux/Acres.sh -VehicleDemo -Vehicle=polaris -PathObjects=$PWD/actor_f56.json
    

    Expected result

    ACRES_NPC off: the run has a scenario file (-PathObjects=)
    ACRES_PATH_OBJECTS loaded=1 file=actor_f56.json
    

No actor moves into the vehicle. An actor stops when its next motion brings it within 1 m of the vehicle. Thus a contact always comes from the motion of the vehicle. A planner that drives past an actor must keep the distance. The Harness gives a planner the tools to wait, pass or reroute.

Next Steps#