Python HTDP Driver
Jump to navigation
Jump to search
A driver written in python as part of Google Summer of Code 2008.
The driver uses one or two wiimotes to track IR points and report their position in 3D space. Currenly it only works on Linux due to python bluetooth support on other platforms.
It has been designed with the aim of being easy to use and understand.
Example Program
import sys,time from final.Wiimote3dTracking import Wiimote3dTracker address1 = '00:19:FD:ED:E1:25' ## address of my wiimote address2 = '00:19:FD:D7:63:B1' ## address of my second wiimote ## These could be passed to tracker to connect to them specifically, but ## specifying no addresses causes the tracker to search for remotes anyway. tracker = Wiimote3dTracker(address1,address2) ## A tracker has the following methods: ## connect() -- connects to any wiimotes it knows the address for ## disconnect() -- quite similar to connect. ## ## register( listener ) ## refresh() ## a listener is anything that has a refresh(pos ,axis) method. When tracker.register( newListener ) ## is called, newLitener is added to the list of trackers current listeners. Upon calling ## tracker.refresh() refresh( pos, axis) is called for each of the registered listeners, ## where pos and axis are the processed data from the wiimotes. tracker.connect() ##Connect to the wiimote class Printer: ## This is an example of a listener. Its refresh method simply prints the data ## if it has changed, and returns True to indicate success. def __init__(self): self.oldData = None def refresh(self,(x1,y1,z1),(x2,y2,z2)): if (x1,y1,z1,x2,y2,z2) != self.oldData: print "x:%i,y:%i,z:%i,X:%i,Y:%i,Z:%i:1" % (x1,y1,z1,x2,y2,z2) self.oldData = (x1,y1,z1,x2,y2,z2) return True tracker.register( Printer() ) tracker.start() ## Starts the tracker running in a loop, calling tracker.refresh() each time.
It also includes support for sockets, allowing the data to be sent to any program that can listen to an open socket meaning that the driver is not restricted to python.
Requirements
Python, pybluez
Video
Here is a video of the project in action.