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
- For the game: package the game. Refer to Build the Game.
- For Python: set the environment of Use the Python API.
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#
Expected result
| 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.
-
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") -
Run the script.
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. -
Show the same scenario in the game.
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#
-
Scenarios with actors, with a planner that decides what to do.
-
How the shield finds the obstacle and stops the vehicle.
-
The behaviour of each actor.