| Trees | Indices | Help |
|
|---|
|
|
1 #!/bin/env python
2
3 """Road width example: walking on roads having a width depending on OSM data
4 - random movement
5 - demonstrates the different road width types
6 - try road types by (un)commenting
7 - test with special width test map and minimap3
8 - output to visual player, which is executed as child process
9 """
10
11 import sys
12 sys.path.append("..")
13
14 from mosp.core import Simulation, Person
15 from mosp.geo import osm
16 from mosp.impl import movement
17 from mosp.monitors import ChildprocessPlayerChamplainMonitor, SocketPlayerMonitor
18
19 __author__ = "B. Henne"
20 __contact__ = "henne@dcsec.uni-hannover.de"
21 __copyright__ = "(c) 2011, DCSec, Leibniz Universitaet Hannover, Germany"
22 __license__ = "GPLv3"
23
24
26 """Implements a simple person doing only random movement on the map.
27 @author: B. Henne"""
28 next_target = movement.person_next_target_random
29
30
32 """Shows the different osm.ROADTYPE implementations.
33
34 Different road width types can be tested here. Use minimap3 to show the
35 walking side by side and RoadWidthTest map for osm data with width values."""
36
37 #osm.ROADTYPE = osm.ROADTYPE_NODIMENSION # road width = 0
38 osm.ROADTYPE = osm.ROADTYPE_ONEWAY_NOSIDEWALK # road width = width from the middle of road to the right in walking direction (as int)
39 #osm.ROADTYPE = osm.ROADTYPE_TWOWAY_NOSIDEWALK # road width = 2xwidth from the left of the road to the right both directions lanes (as int)
40 #osm.ROADTYPE = osm.ROADTYPE_ONEWAY_ONSIDEWALK # no movement on street, but only on sidewalk (as list [road width per direction, sidewalk width+road width per direction]
41
42 osm.ROADWIDTH_DEFAULTS = osm.ROADWIDTH_DEFAULTS # stores width default of different highway types, used if tag (approx_)width is not set
43 #osm.ROADWIDTH_DEFAULTS['footway'] = [3,5] # set default width of highway=footway, must correspond to above ROADTYPE (here: list) - example for *ONSIDEWALK
44 osm.ROADWIDTH_DEFAULTS['footway'] = 3 # set default width of highway=footway, must correspond to above ROADTYPE (here: int) - example for all the others
45
46 # demo map with different road widths in osm data
47 #s = Simulation(geo=osm.OSMModel('../data/RoadWidthTest.osm'), rel_speed=40)
48 # simple demo map to see walking side by side
49 s = Simulation(geo=osm.OSMModel('../data/minimap3.osm'), rel_speed=20)
50 #m = s.add_monitor(ChildprocessPlayerChamplainMonitor, 2)
51 m = s.add_monitor(SocketPlayerMonitor, 2)
52 s.add_persons(RandomWiggler, 2, monitor=m)
53 [p for p in s.persons][0].set_speed(1.8) # if people move in same direction, one should be faster to see them passing each other
54 s.run(until=10000, real_time=True, monitor=True)
55
56
57 if __name__ == '__main__':
58 main()
59
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Jul 6 13:59:55 2014 | http://epydoc.sourceforge.net |