Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elrichgro
Flatland
Commits
245c9cc2
Commit
245c9cc2
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
At switches now conflicts are only detected if agent has option to choose head on colliding path
parent
2d2dd61d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/core/env_observation_builder.py
+1
-0
1 addition, 0 deletions
flatland/core/env_observation_builder.py
flatland/envs/observations.py
+12
-4
12 additions, 4 deletions
flatland/envs/observations.py
with
13 additions
and
4 deletions
flatland/core/env_observation_builder.py
+
1
−
0
View file @
245c9cc2
...
...
@@ -74,6 +74,7 @@ class ObservationBuilder:
direction
[
agent
.
direction
]
=
1
return
direction
class
DummyObservationBuilder
(
ObservationBuilder
):
"""
DummyObservationBuilder class which returns dummy observations
...
...
This diff is collapsed.
Click to expand it.
flatland/envs/observations.py
+
12
−
4
View file @
245c9cc2
...
...
@@ -270,6 +270,7 @@ class TreeObsForRailEnv(ObservationBuilder):
observation
=
[
0
,
0
,
0
,
0
,
0
,
0
,
self
.
distance_map
[(
handle
,
*
agent
.
position
,
agent
.
direction
)],
0
,
0
]
visited
=
set
()
# Start from the current orientation, and see which transitions are available;
# organize them as [left, forward, right, back], relative to the current orientation
# If only one transition is possible, the tree is oriented with this transition as the forward branch.
...
...
@@ -289,6 +290,7 @@ class TreeObsForRailEnv(ObservationBuilder):
# add cells filled with infinity if no transition is possible
observation
=
observation
+
[
-
np
.
inf
]
*
self
.
_num_cells_to_fill_in
(
self
.
max_depth
)
self
.
env
.
dev_obs_dict
[
handle
]
=
visited
return
observation
def
_num_cells_to_fill_in
(
self
,
remaining_depth
):
...
...
@@ -362,11 +364,12 @@ class TreeObsForRailEnv(ObservationBuilder):
pre_step
=
max
(
0
,
tot_dist
-
1
)
post_step
=
min
(
self
.
max_prediction_depth
-
1
,
tot_dist
+
1
)
# Look for conflicting paths at distance
num_step
# Look for conflicting paths at distance
tot_dist
if
int_position
in
np
.
delete
(
self
.
predicted_pos
[
tot_dist
],
handle
,
0
):
conflicting_agent
=
np
.
where
(
self
.
predicted_pos
[
tot_dist
]
==
int_position
)
for
ca
in
conflicting_agent
[
0
]:
if
direction
!=
self
.
predicted_dir
[
tot_dist
][
ca
]
and
tot_dist
<
potential_conflict
:
if
direction
!=
self
.
predicted_dir
[
tot_dist
][
ca
]
and
cell_transitions
[
self
.
_reverse_dir
(
self
.
predicted_dir
[
tot_dist
][
ca
])]
==
1
and
tot_dist
<
potential_conflict
:
potential_conflict
=
tot_dist
if
self
.
env
.
dones
[
ca
]
and
tot_dist
<
potential_conflict
:
potential_conflict
=
tot_dist
...
...
@@ -375,7 +378,8 @@ class TreeObsForRailEnv(ObservationBuilder):
elif
int_position
in
np
.
delete
(
self
.
predicted_pos
[
pre_step
],
handle
,
0
):
conflicting_agent
=
np
.
where
(
self
.
predicted_pos
[
pre_step
]
==
int_position
)
for
ca
in
conflicting_agent
[
0
]:
if
direction
!=
self
.
predicted_dir
[
pre_step
][
ca
]
and
tot_dist
<
potential_conflict
:
if
direction
!=
self
.
predicted_dir
[
pre_step
][
ca
]
and
cell_transitions
[
self
.
_reverse_dir
(
self
.
predicted_dir
[
pre_step
][
ca
])]
==
1
and
tot_dist
<
potential_conflict
:
potential_conflict
=
tot_dist
if
self
.
env
.
dones
[
ca
]
and
tot_dist
<
potential_conflict
:
potential_conflict
=
tot_dist
...
...
@@ -384,7 +388,8 @@ class TreeObsForRailEnv(ObservationBuilder):
elif
int_position
in
np
.
delete
(
self
.
predicted_pos
[
post_step
],
handle
,
0
):
conflicting_agent
=
np
.
where
(
self
.
predicted_pos
[
post_step
]
==
int_position
)
for
ca
in
conflicting_agent
[
0
]:
if
direction
!=
self
.
predicted_dir
[
post_step
][
ca
]
and
tot_dist
<
potential_conflict
:
if
direction
!=
self
.
predicted_dir
[
post_step
][
ca
]
and
cell_transitions
[
self
.
_reverse_dir
(
self
.
predicted_dir
[
post_step
][
ca
])]
==
1
and
tot_dist
<
potential_conflict
:
potential_conflict
=
tot_dist
if
self
.
env
.
dones
[
ca
]
and
tot_dist
<
potential_conflict
:
potential_conflict
=
tot_dist
...
...
@@ -566,6 +571,9 @@ class TreeObsForRailEnv(ObservationBuilder):
if
self
.
predictor
:
self
.
predictor
.
_set_env
(
self
.
env
)
def
_reverse_dir
(
self
,
direction
):
return
int
((
direction
+
2
)
%
4
)
class
GlobalObsForRailEnv
(
ObservationBuilder
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment