1

I am working with a high refresh rate IMU (x-IO technologies NGIMU) which outputs all data in osc format. The manufacturer provides the following python script to serve the data on linux platforms ( I am running Ubuntu 16.04)

'''
NGIMU Demo python v2.7 script written by Tom Mitchell (teamxe.co.uk) 2016
Requires pyOSC https://trac.v2.nl/wiki/pyOSC
'''

import socket, OSC, threading, time

# Change this to the NGIMU IP address
send_address = '192.168.1.1', 9000

# Set the NGIMU to send to this machine's IP address
c = OSC.OSCClient()
c.connect(send_address)
msg = OSC.OSCMessage()
msg.setAddress('/wifi/send/ip')
msg.append(str(socket.gethostbyname(socket.gethostname())))
c.send(msg)
c.close()

# Set up receiver
receive_address = '192.168.1.2', 8000
s = OSC.OSCServer(receive_address)
s.addDefaultHandlers()

def sensorsHandler(add, tags, args, source):
    print add + str(args)

def quaternionHandler(add, tags, args, source):
    print add + str(args)

def batteryHandler(add, tags, args, source):
    print add + str(args)

# Add OSC handlers
s.addMsgHandler("/sensors", sensorsHandler)
s.addMsgHandler("/quaternion", quaternionHandler)
s.addMsgHandler("/battery", batteryHandler)

# Start OSCServer
print "\nUse ctrl-C to quit."
st = threading.Thread(target = s.serve_forever)
st.start()

# Loop while threads are running
try :
    while 1 :
        time.sleep(10)

except KeyboardInterrupt :
    print "\nClosing OSCServer."
    s.close()
    print "Waiting for Server-thread to finish"
    st.join()
    print "Done"

The IMU hosts its own network which I connect to with the computer that is to receieve the data. I have installed pyOSC from the location referenced in the script. When I run the script, no data is delivered, only the message "Use ctrl-C to quit". All connections seem to take place properly. When the script is running, I can see the udp connection at the correct ip and port using the Ubuntu firewall configuration gui. I have tried disabling the firewall but that had no effect. Separately, I have used another computer to send udp packets to that ip and port and confirmed their receipt. To say that I am a coding novice is far too generous. Nonetheless, I need to get this script running. Any help you can offer is greatly appreciated.

1 Answers1

0

The problem is that

socket.gethostbyname(socket.gethostname())

is not setting the correct IP. You should change to

msg.setAddress('/wifi/send/ip')
msg.append('192.168.1.2')
crow
  • 305
  • 4
  • 13