Ant with random steering
This commit is contained in:
parent
8325988334
commit
77a7153675
@ -143,6 +143,7 @@ class PoseMsg(IMessage):
|
|||||||
self.networkId = networkId
|
self.networkId = networkId
|
||||||
self.thingId = thing.id
|
self.thingId = thing.id
|
||||||
|
|
||||||
|
poseType = 0x0F # unity server currently requires position and orientation
|
||||||
self.poseType = poseType
|
self.poseType = poseType
|
||||||
self.position = Spherical.zero
|
self.position = Spherical.zero
|
||||||
self.orientation = Quaternion.identity
|
self.orientation = Quaternion.identity
|
||||||
|
23
SiteServer.py
Normal file
23
SiteServer.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from .Participant import Participant
|
||||||
|
from .Thing import Thing
|
||||||
|
from . import Messages
|
||||||
|
|
||||||
|
import select
|
||||||
|
|
||||||
|
class SiteServer(Participant):
|
||||||
|
def __init__(self, ipAddress, port):
|
||||||
|
super().__init__(ipAddress, port)
|
||||||
|
self.udpSocket.setblocking(0)
|
||||||
|
|
||||||
|
def Update(self, currentTime):
|
||||||
|
ready_to_read, _, _ = select.select([self.udpSocket], [], [], 0.1) # Timeout of 0.1 seconds
|
||||||
|
if ready_to_read:
|
||||||
|
data, addr = self.udpSocket.recvfrom(1024)
|
||||||
|
self.ReceiveData(data)
|
||||||
|
|
||||||
|
return super().Update(currentTime)
|
||||||
|
|
||||||
|
def ProcessNetworkIdMsg(self, msg):
|
||||||
|
self.networkId = msg.networkId
|
||||||
|
msg = Messages.ThingMsg(self.networkId, next(iter(Thing.allThings)))
|
||||||
|
msg.SendTo(self)
|
4
Thing.py
4
Thing.py
@ -9,7 +9,7 @@ class Thing:
|
|||||||
self.modelUrl = None
|
self.modelUrl = None
|
||||||
Thing.Add(self)
|
Thing.Add(self)
|
||||||
|
|
||||||
def Update(self, currentTime):
|
def update(self, currentTime):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -19,4 +19,4 @@ class Thing:
|
|||||||
|
|
||||||
def UpdateAll(currentTime):
|
def UpdateAll(currentTime):
|
||||||
for thing in Thing.allThings:
|
for thing in Thing.allThings:
|
||||||
thing.Update(currentTime)
|
thing.update(currentTime)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
__all__ = ['Direction', 'Spherical', 'Thing', 'Participant', 'Messages']
|
__all__ = ['Direction', 'Spherical', 'Thing', 'Participant', 'Messages', 'SiteServer']
|
||||||
|
|
||||||
from .Direction import Direction
|
from .Direction import Direction
|
||||||
from .Participant import Participant
|
from .Participant import Participant
|
||||||
from .Thing import Thing
|
from .Thing import Thing
|
||||||
from .Spherical import Spherical
|
from .Spherical import Spherical
|
||||||
|
from .SiteServer import SiteServer
|
Loading…
x
Reference in New Issue
Block a user