Based on the work I had done earlier in controlling the Robosapien and Roboquad from the PC, I just got quick program written that controls the ISO-bot from the PC.
This time instead of using my homebrew serial-IR box, I used John Rees’ very professional USB-UIRT box. His box ships with a dll and a couple of sample programs in c and basic.
I decided that I would put something together in python to call the dll. Now that ctypes is in Python 2.5, this is really pretty easy! I will no longer tremble in fear at interfacing dlls. (Maybe I can revisit the CUAnimate problem I had earlier)
Anyway, here is a quickie that drives the robot around. There is plenty more messing around to be done here in terms of timing and repeat rates, but it is bedtime.
his library handles dlls
from ctypes import *
## This will handle the keyboard input for now
from visual import *
##Attach the uuirtdrv.dll to irlib
irlib = windll.uuirtdrv
##Open the USB-UIRT and return the handle
irhandle = irlib.UUIRTOpen()
print irhandle
##These codes were found using the "Learn" mode on the USB-UIRT
##Forward
ForwardIRCode = "F3ER0FB9622714141427141414141427142714131427142714141427142714271414141414141414141414131427142714"
##Turn Left
TurnLeftIRCode = "F3ER1014622814141428131413281427132814141327142813271414141414281314131413141314131413141328142813"
##Sidestep Left
LeftIRCode = "F3ER0FB2622714141427142714141427142714141427142714271414142714271414141414141414141414141427142714"
##Turn Right
TurnRightIRCode = "F3ER0FC1622814141428132814141414142813141328142813281314132814141414141414141414141414141428132814"
##Sidestep Right
RightIRCode = "F3ER1015622714141428142814271414142814141427142814271428141414141414141414141414141414141428142714"
##Backward
BackwardIRCode = "F3ER0FCC622814141427131413281414142714141427142714271414141414141414131413141314131413141427142714"
go = 1
gIRCode = ForwardIRCode
##
## Main Loop
## Will wait for a key wasd and then send the appropriate IR output to the robot
## q will quit. NOTE the Visual window has to be active for this to work.
##
while (go==1):
if scene.kb.keys: # is there an event waiting to be processed?
s = scene.kb.getkey() # obtain keyboard information
if s == "w":
gIRCode = ForwardIRCode
if s == "a":
gIRCode = TurnLeftIRCode
if s=="d":
gIRCode = TurnRightIRCode
if s == "s":
gIRCode = BackwardIRCode
if s == "q":
go = 0
print gIRCode
irlib.UUIRTTransmitIR(irhandle,gIRCode,0,5,0,0,0,0)
print test
##Close the UUIRT, if you don't do this you will have to manually kill off the process
irlib.UUIRTClose(irhandle)
Here is some code for doing the code discovery:
from ctypes import * from visual import * display.visibile = 0 test = 0 irlib = windll.uuirtdrv irhandle = irlib.UUIRTOpen() print irhandle ##Forward gIRCode = "F3ER0FB9622714141427141414141427142714131427142714141427142714271414141414141414141414131427142714" print "Learning: Point the remote at the interface and wait until the light flashes" print irlib.UUIRTLearnIR(irhandle,0,gIRCode,0,0,0,0,0,0) print gIRCode irlib.UUIRTClose(irhandle)
Now to try to get this working from Roborealm.