Ant with random steering

This commit is contained in:
Pascal Serrarens 2024-12-21 14:58:38 +01:00
parent 8325988334
commit 77a7153675
4 changed files with 29 additions and 4 deletions

View File

@ -143,6 +143,7 @@ class PoseMsg(IMessage):
self.networkId = networkId
self.thingId = thing.id
poseType = 0x0F # unity server currently requires position and orientation
self.poseType = poseType
self.position = Spherical.zero
self.orientation = Quaternion.identity

23
SiteServer.py Normal file
View 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)

View File

@ -9,7 +9,7 @@ class Thing:
self.modelUrl = None
Thing.Add(self)
def Update(self, currentTime):
def update(self, currentTime):
pass
@staticmethod
@ -19,4 +19,4 @@ class Thing:
def UpdateAll(currentTime):
for thing in Thing.allThings:
thing.Update(currentTime)
thing.update(currentTime)

View File

@ -1,6 +1,7 @@
__all__ = ['Direction', 'Spherical', 'Thing', 'Participant', 'Messages']
__all__ = ['Direction', 'Spherical', 'Thing', 'Participant', 'Messages', 'SiteServer']
from .Direction import Direction
from .Participant import Participant
from .Thing import Thing
from .Spherical import Spherical
from .SiteServer import SiteServer