This commit is contained in:
leo 2022-02-26 12:28:53 +01:00
parent b6f4b22bd2
commit 237bf6c2b9
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB
5 changed files with 206 additions and 1 deletions

20
Car.py
View File

@ -1,5 +1,6 @@
import sumolib
from math import dist
from math import dist, ceil
from random import randint
from PySide6.QtGui import QPainter
from PySide6.QtCore import QPointF, Signal, QObject
@ -55,6 +56,8 @@ class Car():
self.b=20
self.vmax=0
self.vroom = 0
self.signals.updateDisp.emit(("Position",self.pos))
self.signals.updateDisp.emit(("Vitesse",self.v))
@ -129,6 +132,18 @@ class Car():
def draw(self,painter):
pt = QPointF(*self.pos)
painter.drawEllipse(pt,3,3)
if self.vroom != 0:
painter.save()
d=(60-self.vroom)*0.2
painter.translate(pt + QPointF(0,d))
painter.scale(1,-1)
font = painter.font();
font.setPixelSize(ceil(self.vroom*0.2));
painter.setFont(font)
painter.drawText(QPointF(0,0),"vroom")
self.vroom -= 1
painter.restore()
#painter.drawEllipse(pt,100,100)
def conduite(self,vmax,leader,dt):
@ -181,3 +196,6 @@ class Car():
self.signals.updateDisp.emit(("Position", self.pos))
self.signals.updateDisp.emit(("Vitesse", self.v))
self.signals.updateDisp.emit(("Leader", self.leader if self.leader is None else f"{self.leader.id} @ {self.leaderDist:.2f}m"))
if randint(0,100) == 0:
self.vroom = 60

50
test3.net.xml Normal file
View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated on 2022-02-22 14:24:45 by Eclipse SUMO netedit Version 1.10.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd">
<output>
<output-file value="/home/leo/confPeip/test/test3.net.xml"/>
</output>
<processing>
<offset.disable-normalization value="true"/>
</processing>
<junctions>
<no-turnarounds value="true"/>
</junctions>
<report>
<aggregate-warnings value="5"/>
</report>
</configuration>
-->
<net version="1.9" junctionCornerDetail="5" limitTurnSpeed="5.50" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd">
<location netOffset="0.00,0.00" convBoundary="-22.37,52.89,140.67,54.43" origBoundary="10000000000.00,10000000000.00,-10000000000.00,-10000000000.00" projParameter="!"/>
<edge id=":gneJ1_0" function="internal">
<lane id=":gneJ1_0_0" index="0" speed="13.89" length="0.30" shape="77.11,51.53 77.41,51.53"/>
</edge>
<edge id="gneE0" from="gneJ0" to="gneJ1" priority="-1">
<lane id="gneE0_0" index="0" speed="13.89" length="99.51" shape="-22.39,52.83 77.11,51.53"/>
</edge>
<edge id="gneE1" from="gneJ1" to="gneJ2" priority="-1">
<lane id="gneE1_0" index="0" speed="13.89" length="63.26" shape="77.41,51.53 140.67,51.29"/>
</edge>
<junction id="gneJ0" type="dead_end" x="-22.37" y="54.43" incLanes="" intLanes="" shape="-22.37,54.43 -22.41,51.23"/>
<junction id="gneJ1" type="priority" x="77.27" y="53.13" incLanes="gneE0_0" intLanes=":gneJ1_0_0" shape="77.41,53.13 77.40,49.93 77.09,49.93 77.13,53.13">
<request index="0" response="0" foes="0" cont="0"/>
</junction>
<junction id="gneJ2" type="dead_end" x="140.67" y="52.89" incLanes="gneE1_0" intLanes="" shape="140.66,49.69 140.67,52.89"/>
<connection from="gneE0" to="gneE1" fromLane="0" toLane="0" via=":gneJ1_0_0" dir="s" state="M"/>
<connection from=":gneJ1_0" to="gneE1" fromLane="0" toLane="0" dir="s" state="M"/>
</net>

