README
This commit is contained in:
parent
602d7a2096
commit
c3d70b4c76
33
README.md
33
README.md
@ -1,16 +1,41 @@
|
||||
# Intelligent Roundabout Efficient Simulation of Traffic Evolution
|
||||

|
||||
|
||||
## Installation :
|
||||
|
||||
## Installation : \
|
||||
```
|
||||
git clone https://gitlab.univ-nantes.fr/E208835U/Traffic.git
|
||||
pip install sumolib
|
||||
pip install pyside6 (optionnel pour l'ui)
|
||||
```
|
||||
|
||||
## Usage :
|
||||
|
||||
## Usage : \
|
||||
```
|
||||
python main.py
|
||||
```
|
||||
|
||||
Le programme utilise les fichier .net.xml et .rou.xml générés par [Eclipse SUMo](https://www.eclipse.org/sumo/)
|
||||
|
||||
File>Open>Open Network (pour un ficher *.net.xml)\
|
||||
File>Open>Open Vehicles (pour le fichier *.rou.xml associé)
|
||||
|
||||
gamma/delta/T : variables de comportement\
|
||||
dt : pas de temps de la simulation\
|
||||
fps : vitesse de l'affichage (i/s), delai entre chaque maj de l'affichage (ms)\
|
||||
Physics fps : vitesse de la simulation (u/s), delai entre chaque maj de la simulation (ms)\
|
||||
Start/Stop : arrêter/redémarrer la simulation\
|
||||
|
||||
|
||||
Raccourcis clavier : \
|
||||
```
|
||||
Esc/Q : quitter
|
||||
G : démarrer la simulation
|
||||
E : Met le delai de maj de la simulation à 0 (vitesse maximum)
|
||||
D : Met le delai de maj de la simulation à 17 (vitesse normale)
|
||||
F : Met le delai de maj de la simulation à 500 (vitesse ralentie)
|
||||
C : Met le pas de simulation à 0.3s (accéléré, au dépent de la qualité)
|
||||
P : Met le pas de simulation à 1/60 (valeur par défaut)
|
||||
0-9 : Charge les réseaux prédéfinis
|
||||
```
|
||||
|
||||
## Interface python
|
||||
La simulation peut aussi être executée sans interface (voir [runAllNetworks.py](runAllNetxorks.py) et [blender_import.py](blender_import.py) pour des exemples)
|
||||
|
74
blender_import.py
Normal file
74
blender_import.py
Normal file
@ -0,0 +1,74 @@
|
||||
import sys, os, bpy, math
|
||||
from random import randint
|
||||
directory = os.path.dirname(bpy.data.filepath)
|
||||
path = "./Traffic" # path to projects files
|
||||
sys.path.append(path)
|
||||
|
||||
from CarController import CarController
|
||||
from Map import Map
|
||||
|
||||
m = Map()
|
||||
cc = CarController(m)
|
||||
|
||||
m.fromPath(path+"/rdpt_polytech_fixed.net.xml")
|
||||
cc.fromPath(path+"/rdpt_polytech_burst_moy.rou.xml")
|
||||
cc.prepareRoute()
|
||||
|
||||
def createLane(pts):
|
||||
crv = bpy.data.curves.new("crv", "CURVE")
|
||||
crv.dimensions = "3D"
|
||||
spline = crv.splines.new(type = "POLY")
|
||||
spline.points.add(len(pts)-1)
|
||||
for p, np in zip(spline.points, pts):
|
||||
p.co = list(np) + [0,1]
|
||||
p.tilt = math.pi/2
|
||||
spline.use_endpoint_u = True
|
||||
crv.extrude = 1
|
||||
#crv.bevel_depth = 2
|
||||
obj = bpy.data.objects.new("test_curve", crv)
|
||||
return obj
|
||||
|
||||
def createNet():
|
||||
netCollection = bpy.data.collections.new("gen_net")
|
||||
bpy.context.collection.children.link(netCollection)
|
||||
for edge in m.net.getEdges():
|
||||
for lane in edge.getLanes():
|
||||
obj = createLane(lane.getShape())
|
||||
netCollection.objects.link(obj)
|
||||
|
||||
coll_names = ["gen_cars","gen_net"]
|
||||
coll_names = filter(lambda n: n in bpy.data.collections ,coll_names)
|
||||
gen_coll = [bpy.data.collections[n] for n in coll_names]
|
||||
print(gen_coll)
|
||||
bpy.ops.object.delete({"selected_objects": gen_coll})
|
||||
|
||||
createNet()
|
||||
ref_car = bpy.data.objects["Car.001"]
|
||||
carsCollection = bpy.data.collections.new("gen_cars")
|
||||
bpy.context.collection.children.link(carsCollection)
|
||||
cars = {}
|
||||
|
||||
for i in range (0,6000):
|
||||
cc.update()
|
||||
|
||||
bpy.context.scene.frame_set(round(cc.t*96))
|
||||
|
||||
for ind,car in enumerate(cc.cars):
|
||||
obj_id = car.id#f"Car.{ind:03d}"
|
||||
carObj = None
|
||||
if obj_id in cars:
|
||||
carObj = cars[obj_id]
|
||||
else:
|
||||
randCarInd = randint(1,17)
|
||||
refCar = bpy.data.objects[f"Car.{randCarInd:03d}"]
|
||||
carObj = refCar.copy()
|
||||
carObj.name = obj_id
|
||||
print(carObj.name, obj_id)
|
||||
carObj.data = refCar.data.copy()
|
||||
carObj.animation_data_clear()
|
||||
carsCollection.objects.link(carObj)
|
||||
cars[obj_id] = carObj
|
||||
carObj.location = car.pos + [0]
|
||||
carObj.rotation_euler = (0,0,car.dir)
|
||||
carObj.keyframe_insert(data_path = "location")
|
||||
carObj.keyframe_insert(data_path = "rotation_euler")
|
Loading…
x
Reference in New Issue
Block a user