Skip to content

Instantly share code, notes, and snippets.

@xaxxontech
Last active July 16, 2016 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xaxxontech/7537a5646666bf63eaceb663cb3140e4 to your computer and use it in GitHub Desktop.
Save xaxxontech/7537a5646666bf63eaceb663cb3140e4 to your computer and use it in GitHub Desktop.
Track wheel encoder cumulative distance
#!/usr/bin/env python
import oculusprimesocket
import atexit
def cleanup():
oculusprimesocket.sendString("odometrystop")
atexit.register(cleanup)
oculusprimesocket.connect()
oculusprimesocket.sendString("odometrystart")
totaldistance = 0
while True:
s = oculusprimesocket.waitForReplySearch("<state> distanceangle").split()
if len(s)==4:
distance = float(s[2])/1000
if distance > 0:
totaldistance += distance
msg = "messageclients "+str(totaldistance)+"m"
oculusprimesocket.sendString(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment