Last active
July 16, 2016 01:12
-
-
Save xaxxontech/7537a5646666bf63eaceb663cb3140e4 to your computer and use it in GitHub Desktop.
Track wheel encoder cumulative distance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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