Close

Computer Control Verified and Working

A project log for Stubby the (Teaching) Hexapod

100% open source robot platform with accessability and affordability in mind: teaching children of all ages about robots & programming

the-big-oneThe Big One 07/28/2014 at 21:430 Comments

After a number of very busy days where I was unable to work on Stubby at all, I have finally found enough time to hook up the Bluetooth radio and verify that everything works.  So far, I only am emulating the Universal Controller's protocol (which, BTW, works very well; I may actually write up a simple computer-based controller which lets you use a keyboard to control it rather than relying on a separate physical controller).  

The proof of concept code is below: simply put, it turns Stubby on (hits the "Start" PS2 button), moves forward for one second, backwards for one second, stops for a second, and then turns Stubby off again.

#!/usr/bin/env python2.6
#
# Simple POC for computer controlled Stubby movement
#
###################


import serial, sys
from time import sleep


ser = serial.Serial("/dev/tty.Stubby-DevB", 38400)


ser.write("\x93")		#Start (to begin)

#Reset all analog controls (not strictly needed)
ser.write("\x0F")		#Left X to neutral
ser.write("\x2F")		#Left Y to neutral
ser.write("\x4F")		#Right X to neutral
ser.write("\x6F")		#Right Y to neutral
sleep(0.01)

#Movement
ser.write("\x20")		#Forward
ser.write("\x10")		#Left X to neutral
sleep(1)
ser.write("\x3F")		#Backward
ser.write("\x10")		#Left X to neutral
sleep(1)

#Stop
ser.write("\x0F")		#Left X to neutral
ser.write("\x2F")		#Left Y to neutral
sleep(1)

ser.write("\x93")		#Start (to end)

Discussions