Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
navipy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
Olivier Bertrand
navipy
Commits
46d0221b
Commit
46d0221b
authored
7 years ago
by
Olivier Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Correct PEP8
parent
3e0cae2a
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/source/tutorials.rst
+8
-1
8 additions, 1 deletion
doc/source/tutorials.rst
navipy/__init__.py
+5
-4
5 additions, 4 deletions
navipy/__init__.py
navipy/moving/agent.py
+2
-4
2 additions, 4 deletions
navipy/moving/agent.py
navipy/moving/test_agent.py
+5
-3
5 additions, 3 deletions
navipy/moving/test_agent.py
with
20 additions
and
12 deletions
doc/source/tutorials.rst
+
8
−
1
View file @
46d0221b
...
@@ -66,7 +66,14 @@ In close loop
...
@@ -66,7 +66,14 @@ In close loop
Catchment area of ASV
Catchment area of ASV
---------------------
---------------------
To calculate the catchment area of homing method for a given goal location, \
the agent should be displaced multiple time at different location, and obsverve \
if the agent returned home or not. If it did, then the point in space from which the \
agent started its return trip is part of the catchment area.
When the agent is restricted to move a grid, and its motion at a given place, only \
depends on the current surrounding, then to calculate a catchment area one only to \
build a graph of motion and check how many points converge to it.
Comparing modalities
Comparing modalities
--------------------
--------------------
...
...
This diff is collapsed.
Click to expand it.
navipy/__init__.py
+
5
−
4
View file @
46d0221b
"""
"""
Every agent comes with a brain processing the about of
\
Every agent comes with a brain processing the about of
\
senses or sensors for biological or technical agent, respectively.
senses or sensors for biological or technical agent, respectively.
The senses of agents in navipy are limited
The senses of agents in navipy are limited
to:
to:
...
@@ -23,8 +23,8 @@ Then the brain can be updated at a new position orientation:
...
@@ -23,8 +23,8 @@ Then the brain can be updated at a new position orientation:
Building your own brain
Building your own brain
-----------------------
-----------------------
The Brain class is an abstract Brain, such that it can not control an agent.
To control,
\
The Brain class is an abstract Brain, such that it can not control an agent.
\
an agent, the Brain should have a function called velocity.
To control,
an agent, the Brain should have a function called velocity.
For example, an stationary agent should always return a null velocity.
For example, an stationary agent should always return a null velocity.
...
@@ -39,6 +39,7 @@ An agent using an average skyline homing vector, could be build as follow
...
@@ -39,6 +39,7 @@ An agent using an average skyline homing vector, could be build as follow
"""
"""
from
navipy.database
import
DataBaseLoad
from
navipy.database
import
DataBaseLoad
class
Bunch
:
class
Bunch
:
def
__init__
(
self
,
**
kwds
):
def
__init__
(
self
,
**
kwds
):
self
.
__dict__
.
update
(
kwds
)
self
.
__dict__
.
update
(
kwds
)
...
@@ -69,5 +70,5 @@ class Brain():
...
@@ -69,5 +70,5 @@ class Brain():
if
isinstance
(
self
.
renderer
,
DataBaseLoad
):
if
isinstance
(
self
.
renderer
,
DataBaseLoad
):
return
self
.
renderer
.
posorients
return
self
.
renderer
.
posorients
else
:
else
:
raise
NotImplementedError
(
"
Subclasses should implement this,
"
+
raise
NotImplementedError
(
"
Subclasses should implement this,
"
+
"
when renderer is not DataBaseLoad
"
)
"
when renderer is not DataBaseLoad
"
)
This diff is collapsed.
Click to expand it.
navipy/moving/agent.py
+
2
−
4
View file @
46d0221b
...
@@ -16,9 +16,7 @@ import networkx as nx
...
@@ -16,9 +16,7 @@ import networkx as nx
import
multiprocessing
import
multiprocessing
from
multiprocessing
import
Queue
,
JoinableQueue
,
Process
from
multiprocessing
import
Queue
,
JoinableQueue
,
Process
import
inspect
import
inspect
from
navipy.database
import
DataBaseLoad
import
navipy.moving.maths
as
navimomath
import
navipy.moving.maths
as
navimomath
from
navipy
import
Brain
version
=
float
(
nx
.
__version__
)
version
=
float
(
nx
.
__version__
)
...
@@ -160,7 +158,7 @@ GridAgent is a close loop agent here its position is snap to a grid.
...
@@ -160,7 +158,7 @@ GridAgent is a close loop agent here its position is snap to a grid.
self
.
brain
=
brain
self
.
brain
=
brain
self
.
_posorients_queue
=
posorients_queue
self
.
_posorients_queue
=
posorients_queue
self
.
_results_queue
=
results_queue
self
.
_results_queue
=
results_queue
@property
@property
def
mode_of_motion
(
self
):
def
mode_of_motion
(
self
):
"""
"""
...
@@ -294,7 +292,7 @@ the agent motion, or
...
@@ -294,7 +292,7 @@ the agent motion, or
results_queue
=
results_queue
)
results_queue
=
results_queue
)
for
_
in
range
(
num_agents
)]
for
_
in
range
(
num_agents
)]
for
w
in
agents
:
for
w
in
agents
:
w
.
mode_of_motion
=
self
.
mode_of_motion
w
.
mode_of_motion
=
self
.
mode_of_motion
w
.
start
()
w
.
start
()
# Add a poison pill for each agent
# Add a poison pill for each agent
...
...
This diff is collapsed.
Click to expand it.
navipy/moving/test_agent.py
+
5
−
3
View file @
46d0221b
...
@@ -16,15 +16,16 @@ version = float(nx.__version__)
...
@@ -16,15 +16,16 @@ version = float(nx.__version__)
class
BrainTest
(
Brain
):
class
BrainTest
(
Brain
):
def
__init__
(
self
,
renderer
=
None
):
def
__init__
(
self
,
renderer
=
None
):
Brain
.
__init__
(
self
,
renderer
=
renderer
)
Brain
.
__init__
(
self
,
renderer
=
renderer
)
self
.
__posorient_col
=
[
'
x
'
,
'
y
'
,
'
z
'
,
self
.
__posorient_col
=
[
'
x
'
,
'
y
'
,
'
z
'
,
'
alpha_0
'
,
'
alpha_1
'
,
'
alpha_2
'
]
'
alpha_0
'
,
'
alpha_1
'
,
'
alpha_2
'
]
self
.
__velocity_col
=
[
'
d
'
+
col
for
col
in
self
.
__posorient_col
]
self
.
__velocity_col
=
[
'
d
'
+
col
for
col
in
self
.
__posorient_col
]
self
.
__posorient_vel_col
=
self
.
__posorient_col
self
.
__posorient_vel_col
=
self
.
__posorient_col
self
.
__posorient_vel_col
.
extend
(
self
.
__velocity_col
)
self
.
__posorient_vel_col
.
extend
(
self
.
__velocity_col
)
def
velocity
(
self
):
def
velocity
(
self
):
return
pd
.
Series
(
data
=
0
,
index
=
self
.
__posorient_vel_col
)
return
pd
.
Series
(
data
=
0
,
index
=
self
.
__posorient_vel_col
)
class
TestNavipyMovingAgent
(
unittest
.
TestCase
):
class
TestNavipyMovingAgent
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -40,6 +41,7 @@ class TestNavipyMovingAgent(unittest.TestCase):
...
@@ -40,6 +41,7 @@ class TestNavipyMovingAgent(unittest.TestCase):
#
#
# AbstractAgent
# AbstractAgent
#
#
def
test_move_abstractagent
(
self
):
def
test_move_abstractagent
(
self
):
agent
=
naviagent
.
AbstractAgent
()
agent
=
naviagent
.
AbstractAgent
()
with
self
.
assertRaises
(
NameError
):
with
self
.
assertRaises
(
NameError
):
...
...
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