urcontrol/urosc/oscsend.py

32 lines
No EOL
900 B
Python

from helpfunctions import *
class OSCSend:
from pythonosc import udp_client
def __init__(self,_frequency_oscsend=50):
self.oscreceivers = []
self.frequency_oscsend=_frequency_oscsend
self.last_sendosc=0
def setupReceivers(self,serverips,port):
self.oscreceivers = []
# Set up OSC client
for cip in serverips:
print("connecting to "+str(cip))
connection = self.udp_client.SimpleUDPClient(cip, port)
self.oscreceivers.append(connection)
def send(self,looptime,q):
if looptime-self.last_sendosc<1.0/self.frequency_oscsend:
return
self.last_sendosc=looptime
for c in self.oscreceivers:
for jointi,joint in enumerate(q):
c.send_message("/j"+str(jointi), toDeg(joint))