54
test4.net.xml Normal file
View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated on 2022-02-22 16:03:30 by Eclipse SUMO netedit Version 1.10.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd">
<output>
<output-file value="/home/leo/confPeip/test/test4.net.xml"/>
</output>
<processing>
<offset.disable-normalization value="true"/>
</processing>
<junctions>
<no-turnarounds value="true"/>
</junctions>
<netedit>
<route-files value="/home/leo/confPeip/test/test7.rou.xml"/>
</netedit>
<report>
<aggregate-warnings value="5"/>
</report>
</configuration>
-->
<net version="1.9" junctionCornerDetail="5" limitTurnSpeed="5.50" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd">
<location netOffset="0.00,0.00" convBoundary="-440.38,-61.24,1069.13,-53.04" origBoundary="10000000000.00,10000000000.00,-10000000000.00,-10000000000.00" projParameter="!"/>
<edge id=":gneJ1_0" function="internal">
<lane id=":gneJ1_0_0" index="0" speed="24.95" length="0.23" shape="1045.41,-61.81 1045.63,-61.82"/>
</edge>
<edge id="gneE0" from="gneJ0" to="gneJ1" priority="-1">
<lane id="gneE0_0" index="0" speed="36.00" length="1485.81" shape="-440.39,-54.64 1045.41,-61.81"/>
</edge>
<edge id="gneE1" from="gneJ1" to="gneJ2" priority="-1">
<lane id="gneE1_0" index="0" speed="13.89" length="23.45" shape="1045.63,-61.82 1069.06,-62.83"/>
</edge>
<junction id="gneJ0" type="dead_end" x="-440.38" y="-53.04" incLanes="" intLanes="" shape="-440.38,-53.04 -440.40,-56.24"/>
<junction id="gneJ1" type="priority" x="1045.56" y="-60.21" incLanes="gneE0_0" intLanes=":gneJ1_0_0" shape="1045.70,-60.22 1045.56,-63.41 1045.40,-63.41 1045.41,-60.21">
<request index="0" response="0" foes="0" cont="0"/>
</junction>
<junction id="gneJ2" type="dead_end" x="1069.13" y="-61.24" incLanes="gneE1_0" intLanes="" shape="1068.99,-64.43 1069.13,-61.24"/>
<connection from="gneE0" to="gneE1" fromLane="0" toLane="0" via=":gneJ1_0_0" dir="s" state="M"/>
<connection from=":gneJ1_0" to="gneE1" fromLane="0" toLane="0" dir="s" state="M"/>
</net>

50
test6.rou.xml Normal file
View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated on 2022-02-22 14:35:53 by Eclipse SUMO netedit Version 1.10.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd">
<input>
<sumo-net-file value="/home/leo/confPeip/test/test3.net.xml"/>
</input>
<output>
<output-file value="/home/leo/confPeip/test/test3.net.xml"/>
</output>
<processing>
<geometry.min-radius.fix.railways value="false"/>
<geometry.max-grade.fix value="false"/>
<offset.disable-normalization value="true"/>
<lefthand value="false"/>
</processing>
<junctions>
<no-turnarounds value="true"/>
<junctions.corner-detail value="5"/>
<junctions.limit-turn-speed value="5.5"/>
<rectangular-lane-cut value="false"/>
</junctions>
<pedestrian>
<walkingareas value="false"/>
</pedestrian>
<netedit>
<route-files value="/home/leo/confPeip/test/test6.rou.xml"/>
</netedit>
<report>
<aggregate-warnings value="5"/>
</report>
</configuration>
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<vehicle id="vehicle_0" depart="0.00">
<route edges="gneE0 gneE1" color="cyan"/>
</vehicle>
<vehicle id="vehicle_1" depart="0.00">
<route edges="gneE0 gneE1" color="cyan"/>
</vehicle>
</routes>

33
test7.rou.xml Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated on 2022-02-22 15:24:16 by Eclipse SUMO netedit Version 1.10.0
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netconvertConfiguration.xsd">
<output>
<output-file value="/home/leo/confPeip/test/test4.net.xml"/>
</output>
<processing>
<offset.disable-normalization value="true"/>
</processing>
<junctions>
<no-turnarounds value="true"/>
</junctions>
<netedit>
<route-files value="/home/leo/confPeip/test/test7.rou.xml"/>
</netedit>
<report>
<aggregate-warnings value="5"/>
</report>
</configuration>
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<vehicle id="vehicle_0" depart="0.00">
<route edges="gneE0 gneE1" color="cyan"/>
</vehicle>
</routes>