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
Model registry
Operate
Environments
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
pranjal_dhole
Flatland
Commits
f74f3463
Commit
f74f3463
authored
2 years ago
by
adrian_egli2
Browse files
Options
Downloads
Patches
Plain Diff
Notebook is working (Flatland3)
parent
81233c6d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/test-collision.ipynb
+48
-13
48 additions, 13 deletions
notebooks/test-collision.ipynb
with
48 additions
and
13 deletions
notebooks/test-collision.ipynb
+
48
−
13
View file @
f74f3463
...
...
@@ -10,9 +10,22 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
1
,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<style>.container { width:95% !important; }</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
...
...
@@ -22,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
2
,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -34,13 +47,12 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
3
,
"metadata": {},
"outputs": [],
"source": [
"from flatland.envs import malfunction_generators as malgen\n",
"from flatland.envs.agent_utils import EnvAgent\n",
"#from flatland.envs import sparse_rail_gen as spgen\n",
"from flatland.envs import rail_generators as rail_gen\n",
"from flatland.envs import agent_chains as ac\n",
"from flatland.envs.rail_env import RailEnv, RailEnvActions\n",
...
...
@@ -52,11 +64,26 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
4
,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6d0c393e0bae47d1ba5ee4843c0f0604",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(height=300, width=600)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"env, envModel = eeu.makeTestEnv(\"concentric_loops\", nAg=2,
bUCF
=True)\n",
"env, envModel = eeu.makeTestEnv(\"concentric_loops\", nAg=2,
remove_agents_at_target
=True)\n",
"behaviour = ju.ForwardWithPause(env, [ju.AgentPause(0, 12, 5)])\n",
"oEC = ju.EnvCanvas(env, behaviour)\n",
"env.reset(regenerate_rail=False)\n",
...
...
@@ -69,12 +96,20 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
6
,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Expected: {0: (8, 6, 3), 1: (8, 7, 3)}\n",
"Actual: {0: (8, 6, 3), 1: (8, 7, 3)}\n"
]
}
],
"source": [
"dAgStateExpected = {0: (8, 5, 3), 1: (8, 6, 3)} \n",
"# {0: (7, 15, 2), 1: (6, 15, 2)}\n",
"dAgStateExpected = {0: (8, 6, 3), 1: (8, 7, 3)} \n",
"\n",
"dAgState={}\n",
"for iAg, ag in enumerate(env.agents):\n",
...
...
@@ -102,7 +137,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
7
"
"version": "3.6.
8
"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
...
...
%% Cell type:markdown id: tags:
# Test Collisions
A visual test of a "rear-shunt" collision, to ensure that the agent does not get marked as collided permananently.
%% Cell type:code id: tags:
```
python
%
load_ext
autoreload
%
autoreload
2
from
IPython.core
import
display
display
.
display
(
display
.
HTML
(
"
<style>.container { width:95% !important; }</style>
"
))
```
%% Output
%% Cell type:code id: tags:
```
python
import
PIL
from
IPython
import
display
from
ipycanvas
import
canvas
import
time
```
%% Cell type:code id: tags:
```
python
from
flatland.envs
import
malfunction_generators
as
malgen
from
flatland.envs.agent_utils
import
EnvAgent
#from flatland.envs import sparse_rail_gen as spgen
from
flatland.envs
import
rail_generators
as
rail_gen
from
flatland.envs
import
agent_chains
as
ac
from
flatland.envs.rail_env
import
RailEnv
,
RailEnvActions
from
flatland.envs.persistence
import
RailEnvPersister
from
flatland.utils.rendertools
import
RenderTool
from
flatland.utils
import
env_edit_utils
as
eeu
from
flatland.utils
import
jupyter_utils
as
ju
```
%% Cell type:code id: tags:
```
python
env
,
envModel
=
eeu
.
makeTestEnv
(
"
concentric_loops
"
,
nAg
=
2
,
bUCF
=
True
)
env
,
envModel
=
eeu
.
makeTestEnv
(
"
concentric_loops
"
,
nAg
=
2
,
remove_agents_at_target
=
True
)
behaviour
=
ju
.
ForwardWithPause
(
env
,
[
ju
.
AgentPause
(
0
,
12
,
5
)])
oEC
=
ju
.
EnvCanvas
(
env
,
behaviour
)
env
.
reset
(
regenerate_rail
=
False
)
oEC
.
show
()
for
i
in
range
(
25
):
oEC
.
step
()
oEC
.
render
()
time
.
sleep
(
0.1
)
```
%% Output
%% Cell type:code id: tags:
```
python
dAgStateExpected
=
{
0
:
(
8
,
5
,
3
),
1
:
(
8
,
6
,
3
)}
# {0: (7, 15, 2), 1: (6, 15, 2)}
dAgStateExpected
=
{
0
:
(
8
,
6
,
3
),
1
:
(
8
,
7
,
3
)}
dAgState
=
{}
for
iAg
,
ag
in
enumerate
(
env
.
agents
):
dAgState
[
iAg
]
=
(
*
ag
.
position
,
ag
.
direction
)
print
(
"
Expected:
"
,
dAgStateExpected
)
print
(
"
Actual:
"
,
dAgState
)
assert
dAgState
==
dAgStateExpected
```
%% Output
Expected: {0: (8, 6, 3), 1: (8, 7, 3)}
Actual: {0: (8, 6, 3), 1: (8, 7, 3)}
...
...
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