-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
716 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Dummy examples created by @ll7 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
# Example 01: basic import test | ||
""" | ||
import pysocialforce as pysf | ||
|
||
|
||
simulator = pysf.Simulator_v2() | ||
|
||
for step in range(10): | ||
simulator.step() | ||
print(f"step {step}") | ||
print(simulator.states.ped_positions) | ||
print("=================") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
# Example 02: test the configuration of the simulator | ||
""" | ||
import pysocialforce as pysf | ||
|
||
obstacle01 = pysf.map_config.Obstacle( | ||
[(10, 10), (15,10), (15, 15), (10, 15)]) | ||
obstacle02 = pysf.map_config.Obstacle( | ||
[(20, 10), (25,10), (25, 15), (20, 15)]) | ||
|
||
route01 = pysf.map_config.GlobalRoute( | ||
[(0, 0), (10, 10), (20, 10), (30, 0)]) | ||
crowded_zone01 = ((10, 10), (20, 10), (20, 20)) | ||
|
||
map_def = pysf.map_config.MapDefinition( | ||
obstacles=[obstacle01, obstacle02], | ||
routes=[route01], | ||
crowded_zones=[crowded_zone01]) | ||
|
||
simulator = pysf.Simulator_v2(map_def) | ||
|
||
for step in range(10): | ||
simulator.step() | ||
print(f"step {step}") | ||
print(simulator.states.ped_positions) | ||
print("=================") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
# Example 03: simulate with visual rendering | ||
""" | ||
import pysocialforce as pysf | ||
import numpy as np | ||
|
||
obstacle01 = pysf.map_config.Obstacle( | ||
[(10, 10), (15,10), (15, 15), (10, 15)]) | ||
obstacle02 = pysf.map_config.Obstacle( | ||
[(20, 10), (25,10), (25, 15), (20, 15)]) | ||
|
||
route01 = pysf.map_config.GlobalRoute( | ||
[(0, 0), (10, 10), (20, 10), (30, 0)]) | ||
crowded_zone01 = ((10, 10), (20, 10), (20, 20)) | ||
|
||
map_def = pysf.map_config.MapDefinition( | ||
obstacles=[obstacle01, obstacle02], | ||
routes=[route01], | ||
crowded_zones=[crowded_zone01]) | ||
|
||
simulator = pysf.Simulator_v2(map_def) | ||
sim_view = pysf.SimulationView(obstacles=map_def.obstacles, scaling=10) | ||
sim_view.show() | ||
|
||
for step in range(10_000): | ||
simulator.step() | ||
ped_pos = np.array(simulator.states.ped_positions) | ||
ped_vel = np.array(simulator.states.ped_velocities) | ||
actions = np.concatenate(( | ||
np.expand_dims(ped_pos, axis=1), | ||
np.expand_dims(ped_pos + ped_vel, axis=1) | ||
), axis=1) | ||
state = pysf.sim_view.VisualizableSimState(step, ped_pos, actions) | ||
sim_view.render(state, fps=10) | ||
|
||
sim_view.exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.