-
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
1 parent
e79b24b
commit c1ac9a4
Showing
5 changed files
with
63 additions
and
28 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"version": "1.0", | ||
"name": "default_map", | ||
"bounds": { | ||
"x_margin": [-100, 100], | ||
"y_margin": [-200, 200] | ||
}, | ||
"ped_routes": [ | ||
{ | ||
"name": "route_1", | ||
"waypoints": [ | ||
[0, 0], | ||
[0, 100], | ||
[100, 100], | ||
[100, 0], | ||
[0, 0] | ||
], | ||
"reversible": "true" | ||
} | ||
], | ||
"crowded_zones": [ | ||
{ | ||
"name": "zone_1", | ||
"zone_rect": [ | ||
[40, -40], | ||
[40, -20], | ||
[60, -20] | ||
] | ||
} | ||
], | ||
"obstacles": [ | ||
{ | ||
"name": "obstacle_1", | ||
"vertices": [ | ||
[20, 20], | ||
[20, 40], | ||
[40, 40], | ||
[40, 20] | ||
] | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import json | ||
from pysocialforce.map_config import \ | ||
MapDefinition, GlobalRoute, Obstacle | ||
|
||
|
||
def load_map(file_path: str) -> MapDefinition: | ||
"""Load map data from the given file path.""" | ||
|
||
with open(file_path, 'r') as file: | ||
map_json = json.load(file) | ||
|
||
obstacles = [Obstacle(o["vertices"]) for o in map_json['obstacles']] | ||
routes = [GlobalRoute(r['waypoints']) for r in map_json['ped_routes']] | ||
routes += [GlobalRoute(list(reversed(r['waypoints']))) | ||
for r in map_json['ped_routes'] if r["reversible"]] | ||
crowded_zones = [tuple(z["zone_rect"]) for z in map_json['crowded_zones']] | ||
|
||
return MapDefinition(obstacles, routes, crowded_zones) |