School of Innovation Design and Engineering
V¨
aster˚
as, Sweden
Thesis for the Degree of Master of Science in Engineering - Robotics
30.0 credits
ADAPTIVE AUTONOMY WITH
UNRELIABLE COMMUNICATION
Ragnar Moberg
rmg11001@student.mdh.se
Examiner: Baran C¨
ur¨
ukl¨
u
M¨
alardalen University, V¨
aster˚
as, Sweden
Supervisor: Fredrik Ekstrand
Abstract
For underwater robotics there exists severe constraints regarding wireless bandwidth in the kilobits
range. This makes a centralised approach to high-level mission management possibly less than
ideal due to inherent delays and possible temporary incompleteness in data during decision making.
This thesis aims to propose, implement (in ROS) and test a distributed approach. An auction based
method for task assignment was being used, as well as a Pagerank based approach that models a
trust based hierarchy between autonomous agents inferred from information exchange, in order
to enforce decision conformity. Simulations where carried out using UWsim and a custom made
bandwidth limiter for ROS. It was concluded that the Pagerank based algorithm managed to uphold
conformity and solve conflicts during network slowdown but did not always lead to the correct
decisions being enforced.
Table of Contents
1
Introduction
5
1.1
Motivation
. . . .
5
1.2
Problem Formulation . . . .
5
1.2.1
Hypothesis . . . .
5
2
Theoretical background
6
2.1
Pardighms for autonomous agents
. . . .
6
2.2
Mission management and planning . . . .
6
2.3
Level of autonomy . . . .
7
2.4
Swarm behaviour . . . .
7
3
Related work
8
3.1
Market based task allocation
. . . .
8
3.2
Ontology based mission management . . . .
8
3.3
Other related work . . . .
8
4
ROS - Robotic operating system
10
4.1
A brief ROS overview
. . . .
10
4.1.1
Syncronisation . . . .
10
4.2
Simulation . . . .
10
5
Pagerank
11
5.1
Deriving pagerank - Random surfer model . . . .
11
5.2
Distrubuted Pagerank computation . . . .
11
6
Method
13
6.1
Main concept . . . .
13
6.1.1
Test criteria and prerequisites . . . .
13
6.2
Applied planing problem . . . .
13
7
Setup
14
7.1
Simulation enviroment . . . .
14
7.2
State synchronisation . . . .
14
7.3
Authority and trust
. . . .
15
7.3.1
Trust-rewards from state synchronisation
. . . .
15
7.3.2
Pagerank . . . .
16
7.4
Decision arbitration
. . . .
16
7.5
Task allocation . . . .
16
7.6
Mission management model . . . .
16
7.6.1
Planning
. . . .
17
8
Testing and results
18
8.1
Test 1 . . . .
19
8.2
Test 2 and 3 . . . .
20
8.3
Test 4 . . . .
21
8.4
Conflicts soursounding task asignment . . . .
21
8.5
Size of packets
. . . .
22
9
Discussion
23
9.1
Pagerank and trust . . . .
23
9.2
Pagerank
. . . .
23
10 Conclusion
25
10.1 Answer to the hypothesis
. . . .
25
References
27
Appendix A Complete set of test figurers
28
A.1 Test 1 . . . .
28
A.1.1
Trust
. . . .
29
A.2 Test 2 . . . .
31
A.2.1
Trust
. . . .
33
A.3 Test 3 . . . .
35
A.3.1
Trust
. . . .
36
A.4 Test 4 . . . .
38
A.4.1
Trust
. . . .
40
A.5 Size of packets
. . . .
41
A.6 Conflicts soursounding task asignment . . . .
42
Appendix B Implementation
42
B.1 Main package . . . .
42
B.1.1
Custom message types . . . .
42
B.1.2
Globalsync . . . .
42
B.1.3
localstatemessage . . . .
42
B.1.4
movetogoal . . . .
42
B.1.5
statemessagemanegement . . . .
43
B.1.6
swarmfollow . . . .
43
B.2 Task-allocation . . . .
43
B.2.1
Custom message types . . . .
43
B.2.2
Custom service type . . . .
43
B.2.3
Tasking . . . .
44
B.2.4
Biddingstate
. . . .
44
B.2.5
Bidding . . . .
44
B.2.6
Auction . . . .
44
B.3 Pagerank/Trust . . . .
44
B.3.1
Custom message types . . . .
44
B.3.2
Trust
. . . .
44
B.3.3
Mypagerank . . . .
45
B.3.4
TrustTimesPagerank . . . .
45
Appendix C Code
46
C.1 Testing tools
. . . .
46
C.1.1
analysebag.py . . . .
46
C.1.2
analysebag2.py . . . .
48
C.1.3
analysebag3.py . . . .
49
C.1.4
analysebag4.py . . . .
50
C.1.5
taskfeed.py . . . .
52
C.2 Main package . . . .
53
C.2.1
globalsync.py . . . .
53
C.2.2
localstatemessage.py . . . .
55
C.2.3
movetogoal.py
. . . .
56
C.2.4
statemessagemanegement.py . . . .
57
C.2.5
swarmfollow.py . . . .
59
C.3 Pagerank trust . . . .
60
C.3.1
mypagerank.py . . . .
60
C.3.2
trust.py . . . .
61
C.3.3
TrustTimesPagerank.py . . . .
64
C.4 Task allocation . . . .
64
C.4.1
auction.py . . . .
64
C.4.2
authority.py . . . .
66
C.4.3
bidding.py . . . .
69
C.4.4
biddingstate.py . . . .
70
C.4.5
execution.py
. . . .
71
1
Introduction
1.1
Motivation
A robot is an agent that can sense, plan and act. This thesis will focus on the task planning aspect
in the context of an underwater multi-robot system.
One important challenge here is communication limitations associated with underwater
applica-tions of all kinds, For an underwater environment radio-based communication is not feasible since
signal strength quickly deteriorate over even small distances. This means communication need be
performed acoustically with data rates in the kilobit span. When the robots move farther apart
the effective data rate become lower [
1
].
The SWARM-research project at M¨
alardalen University strives to have multiple autonomous
un-derwater vehicles (AUV) that cooperate. A central part of the research is adaptive autonomy, i.e.
a robots level of autonomy changes based on internal and external factors. This also means that
a robot can, at least in theory, change the level of autonomy of another robot in the group.
The current approach is to have a centralised system which involves communication through
sur-face vehicles. As means of communication is limited a central system that is too far away requires
allot of time to synchronise information and sending out commands, while the robots might have
more information at hand than what is possible to send in a reasonable time-frame.
Due to these limits it is of interest to evaluate a decentralised approach with a middleware such as
ROS [
2
] together with AI-methods. This means that all decision making regarding task assignment,
motion-planning and other decisions will be the responsibility of the swarm, thus distributed.
1.2
Problem Formulation
How can different tasks be allocated in a mission that requires constant feedback of information
in a swarm of agents with limited information and communication? How can such task allocation
be optimised? How should agents different states (battery level, positioning or capabilities, etc.)
be taken under consideration during task assignment? How can task completion be monitored
and verified with limited means of communication? How can the problem of limited means of
communication itself be minimised?
The goal is to have a working system of multiple AUVs that can efficiently perform a mission
to-gether successfully while being monitored despite having limited means of communication. When
a successful mission has been verified from a stationary command central in a simulation then this
goal has been met.
1.2.1
Hypothesis
One possible approach towards decentralised planning is to rank each members trustworthiness in
terms of its ability to make informed decisions. This would be inferred from the opinion of its
surrounding peers, and feed into some form of graph centrality measurement i.e. mimicking social
interaction.
Can a Pagerank based algorithm be used in order to overcome cooperation challenges due to
limited means of data synchronisation?
2
Theoretical background
2.1
Pardighms for autonomous agents
Behavior based autonomy means that the agent observes the environment and performs actions
in a single step is. Sense→Act or ”monkey see, monkey do”. One example is the potential field
method for obstacle avoidance where direction is directly computed from a repulsive a tractor
formula [
3
].
Plan based autonomy means that the agent decides its actions in multiple steps, thus
sacrific-ing short term utility for greater long term accomplishments. Examples of plan based autonomy
includes decision-trees, dynamic programming, and sample based methods [
4
].
Both approaches have benefits and drawbacks. In an unknown environment, behaviour based
autonomy offers the ability to make quick decisions in unpredictable events, while plan based
au-tonomy is capable of offering smarter decisions if enough information and computation time is given.
In an attempt to combine ”the best of two worlds” there exists a hybrid approach commonly
referred as the backseat/frontseat paradigm. The backseat driver is responsible for long term
planning and breaking it down to short term sub-objectives. The front seat driver is responsible
for achieving the present sub-objective and making quick decisions in unpredicted events [
5
,
6
,
7
].
2.2
Mission management and planning
If the goal is to completely search an obstacle free area and not perform any actions, or perform
a task in a static and completely known environment, then it is possible to have a complete plan
made before mission launch, However, whenever uncertainty or lack of information is present
be-forehand then it is of interest to be able to adapt or being able to make new plans continuously.
One example of a scenario where an AUV needs to adapt as mission progresses is mentioned
in [
8
]. An underwater-pipeline is leaking and needs to be repaired and the position of the leakage
is only partially known from the pipeline fault detection system (thus a limited search area). The
pipeline has control points with distance D between them.
In order to achieve a better understanding of the mission it can be modelled in different levels
of abstraction. When this is incorporated into the task allocation scheme, it allows for a better
situation awareness from an observers point of view as the mission progresses. This is refereed to
as ontology based mission management [
9
].
When an agent is assigned a task, then the amount of additional effort required to complete
it is dependent on other tasks that have previously been assigned to the agent, thus the optimal
execution sequence of tasks is an inherent sub-problem. With multiple agents the problem of task
assignment is NP-complete. This can be solved using methods such as a Genetic Algorithm or the
Hungarian method [
10
].
As any of the two computational methods mentioned above requires that a particular node in
the method has complete control of task assignment, it is limited by that nodes individual
per-ception of the swarm. One alternative is to have each agent give an estimate of effort themselves,
which also gives them the ability to refuse tasks that they cannot execute. This can be realised
into a auctioning based method for task assignment.
Auction based task allocation or Market based task allocation as it is also known, works by having
each task having an assigned reward. Each agent can then parse through the list of available
tasks and place a bid based on the reward minus its individual cost to complete the task, such as
2.3
Level of autonomy
In presence of multi-agent systems and human automation interaction (HAI), situations where
there lies an asymmetry of situational awareness or capability to make decisions. In order to tackle
this an agent can have an adjustable level of autonomy (LOA) depending on internal and external
parameters. Depending on LOA an agent may operate fully autonomous, wait for the human to
veto its plan, give suggestions or let the human completely take over control [
12
]. This decreases
the workload for a human operator that is controlling a large number of agents [
13
].
In a multi agent scenario, there exists an extended concept where an agent with a high LOA
takes the humans place to interact and control agents with lower LOA. This is motivated by
flex-ibility and robustness [
14
].
One way of determining the level of autonomy is to have a central expert system observe
per-formance shaping factors and set LOA in accordance [
15
,
16
],
2.4
Swarm behaviour
Swarm robotics is the study of how to make a large number of robots that individually perform
simple behaviour result in large scale results. This is greatly inspired by phenomena in nature. A
member in the swarm only interacts with its neighbours and environment.
One example of swarm behaviour that was presented by Castello et al. [
17
] was based on an
adaptive response threshold model. No communication between agents took place and instead
they only observed in the environment. The task was to collect food that is being consumed by an
unknown factor and consume as little energy as possible, which means that more than necessary
food should not be collected at a time. Two states were given, namely being passive at home or
collecting. These two states were decided by having each agent observe how much food is collected
with an internal random walk that have an attracting factor depending on how much food is being
stored. By having different variance in each agents random walk (could be interpreted as different
”laziness” to transition states) they will transition states at different times, and thus having an
emergent behaviour that solved the task.
WeiXing et al. [
18
] proposed a simple method for underwater robots to maintain a formation
in a circular shape. Each robot has a rank where those nearest the litter robot have a higher rank.
Each robot tries to maintain a certain distance to higher ranking robots in an interactive/repulsive
manner.
3
Related work
3.1
Market based task allocation
Zlot and Stenz [
19
] introduced the complex task allocation problem and described a distributed
market based solution to the problem. A complex task may be decomposed into multiple subtasks
that can either be simple or complex. A set of simple tasks can also be clustered into a complex
task. In order to model complex tasks they were structured into a tree structure in a logical
AND/OR way. The parent in the tree is a task that is performed by performing its child-tasks.
Experiments were carried out with autonomous ground vehicles in an area reconnaissance scenario,
and showed that this approach improved on algorithms that only allocate simple tasks.
Kaira et al. [
20
] developed a market based framework called Hoplites. It consists of two
coor-dination mechanisms denoted as active and passive coorcoor-dination. Passive coorcoor-dination means that
one robot first generates a set of possible plans and select the one with highest utility, then
broad-cast its plan to its teammates, the teammates use this information to reevaluate their plans and
broadcast their changes, this continues iteratively and can be efficient to generate local planning.
Active coordination means that a robot compute a complete plan for itself and team-members, it
presents the solution to its team-members and if it has greater utility for the whole team than the
previous plan it is accepted. Active coordination is performed by a team-member if its current plan
only has small utility as a mean to escape local minima. The Hoplites algorithm was implemented
and tested on wheeled robots tasked with searching an area for intruders and was shown to perform
better than many of its competing algorithms.
Mosteo and Montano [
21
] compared multiple auction based techniques for task allocation. They
provided simulation results and showed that the MinMix which combines both time and resource
costs performed well in all tested cases. MinSum was good performed well in terms of resource
usage, but was worse for mission time. It was also shown that only allowing each robot to have
one task allocated at a time is best suited for situations where the number of tasks outnumber the
robots.
3.2
Ontology based mission management
Miguela˜
nez et al. [
9
] proposed a semantic world model framework for hierarchical distributed
rep-resentation of knowledge in autonomous underwater systems. The idea is that similar real-world
data must be processed through several different layers before being used by high-level decision
making. This work stride for higher situation awareness for AUVs thus enabling a higher degree
of autonomy. Finally, the framework was tested on an AUV in water while performing a mine
counter measure mission with a simulated hardware fault.
Shared Knowledge Interaction Model (SKIM) proposed by Drenjanac et al. [
22
] is capable of
centralised, distributed and hybrid task assignment. SKIM is based on a model driven
architec-ture with ontologies. Three possible criteria’s for measuring performance of adaptive autonomy is
also mentioned as “1) the success rate of task allocation, 2) the communication overhead, and 3)
the robot utilization rate”.
3.3
Other related work
Shafer et al. [
23
] proposed a cellular-decomposition-based framework for cooperative and adaptive
search. They carried out simulations with an AUV platform together with an autonomous surface
vessel that carried out a lawn-mover like pattern in an area to search for mines. The framework
was implemented in MOOS and IvPHelm. They showed that it is feasible to use autonomous
with an AUV. CARACas features an dynamic re-planing engine that take temporal and resource
constraints into consideration, as well as a real-time behavioural engine that can avoid hazards
and perform low-level tasks.
4
ROS - Robotic operating system
Implementing and testing in a predefined software framework have many benefits as code becomes
compatible with other projects and having common algorithms already implemented. Robotic
operating system (ROS) is a software eco-system on top of Linux with many tools and libraries
designed for robotic purposes. Among those there are packages for motion-planning, localisation,
tools for human-robot interaction and tools to monitor data-flow [
2
].
4.1
A brief ROS overview
The ROS-Master is a server used to enable communication between all programs that are being
run known as nodes. Nodes and the ROS-Master does not have to be run on the same machine as
long as there exists a network connection, and is transparent in the sense that when developing a
node no additional code needs to be written in order to run on a separate machine as this is taken
care of from a configuration file that specifies where to connect with the ROS-Master [
2
].
4.1.1
Syncronisation
There are three ways for nodes to synchronise data in ROS.
• Parameters are stored and retrieved from the ROS-Master. This needs to be actively
re-quested as they are mainly used for initiation data ie. PID-parameters, robot-name, etc. A
parameter can be defined prior to launch of any nodes.
• Message/topics are a peer-to-peer multiple sender to multiple receivers means of
synchroni-sation.
• Services is a remote procedure call operation which also is a blocking operation on the
requesting node. As opposed to message/topics this is a one to one means of synchronisation
and ends with a response back to the requesting node.
4.2
Simulation
Gazebo is a simulation environment for ROS that features realistic physics and is designed so that
the robot software can interact with it as if it was against the real world. The only difference is that
the hardware interacting processes need to be replaced by processes that interact with gazebo[
25
].
UWSim is a ROS-compatible simulation environment purposely developed for underwater robotics.
It is possible to either run with dynamics turned on in order to test things like visual servoing in
difficult conditions, or run without dynamics, thus enabling testing of more high-level processes
without interference of things such as inadequate PID-parameters [
26
].
5
Pagerank
Pagerank is a method developed for measuring the importance of web pages based on link structure
analysis. It is the original method used by the Google web search engine in order to decide on
which order it should display web pages. It is based on the assumption that a link from one website
to another is regarded as a recommendation and the relevance of such a recommendation depends
on how well the recommending website is recommended by others. The formula is as follows:
P R(p
i) =
1−dN+ dΣ
P R(pj)
L(pj)
Where P R(p
i) is current Pagerank for the node p
i, N is the total number of nodes, L(p
i) is
the total number of links from the node p
jand d is a dampening factor that is empirical decided
(usually around 0.85).
The transition probability component of Pagerank (
L(p1j)
or 0) can be altered into any
proba-bility distribution. This does not violate any off they theory supporting its convergence towards a
unique value as long as no self-linking occurs.
Computation can be achieved by formulating above formula into matrix form and compute its
eigenvalue [
27
,
28
,
29
].
A benefit of Pagerank is that it has been proven to be robust against tendencies of two
differ-ent competing groups competing in credibility denoted as the tightly-knitted community effect
[
30
].
5.1
Deriving pagerank - Random surfer model
The core assumption of Pagerank is an websurfer mindlessly browsing the internet without memory
of prior pages (Markov property), there are also not any pages that link to themselves (self-loops).
Our goal is to obtain the proportional amount of visits given an infinite amount of transitions,
thus being able to rank pages by prominence.
Parameter d is the probability that our random surfer will click a link on the current page, this
also means that there is a (1-d) probability that said surfer will instead decide to start over at a
new page, hence if d=0 then there is a uniform probability distribution among all pages on the
web for which page will be next page to visit.
Now with a non-zero d we have from the additive property of probabilities that the probability of
arriving at the page p
ican be expressed as:
P (pi) =
1−dN+ d ∗ G(pi)
Where G(pi) is the probability that the random surfer arrive at pi
from any other page given
a link has been followed. Now to find G(pi) we need to consider all pages that have a direct link
to pi
and obtain:
G(pi) = ΣP (pj) ∗ P (pi|pj)
And finally we need the transition probability P (Pj
→ pi) that in this case we chose as P (Pj
→
p
i) = 0 if there is no direct link and P (P
j→ pi
) =
L(p1j)if there is a direct link.
5.2
Distrubuted Pagerank computation
An inherent parallel way of computing Pagerank is the Gauss-Sejdel method. With a parameter t
let P R(pi, t + 1) =
1−dN+ dΣ
P R(pj,t)L(pj)
and P R(pi, 0) =
1
N
. Stop when ||P R(pi, t) − P R(pi, t) < for
a small [
31
]. As the only information required in order to calculate P R(pi, t + 1) are neighbouring
Pagerank and transition probabilities this can be implemented on a distributed system.
Das Sarma et al.
proposed a distributed Monte Carlo method of computing Pagerank.
The
key concept is that each node generate a set of ”coupons” at the start and send them randomly
to other nodes in accordance to its transition probabilities, and counts the number of visits from
incoming coupons. They also proved that it is able to compute a δ-approximation in O(
log(n))
rounds for any constant δ, and that message size is at most O(logn) per each edge in every round
where n is the total number of nodes [
32
].
6
Method
6.1
Main concept
In the context of unreliable or insufficient means of communication, there may be different pieces
of information available among different subsets of the swarm. These circumstances mean that
dif-ferent subsets of the swarm will come to difdif-ferent conclusions in terms of distributed multi-agent
planning. One possible remedy would be to rank each member in the swarm in terms of their
ability to make well informed decisions and have those decisions take precedence over decisions
made by lesser informed agents.
Each agent maintains a table that states how much trust they put into other individual agents.
With these tables in place the idea is to create some sort of voting procedure in order to establish
a hierarchy, the Pagerank algorithm was chosen for this purpose for the following reasons:
• It allows for indirect voting IE. an outlier in the swarm can chose to only assign trust for its
immediate neighbours that in turn obtain more power to affect the authority of others.
• It allows for distributed computation in such a way that local authority can be determined
without complete knowledge of the entire swarm.
• It is robust against the tightly knit community problem.
In order to model trust the key assumption is that an agent that is able to produce or relay data
that is useful for the mission are more likely to be more well informed than an agent that is unable
to do so. The source of trust that was implemented in this thesis was based on the timestamps of
local state data such as current position.
6.1.1
Test criteria and prerequisites
As the key concept relies on trying to make decisions from well informed agents take precedence
over lesser informed agents, it needs to be tried in a context where these conflicts can be analysed
post-simulation, and correct decisions needs to be shown to be enforced due to authority more
frequent than incorrect decisions.
In order to test the correctness the surrounding framework must be implemented and organised in
such a way that it is clear whenever or not a certain decision was truly correct.
6.2
Applied planing problem
The planing-problem that will be tested against is multi-agent task assignment. While auction
based task assignment is an efficient solution, the synchronization of bidds still means that not
every member will know the set of bids for every other member of the swarm, under the constraint
of limited and unreliable communication.
Auction based task assignment was chosen as it is deterministic and any recorded bid-messages
yields a clear way to perform post simulation analysis, in terms of determining if the best bid
meant that the agent in question was assigned the task.
7
Setup
7.1
Simulation enviroment
UWsim was is to simulate an environment with multiple AUVs. At first the intention was to
run the code for each AUV on a separate virtual machine, however this was turning out to be
impractical and unnecessary, instead each AUV runs on the same machine and ROS-master but
with separate namespaces. Inside each robot namespace there are two folders named ”in” and
”out” for sending and reviving ROS-messages to other robots.
In order to avoid interference from low performing control-systems and performance demanding
navigation systems no sensor data from UWsim is being used, dynamic physics is left turned off.
Each robot is given its true position without noise.
For the sake of simplicity all inter-robot communication is assumed to be on a
multiple-input/multiple-output basis ie. a full duplex communications link for each pair of robots. Available bandwidth is
directly inferred as a linear relationship of distance and packet-loss is decided by a random number
generator with probability of packet loss also decided by the distance (”line of sight”-restrictions
are disregarded).
Relaying for ROS-messages i done through a common ROS-node that creates a set of FIFO-queues
in order to act as an intentional bottleneck.
Figure 1: Message transmission
7.2
State synchronisation
At regular intervals a local state-message is generated, including current position, battery-level
and what task is being worked on. This message is meant to be sent out to neighbouring
swarm-members in an unreliable manner (UDP-packet).
Each member in the swarm maintains a list that maps robot-names to timestamps from latest
update regarding the current state (retrieved from state message). As this list is broadcast to
neighbouring swarm-members an indirect method for rebroadcasting state-spaces emerges.
If the incoming lists of timestamps shows a time-difference beyond a pre-set threshold then the
relevant state-message is relayed. If the threshold criteria is not met, then the local state message
is sent out.
7.3
Authority and trust
In this context authority is a numeric value used for deciding whenever a group member is able
to make decisions that overrides other members’ decisions. It is calculated from Graph centrality
using the Pagerank metric.
Trust is gained by information exchange between two agents over time in accordance to a metric
on relevance and usefulness. Trust is only given out if there is a direct link off contact between
two agents and can be reduced.
The main idea is that if an agent is able to relay information that is considered useful to other
members of the swarm then it must have, to a greater extent more relevant knowledge than an
agent unable to do the same.
Due to the modularity friendly nature of ROS it is possible to have trust from multiple sources
added together without any other alteration other than launching a new process that outputs an
array of trust-values.
One source of trust is called trust-rewards. It is defined by a timestamp, label of whom shall
be rewarded and value of the reward. The reward expires once it is older than a certain amount
off time (default is 30 seconds).
7.3.1
Trust-rewards from state synchronisation
A constant need for situational awareness is the ability for each member of the swarm to know
the current state of all other members. There are two deciding factors that comes into play when
deciding on how useful a state-message is appreciated: Its timestamp in relation to current time
(∆t
now) and its timestamp in relation to prior knowledge (∆t
old).
These two factors can either be large or small and can be arranged in order of importance in
order to establish how large the reward should be (inspired by fuzzy logic):
1. ∆t
nowis small and ∆t
oldis large.
2. ∆tnow
is small and ∆told
is small.
3. ∆tnow
is large and ∆told
is large.
4. ∆tnow
is large and ∆told
is small
So far the terms ”small” and ”large” are ambiguous and needs a stricter definition. The main
con-cern is that a time difference can in theory be infinite thus complicating inference. This would be
less of a problem if it got constrained to a number between zero and one. Hence we remap any ∆t as:
∆t
remapped:=
∆t+1∆tThis constrains our values between zero and one using rudimentary knowledge of limits. For
the sake of readability we will consider any ∆t as if already remapped.
Above list can now be generalised into a simple plane equation where (x,y) values are the
dif-ferent ∆t and the z value is the inferred reward:
reward = (1 − K) ∗ ∆told
− k ∗ ∆tnow
+ K
to a reward equal to zero. K is a parameter larger than 0.5 and smaller than 1.0 that represents
the difference of value between #2 and #3.
7.3.2
Pagerank
After normalising all agents trust, then it is possible to apply Pagerank. This is done by having
each agent continuously broadcast its current Pagerank and normalised trust ie. a distributed
Gauss-Seijdel method.
An additional detail is that a dummy agent corresponding to the human operator will receive
an additional constant amount of trust from all other agents. This is done in order to preserve
an amount of control for human operator and maintain the possibility to not give out any relative
trust to other robots after normalisation.
7.4
Decision arbitration
When the process wants to make a change in the current set of decisions it sends out a proposal
to a separate process called authority check. The authority check process takes in proposals from
other swarm members and the local Meta-task process, alters the current decision table whenever
a proposal comes from a higher authority than the previous decision.
Figure 3: Suggestions are accepted/rejected in accordance to authority
7.5
Task allocation
Task allocation is done by auctioning. When a simple task is released on the market by its parent
meta-task, then it can be bid on for any member of the swarm. Bidding value is decided by how
much the given task would affect a numeric value that describes how well the robot is used known
as plan utility.
7.6
Mission management model
A mission is divided into abstract meta-tasks and concrete tasks in a weighted tree as shown in the
figure below. In this concept a task is meant to be a simple command as ”go here and do this”,
while a meta-task is responsible for defining subordinate tasks/meta-tasks.
Figure 4: An example task tree. Circles represents actual tasks.
The root node in this tree is meant to be a means of graceful human intervention. If an
unexpected event occurs which is not handled efficiently by the swarm or new aspects of the
mission is discovered then the human operator can create a new branch of tasks in order to deal
with the situation. One example could be to regain contact with a robot that is out of reach for
communication.
7.6.1
Planning
Definition 1. Effective value: Each task is valued by its weight multiplied with all parent weights
up to the root node in the task tree.
Definition 2. Total travel distance: The distance a robot must travel from its current position to
a task while also travelling to other previously given tasks before it.
Definition 3. Task utility: The tasks effective value divided by total travel distance.
Each robot has a set of tasks that it has been previously given. These tasks get sorted into a
list in order to form a plan. This is done in a greedy fashion as follows:
1. Set plan utility=0.
2. Calculate total travel distance and task utility for all tasks in the allocated task set that has
not been added to the execution plan yet.
3. Add the task with highest task utility to the end of the execution plan, Also add the task
utility for that same task to the plan utility.
4. If there is still tasks in the allocated task set that has not been added to the execution plan
then goto step 2.
5. Return plan utility and exit.
While this method does not take battery usage and individual capabilities such as gripper/arms,
this concept can easily be extended by having a maximum allowed travelling distance and filter
out tasks that cant be performed by the individual.
8
Testing and results
In order to ensure clarity this section only contains a limited set of the most relevant data-figures.
The reader is encouraged to consult the appendix for the full set of data-figures.
All simulations took place in UWSim with three AUVs simulated. Realistic physics turned of.
Figure 5: Screenshot of UWSim
The mission was to traverse to a large set of way-points where each way-point only requires
one AUV for that singular task to be successful.
Figure 6: Simplified overview
Four simulations was carried out with different network limitations. If two AUVs are closer
than stated minimum distance then they have unlimited bandwidth towards each other. Available
bandwidth decreases linearly from the minimum distance to the maximum distance.
Test
Min dist.
Max dist.
Max bps
1
∞
∞
∞
2
7
20
1k
3
7
20
2k
4
0
100
1k
Base agent was unconditionally given additional trust equal to one from each other agent. All
communication where recorded into a rosbag file for further analysis.
8.1
Test 1
Pagerank converges to the same value for all AUVs while minor disturbances due to race conditions
take place during steady state.
Figure 7: Pagerank over time
Figure 8: Individual task utility over time
8.2
Test 2 and 3
As test 3 had twice the amount of available bandwidth than test 2, only one conflict took place in
test three as compared to nine conflicts in test 2.
Figure 9: Test 2. Pagerank over time.
Test 2 and 3 yielded similar behaviour in terms of pagerank.
Figure 10: Test 3. Pagerank over time
8.3
Test 4
Test 4 which had the steepest decrease of bandwidth demonstrated a chaotic behaviour in terms
of Pagerank.
Figure 11: Pagerank over time
8.4
Conflicts soursounding task asignment
The following table shows the number of conflicting decisions that took place and got overturned
due to diference in Pagerank, as well the number off these tasks that ended with the resulting
winner having an inferior bid than the loser.
Test
Num conflicts
Wrong winner
1
3
0
2
9
4
3
1
1
4
6
3
8.5
Size of packets
Some measurements taken during tests gave the following size of packets. Note that the size of State
stamp and Trust are dependent on the size of the swarm and are therefore only valid in this context.
Message
Size (bytes)
State
83
Statestamp
88
Trust
30
Bidd
33
Taskstatus
41
With a publishing frequency of 1/2Hz for Trust it uses 120bps on average. Note that this
number grows linearly with the number of agents in the swarm.
9
Discussion
9.1
Pagerank and trust
As seen on the first test the trust metric is highly sensitive to small changes in delay. The ”bumps”
in figure 7 are caused by other programs running on the same computer, causing temporary delays.
The steady state difference in trust can be explained by phase difference among publishing loops.
As observed from test 2 there were frequent occurrences of connection delays between the Base
agent and the robots. As trust is only given if there have been exchanges of trust-packets within
the last 5 seconds, there were a significant amount of spikes in terms of relative trust, thus causing
calculated Pagerank to change in an slightly unpredictable manner. This did not have significant
improvements in test 3 where available bandwidth was doubled.
In test 4 the flaw of having discontinuity’s in the Trust metric becomes clearly visible. As shown
seen in figure 29-32 the outgoing trust is severely unstable.
9.2
Pagerank
So far i have only considered trust that is formed on an objective basis ie. Trust-rewards based
meta-data such as timestamps. Another aspect is trust based on a subjective basis ie. the actual
content of the data. This can include many aspects surrounding internal/external states that
dictate a need for an agent in the swarm to have an increased or decreased ability to affect decisions
in the swarm. Examples of this are:
• Battery level.
When a robot has a low battery level, then it is an indicator of its upcoming absence.
This could lead to it, leaving decisions behind for the rest of the swarm to obey without
understanding of the reasoning behind them.
• Positional accuracy and navigation data.
If a robot lack knowledge of the surrounding environment and its placement relative to its
peers, it may be a reason to question its ability to make decisions of how its peers should
move around.
• Vicinity of danger.
If an agent alerts its peers of dangerous circumstances such as sea-mines that they previously
was not aware of then it is also capable of guiding its peers with safe trajectories.
• Task related requirements and capabilities.
9.3
Task allocation
As the auctioning procedure was intentionally slowed down in order to provide ample time for
syn-chronisation, it became unexpectedly slower than the execution-rate of tasks as they were placed
too close to each other. The results from the tests concerning task allocation can’t by itself be
concluded from a quantitative standpoint without further testing.
The design choice of having an agent immediately entering ”swarm-mode” when it has no
as-signed task created a tendency for having the robots unnecessary stick together and compete for
the same set of tasks. With more rapid task allocation as compared to execution, it is plausible
for this problem to decrease.
I propose the following hypothetical approaches on how to promote a more rapid spread out
in the task assignment, thus avoiding unnecessary close competition:
• Select a small set of spread out tasks equal to the number of members of the swarm, and
assign a higher reward than other tasks for completing them. This would mean that these
selected tasks get assigned earlier in the greedy auctioning process, thus creating spread out
market segments.
• Extend the evaluation process for task utility to include reasoning in terms of how it may
potentially affect future bids. A potential drawback to this is that it could lead to a set of
tasks being ignored.
• Pre-assign tasks using a global optimisation and use auctioning as a fall back procedure for
unexpected events.
9.4
Towards adaptive autonomy
As i have only considered the use of Pagerank as a means of measuring an agent’s ability of making
informed decisions that affect itself and others, it is not adaptive autonomy in the full sense as it
does not fully measure an agents ability to efficiently execute tasks.
There are three possible approaches on how our use of Pagerank may be extended into full adaptive
autonomy:
• Let every single decision be scrutinised by the authority check.
Benefit: Fluid transition between autonomy level.
Drawback: Unnecessary communication off suggestions that ends up rejected.
• Decide the autonomy level directly from Pagerank.
Benefit: Low complexity of implementation and predictable transitions.
Drawback: As trust is a relative concept, it is not fully able reflect performance shaping
factor on an absolute basis.
• Let autonomy level be a decision that is checked by the authority system. Benefits: A swarm
member that gained a low Pagerank in a highly functional swarm may still be able to act on
a high LOA if deemed appropriately from the expert systems of a high Pagerank member.
Drawback: Adds an additional layer of complexity.
9.5
Future work
Apart from optimising bandwidth usage possible steps for future development are:
• Global optimization for task allocation.
• Trust-rewards from a multitude of sources.
• Incorporate Pagerank into a full adaptive autonomy system that takes into account an agents
ability to perform its tasks.
9.5.1
Internal swarm politics
An interesting aspect of introducing trust based on subjective aspects is if agents also get
pro-grammed in order to maximise their own authority. Strategies like this could include:
• Prioritize relaying of information that reduces the trust off others.
• Selectively fail to relay the same information if it hurts another agent that gives allot of
incoming trust.
• Give additional trust to peers that give large amounts of trust back in order to maximise the
payoff in Pagerank.
10
Conclusion
• While the Pagerank shows an promising outlook it did perform poorly on solving conflicts in
its current configuration due to discontinuities in how its feed the trust-metric.
• Tasks where executed to quick during the simulations for the market based task allocation
to keep up. As this was mainly due to tasks being placed to close apart and robots moving
to fast in the simulation environment, no conclusion can be made without further testing.
• With more added sources of trust this implementation of Pagerank can be incorporated into
a system performing adaptive autonomy.
• A hierical system based on trust-induced indirect voting is not by itself a guarantee for
establishing optimal decisions.
10.1
Answer to the hypothesis
As the hypothesis was stated: Can the Pagerank based algorithm be used in order to overcome
cooperation challenges due to limited means of data synchronisation?
The proposed and implemented framework in this thesis can be regarded as a confirmation to
the hypothesis.
References
[1] I. F. Akyildiz, D. Pompili, and T. Melodia, “Underwater acoustic sensor networks: research
challenges,” Ad hoc networks, vol. 3, no. 3, pp. 257–279, 2005.
[2] M. Quigley, K. Conley, B. P. Gerkey, J. Faust, T. Foote, J. Leibs, R. Wheeler, and A. Y. Ng,
“Ros: an open-source robot operating system,” in ICRA Workshop on Open Source Software,
2009.
[3] Y. Koren and J. Borenstein, “Potential field methods and their inherent limitations for mobile
robot navigation,” in Robotics and Automation, 1991. Proceedings., 1991 IEEE International
Conference on, Apr 1991, pp. 1398–1404 vol.2.
[4] S. M. LaValle, Planning algorithms.
Cambridge university press, 2006.
[5] D. Eickstedt and S. Sideleau, “The backseat control architecture for autonomous robotic
vehicles: A case study with the iver2 auv,” in OCEANS 2009, MTS/IEEE Biloxi - Marine
Technology for Our Future: Global and Local Challenges, Oct 2009, pp. 1–8.
[6] T. Y. Teck and M. Chitre, “Hierarchical multi-agent command and control system
for autonomous underwater vehicles,” in Autonomous Underwater Vehicles (AUV), 2012
IEEE/OES, Sept 2012, pp. 1–6.
[7] A. Balasuriya, S. Petillo, H. Schmidt, and M. Benjamin, “Behavior-based planning and
prose-cution architecture for autonomous underwater vehicles in ocean observatories,” in OCEANS
2010 IEEE - Sydney, May 2010, pp. 1–5.
[8] J. Albiez, S. Joyeux, and M. Hildebrandt, “Adaptive auv mission management in
under-informed situations,” in OCEANS 2010, Sept 2010, pp. 1–10.
[9] E. Miguela˜
nez, P. Patron, K. Brown, Y. Petillot, and D. Lane, “Semantic knowledge-based
framework to improve the situation awareness of autonomous underwater vehicles,” Knowledge
and Data Engineering, IEEE Transactions on, vol. 23, no. 5, pp. 759–773, May 2011.
[10] C. Jianping, Y. Yimin, and W. Yunbiao, “Multi-robot task allocation based on robotic utility
value and genetic algorithm,” in Intelligent Computing and Intelligent Systems, 2009. ICIS
2009. IEEE International Conference on, vol. 2, Nov 2009, pp. 256–260.
[11] A. T. Stentz and M. B. Dias, “A free market architecture for coordinating multiple robots,”
Robotics Institute, Pittsburgh, PA, Tech. Rep. CMU-RI-TR-99-42, December 1999.
[12] A. Fereidunian, M. Lehtonen, H. Lesani, C. Lucas, and M. Nordman, “Adaptive autonomy:
Smart cooperative cybernetic systems for more humane automation solutions,” in Systems,
Man and Cybernetics, 2007. ISIC. IEEE International Conference on, Oct 2007, pp. 202–207.
[13] M. Goodrich, T. McLain, J. Anderson, J. Sun, and J. Crandall, “Managing autonomy in robot
teams: Observations from four experiments,” in Human-Robot Interaction (HRI), 2007 2nd
ACM/IEEE International Conference on, March 2007, pp. 25–32.
[14] K. Barber, “Dynamic adaptive autonomy in agent-based systems,” in Autonomous
Decentral-ized Systems, 1999. Integration of Heterogeneous Systems. Proceedings. The Fourth
Interna-tional Symposium on, 1999, pp. 402–405.
[15] A. Fereidunian, M. Zamani, F. Boroomand, H. Jamalabadi, H. Lesani, and C. Lucas, “Aalres:
An intelligent expert system for realization of adaptive autonomy using logistic regression,”
in MELECON 2010 - 2010 15th IEEE Mediterranean Electrotechnical Conference, April 2010,
pp. 1534–1539.
[17] E. Castello, T. Yamamoto, Y. Nakamura, and H. Ishiguro, “Task allocation for a robotic
swarm based on an adaptive response threshold model,” in Control, Automation and Systems
(ICCAS), 2013 13th International Conference on, Oct 2013, pp. 259–266.
[18] F. WeiXing, W. KeJun, Y. XiuFen, and G. ShuXiang, “Novel algorithms for coordination of
underwater swarm robotics,” in Mechatronics and Automation, Proceedings of the 2006 IEEE
International Conference on, June 2006, pp. 654–659.
[19] R. Zlot and A. Stentz, “Complex task allocation for multiple robots,” in Robotics and
Au-tomation, 2005. ICRA 2005. Proceedings of the 2005 IEEE International Conference on, April
2005, pp. 1515–1522.
[20] N. Kalra, D. Ferguson, and A. Stentz, “Hoplites: A market-based framework for planned
tight coordination in multirobot teams,” in Robotics and Automation, 2005. ICRA 2005.
Proceedings of the 2005 IEEE International Conference on, April 2005, pp. 1170–1177.
[21] A. Mosteo and L. Montano, “Comparative experiments on optimization criteria and
algo-rithms for auction based multi-robot task allocation,” in Robotics and Automation, 2007
IEEE International Conference on, April 2007, pp. 3345–3350.
[22] D. Drenjanac, S. Tomic, and E. Kuhn, “A semantic framework for modeling adaptive
auton-omy in task allocation in robotic fleets,” in Enabling Technologies: Infrastructure for
Collabo-rative Enterprises (WETICE), 2015 IEEE 24th International Conference on, June 2015, pp.
15–20.
[23] A. Shafer, M. Benjamin, J. Leonard, and J. Curcio, “Autonomous cooperation of
heteroge-neous platforms for sea-based search tasks,” in OCEANS 2008, Sept 2008, pp. 1–10.
[24] T. Huntsberger and G. Woodward, “Intelligent autonomy for unmanned surface and
under-water vehicles,” in OCEANS 2011, Sept 2011, pp. 1–10.
[25] N. Koenig and A. Howard, “Design and use paradigms for gazebo, an open-source
multi-robot simulator,” in Intelligent Robots and Systems, 2004.(IROS 2004). Proceedings. 2004
IEEE/RSJ International Conference on, vol. 3.
IEEE, pp. 2149–2154.
[26] M. Prats, J. P´
erez, J. J. Fern´
andez, and P. J. Sanz, “An open source tool for simulation and
supervision of underwater intervention missions,” in Intelligent Robots and Systems (IROS),
2012 IEEE/RSJ International Conference on, Oct 2012, pp. 2577–2582.
[27] S. Brin and L. Page, “The anatomy of a large-scale hypertextual web search engine,” in
Seventh International World-Wide Web Conference (WWW 1998), 1998. [Online]. Available:
http://ilpubs.stanford.edu:8090/361/
[28] K. Bryan and T. Leise, “The $25,000,000,000 eigenvector:
The linear algebra behind
google,” SIAM Rev., vol. 48, no. 3, pp. 569–581, Mar. 2006. [Online]. Available:
http://dx.doi.org/10.1137/050623280
[29] M. Franceschet, “Pagerank: Standing on the shoulders of giants,” Commun. ACM, vol. 54,
no. 6, pp. 92–101, Jun. 2011. [Online]. Available:
http://doi.acm.org/10.1145/1953122.
1953146
[30] R. Lempel and S. Moran, “Salsa:
The stochastic approach for link-structure analysis,”
ACM Trans. Inf. Syst., vol. 19, no. 2, pp. 131–160, Apr. 2001. [Online]. Available:
http://doi.acm.org/10.1145/382979.383041
[31] A. Arasu, J. Novak, J. Tomlin, and J. Tomlin, “Pagerank computation and the structure of
the web: Experiments and algorithms,” 2002.
[32] A. D. Sarma,
A. R. Molla,
G. Pandurangan,
and E. Upfal,
“Fast distributed
pagerank computation,” Theoretical Computer Science, vol. 561, Part B, pp. 113 –
121, 2015, special Issue on Distributed Computing and Networking. [Online]. Available:
A
Complete set of test figurers
Test
Min dist.
Max dist.
Max bps
1
∞
∞
∞
2
7
20
1k
3
7
20
2k
4
0
100
1k
A.1
Test 1
Figure 14: Individual task utility over time
A.1.1
Trust
Figure 16: Robot 2 Trust
Figure 18: BASE agent Trust
A.2
Test 2
Figure 20: Distance to nearest neighbour over time
A.2.1
Trust
Figure 22: Robot 1 Trust
Figure 24: Robot 3 Trust
A.3
Test 3
Figure 26: Pagerank over time
Figure 28: Individual task utility over time
A.3.1
Trust
Figure 30: Robot 2 Trust
Figure 32: BASE agent Trust
A.4
Test 4
Figure 34: Distance to nearest neighbour over time
A.4.1
Trust
Figure 36: Robot 1 Trust
Figure 38: Robot 3 Trust
Figure 39: BASE agent Trust
A.5
Size of packets
Message
Size (bytes)
State
83
Statestamp
88
Trust
30
Bidd
33
A.6
Conflicts soursounding task asignment
Test
Num conflicts
Wrong winner
1
3
0
2
9
4
3
1
1
4
6
3
B
Implementation
All code is written in python using the rospy api for ROS. All programs except Biddingstate and
Globalsync are run in a separate instance for each agent inside a corresponding namespace.
Names for published and subscribed topics are within quotation marks and is in the namespace
unless it starts with an ”/”. Topic type is within () brackets.
B.1
Main package
B.1.1
Custom message types
• idstamp
string id
time stamp
• idstamparray
string sender
time stamp
idstamp[] data
• staterelay
string sender
string id
time stamp
int8 battery
geometry msgs/Point pos
geometry msgs/Point destination
B.1.2
Globalsync
Subscribe to all topics inside all out-folders.
Publishes to all topics inside all in-folders.
This process is intended to simulate communication with delay between a hard-coded list of
names-paces. Each listed namespace needs to have an in-folder and an out-folder for topics that are to
be transferred.
B.1.3
localstatemessage
Subscribes to odom (nav msgs.msg/Odometry), plan (Int32), and battery (Int32).
Publishes to state (staterelay).
Compiles all listed subscribed topics into a single staterelay-message.
B.1.4
movetogoal
B.1.5
statemessagemanegement
Subscribes to ”state” (staterelay), ”in/state” (staterelay), and ”in/statestamp” (idstamparray).
Publishes to ”reward” (idval), ”out/state” (staterelay), ”out/statestamp” (idstamparray), and
”states” (staterelay).
This process is responsible for synchronise current state with other members of the swarm as well
as relay its knowledge of states to other members of the swarm. This is done by keeping a list of
timestamps for every known state and sharing it. If a neighbour shows that it have a timestamp
that is significantly older than what is on the local list, then the current local knowledge will be
sent (longest age difference first).
When a state message is received, then the sender will be awarded with trust proportional to
the age difference to prior knowledge.
B.1.6
swarmfollow
Subscribes to ”odom” (nav msgs.msg.Odometry), ”states” (staterelay), and ”executing (Bool).
Publishes to ”goal” (geometry msgs.msg.PoseStamped).
If a task is not being executed, then, retrieve relative distance vectors to the rest of the swarm,
and try to maintain a pre-set distance to everyone using potential fields (cubic force function).
B.2
Task-allocation
B.2.1
Custom message types
• task
string sender
uint32 id
time stamp
uint32 parent
uint32[] childs
bool metatask
float32 weigth
int32 posx
int32 posy
int32 posz
• taskstatus
string sender
uint32 id
time stamp
string status
string owner
• bid
string sender
uint32 id
time stamp
uint32 auction
uint32 bid
B.2.2
Custom service type
B.2.3
Tasking
Subscribe to ”task” (task) and ”/Biddingstate” (String).
Publishes to none.
This is a library that runs inside both the bidding and auctioning process. It’s responsible for
processing and organising tasks and metatasks, as well as keeping track of a time synchronised
state such that bids are sent and processed in a timely manner.
B.2.4
Biddingstate
Subscribe to none.
Publishes to ”/Biddingstate” (String).
This process sets bidding states globally. It is meant to be convenient during simulation as it
broadcasts to all agents and would need replacement in case of real application.
B.2.5
Bidding
Subscribe to ”taskstatus” (taskstatus) ”odom” (nav msgs.msg.Odometry).
Publishes to ”bidd” (bid) and ”plan” (Int32).
Provide service: ”CostToSell” (cost).
This process keeps track of what simple tasks are available on the market and place bids as described
in the setup section. It also decides what order simple tasks are to be executed and outputs the
first one on the list. It also provides a service in order to answer how the removal of a task from
curent plan would affect utility.
If a task has been recently been removed from the current plan due to authority, this process will
make one attempt of placing a bid in order to challenge the decision.
B.2.6
Auction
Subscribe to ”bidd” (bid) and ”in/bidd” (bid).
Publishes to ”sugestion” (taskstatus) and ”out/bidd” (bid).
Uses service: ”CostToSell” (cost)
This process keeps track of all bids for simple tasks and assigns them to each winner. Outputs
decisions to authority check.
It may also put an assigned task back on market if it has been assigned to the agent its running
on, when it receives a bid that exceeds the value returned by ”CostToSell”.
This process also relays any bid that may have a chance of winning. This is done in order to save
bandwidth and keep other swarm members informed of relevant bids.
B.3
Pagerank/Trust
B.3.1
Custom message types
• idval String ”.idnum” and float32 ”.value”
• idval array - Contains sender id as string ”.id” and an array of idval as ”.data”
B.3.2
Trust
Subscribes to: ”Reward” (idval), ”in/TrustTables” (idval array), ”TrustTable common” (idval array).
Publishes to: ”TrustTable” (idval array).
Parameters: ’RewardExpiration’ (default: 30), ”external contact timeout” (default: 5)
B.3.3
Mypagerank
Subscribe to ”in/TrustTable” (idval array).
Publishes to ”MyPagerank” (Float32).
Calculates local Pagerank.
B.3.4
TrustTimesPagerank
Subscribe to ”MyPagerank” (int32), ”TrustTable” (idval array).
Publishes to ”out/TrustTable” (idval array).
C
Code
C.1
Testing tools
C.1.1
analysebag.py
# −∗− c o d i n g : u t f −8 −∗− ””” C r e a t e d on Wed Nov 23 1 5 : 2 2 : 3 9 2016 @author : r a g n a r ””” i m p o r t r o s b a g i m p o r t math i m p o r t m a t p l o t l i b . p y p l o t a s p l t t e s t =’ t e s t 4 ’ b a g s f o l d e r p a t h = ’/home/ r a g n a r / . r o s / b a g s / ’ f i l e p a t h=b a g s f o l d e r p a t h+t e s t + ’ . bag ’ s a v e p a t h = ’/home/ r a g n a r / Dropbox / t h e s i s / r a p p o r t / f i g u r e s / t e s t i n g / ’ d e f E x t r a c t D a t a ( TopicName , Namespaces , BAG, Data=True ) :Time={} Value ={} T o p i c L i s t = [ ] f o r n i n Namespaces : T o p i c L i s t . append ( ’ / ’ + n+ ’/ ’+ TopicName ) p r i n t T o p i c L i s t f o r t o p i c , msg , t i n BAG. r e a d m e s s a g e s ( T o p i c L i s t ) : i f t o p i c n o t i n Time : Time [ t o p i c ] = [ ] Value [ t o p i c ] = [ ] Time [ t o p i c ] . append ( t . s e c s ) i f Data : Value [ t o p i c ] . append ( msg . d a t a ) e l s e : Value [ t o p i c ] . append ( msg ) r e t u r n Time , Value #%% d e f p r i n t D a t a ( TopicName , namespace ) : w i t h r o s b a g . Bag ( f i l e p a t h ) a s bag :
, d a t a=E x t r a c t D a t a ( TopicName , namespace , bag , Data=F a l s e ) r e t u r n d a t a #f o r d i n d a t a [ ’ / ’ + namespace + ’/ ’+ TopicName ] : #p r i n t ”−−−” #p r i n t d #%% #p r i n t D a t a ( ” T r u s t T a b l e ” , [ ” r o b o t 2 ” ] ) #%% Agents =[”BASE” , ” r o b o t 1 ” , ” r o b o t 2 ” , ” r o b o t 3 ” ] w i t h r o s b a g . Bag ( f i l e p a t h ) a s bag : t o p i c s = bag . g e t t y p e a n d t o p i c i n f o ( ) [ 1 ] . k e y s ( )
PageRankTime , PageRankValue=E x t r a c t D a t a ( ’ MyPagerank ’ , Agents , bag )
TaskStatusTime , T a s k S t a t u s V a l u e=E x t r a c t D a t a ( ’ t a s k s t a t u s ’ , Agents , bag , F a l s e )
P o s i t i o n T i m e , P o s i t i o n V a l u e=E x t r a c t D a t a ( ’ odom ’ , [ ” r o b o t 1 ” , ” r o b o t 2 ” , ” r o b o t 3 ” ] , bag , F a l s e ) p r i n t ”Done ! ”
#%%
f o r key i n PageRankTime . i t e r k e y s ( ) :
p l t . p l o t ( PageRankTime [ key ] , PageRankValue [ key ] , l a b e l=key ) p l t . l e g e n d ( b b o x t o a n c h o r = ( 0 . , 1 . 0 2 , 1 . , . 1 0 2 ) , l o c =3 , n c o l =2 , mode=”expand ” , b o r d e r a x e s p a d = 0 . ) l g d=p l t . l e g e n d ( b b o x t o a n c h o r = ( 0 . , 1 . 0 2 , 1 . , . 1 0 2 ) , l o c =3 , n c o l =2 , mode=”expand ” , b o r d e r a x e s p a d = 0 . ) p l t . s a v e f i g ( s a v e p a t h+t e s t + ’/ p a g e r a n k . png ’ , b b o x e x t r a a r t i s t s =( l g d , ) , b b o x i n c h e s =’ t i g h t ’ ) p l t . c l f ( ) p l t . c l o s e ( ) #%%