!date
lundi 6 novembre 2017, 10:11:00 (UTC+0100)
Trajectory and Network simulation¶
from IPython.display import Image, HTML, Latex, YouTubeVideo
import numpy as np
import pylayers.mobility.trajectory as traj
from pylayers.mobility.ban.body import *
from pylayers.gis.layout import *
%matplotlib inline
YouTubeVideo('1Qa6xLpU5-M')
Trajectories can be generated using simulnet.
from pylayers.simul.simulnet import *
S=Simul()
Warning Unable to read graph Gr
Warning Unable to read graph Gw
Layout graphs are loaded from /home/uguen/Bureau/P1/struc/ini
# set simulation duration
S.sim_opt['duration']='100'
S.meca_opt['mecanic_update_time']=0.1
# turn on network simulation
S.net_opt['network']=True
# run mechanical simulation
S.runsimul()
Trajectory¶
trajectories can be imported from a simulnet simulation with the
importh5
method
from pylayers.mobility.trajectory import *
str1 = eval(S.sim_opt['filename'])
str2 = S.L._filename.split('.')[0]
save_filename = str1 + '_' + str2 +'.h5'
list_traj = S.traj
list_traj
Trajectories performed in Layout : TA-Office.lay Trajectory of agent John with ID 1 ---------------------------------- t (s) : 0.00 : 0.20 : 99.80 dtot (m) : 371.86 Vmoy (m/s) : 3.73 x y vx vy ax t 1970-01-01 00:00:00.000 2.704137 2.529231 0.020684 0.158657 0.103419 1970-01-01 00:00:00.200 2.711583 2.586348 0.037231 0.285583 0.082735 ay s t 1970-01-01 00:00:00.000 0.793287 0.160 1970-01-01 00:00:00.200 0.634630 0.448 Trajectory of agent Alex with ID 2 ---------------------------------- t (s) : 0.00 : 0.20 : 99.80 dtot (m) : 144.40 Vmoy (m/s) : 1.45 x y vx vy ax t 1970-01-01 00:00:00.000 38.907408 2.071490 -0.059739 0.148429 -0.298696 1970-01-01 00:00:00.200 38.885901 2.124925 -0.107531 0.267172 -0.238957 ay s t 1970-01-01 00:00:00.000 0.742146 0.160 1970-01-01 00:00:00.200 0.593717 0.448 Access point Router with ID 6 ----------------------------- t (s) : 0.00 Vmoy (m/s) : 0.0 x y z vx vy ax ay s t 1970-01-01 0.5 2.0 2.5 0.0 0.0 0.0 0.0 0.0 Access point Router with ID 7 ----------------------------- t (s) : 0.00 Vmoy (m/s) : 0.0 x y z vx vy ax ay s t 1970-01-01 0.7 14.0 2.5 0.0 0.0 0.0 0.0 0.0 Access point Router with ID 8 ----------------------------- t (s) : 0.00 Vmoy (m/s) : 0.0 x y z vx vy ax ay s t 1970-01-01 39.0 13.0 2.5 0.0 0.0 0.0 0.0 0.0
The 2 following trajectories have been calculated with
pylayers.simul.simulnet
t=S.traj.resample(10)
f=plt.figure(figsize=(20,20))
f,a = S.L.showG('s',fig=f)
for k,nodes in enumerate(t):
f,a = nodes.plot(fig=f,ax=a)
S
Simulation information
----------------------
Layout: TA-Office.lay
Simulation duration: 100
Random seed: 1
Save simulation: False
Update times
-------------
Mechanical update: 0.1
Network update: 0.1
Localization update: 'autonomous'
Agents => self.lAg[i]
------
Number of agents :5
Agents IDs: ['1', '2', '6', '7', '8']
Agents names: ['John', 'Alex', 'Router', 'Router', 'Router']
Destination of chosen agents: 'random'
Network
-------
Nodes per wstd: {}
Localization
------------
Localization enable: False
Postion estimation methods: ['geo']