Thursday, April 25, 2013

Mechanical Turk Arm First Movement

The mechanical arm of the AWS Mechanical Turk powered chess playing Mechanical Turk is now built!

Here is the arm under manual control:

I chose the Lynxmotion AL5D robotic arm to provide a reasonable reach at an affordable price.  Moving plastic chess pieces does not require much torque, so I was able to avoid using the very capable but very expensive Dynamixel servos and instead used standard cheap RC servos.  Like many folks, I purchased only the AL5D hardware kit from Lynxmotion, and purchased the RC servos from the cheapest price on Amazon.

Building the AL5D took about four hours altogether.  My only serous complaint is that while the hardware is segregated to some extent in heat-sealed plastic bags, it still is often difficult for a novice to figure out which pieces of hardware is which (for example, 2-56 x .250" steel machine screw vs. #2 x .250" steel tapping screw vs. 3mm x 8mm steel screw).  It would be useful if every heat-sealed bag section had a piece of paper identifying the hardware in that section and perhaps which part of the instructions the hardware is associated with.

Also my HS-805BB servo (that I purchased from somewhere else besides Lynxmotion) came with a horn that was not quite compatible with the servo bracket.  It turns out that Lynxmotion does appear to pack a compatible horn in the kit, but somehow I missed that, so I drilled new holes in the existing horn.  Everything worked out anyway.

All of the controllers from Lynxmotion were overpriced or difficult to interface with a Raspberry Pi, so I chose the Pololu Micro Maestro 6-channel RC controller.  I have had great experiences with Pololu servo controllers in the past.  The Micro Maestro connects to a host via USB, and costs ~$20.  It also can provide some analog or digital input as well as serial output, so it is very function-packed for the price.

Two issues with the Pololu Micro Maestro - first, to use it with a Mac or Linux, you need to run the Maestro Control Center on a PC, and under the "Serial Settings" tab you should set the Serial mode to "USB Dual Port".  Then under "Channel Settings" you should open up the "Min" and "Max" settings for the arm servos to 500µs and 2500µs to assure you can move the Hitec servos a full 180 degrees.

If you are looking for info regarding inverse kinematics of the AL5D, see this blog entry.  Also great source code for full control of the Pololu Micro Maestro can be found here.

Finally, I wrote my first Tkinter program in Python to provide a manual GUI for the arm servo controls on a Mac:

Source code below:

# for more Pololu Micro Maestro interface code # see def setpos(cha,uS): """maestro uses is 0.25us increments """ pos=int(uS) pos=pos*4 low=pos&0x7f high=pos>>7 #print low,high # cmd, chan, low, high s.write(chr(0x84)+chr(cha)+chr(low)+chr(high)) def setpos0(uS): setpos(0,uS) def setpos1(uS): setpos(1,uS) def setpos2(uS): setpos(2,uS) def setpos3(uS): setpos(3,uS) def setpos4(uS): setpos(4,uS) from Tkinter import * import serial s=serial.Serial() # this /dev/tty.usbmodem device is for my particular system # do ls /dev/tty.usbmodem* to figure out yours # in Dual USB mode, lower number is the command port s.port="/dev/tty.usbmodem00049671" s.baudrate=115200 s.timeout=1 master = Tk() w0 = Scale(master,command=setpos0,from_=500,to=2500,length=500) w0.grid(row=0,column=0) w0.set(1500) w1 = Scale(master,command=setpos1,from_=500,to=2500,length=500) w1.grid(row=0,column=1) w1.set(1500) w2 = Scale(master,command=setpos2,from_=500,to=2500,length=500) w2.grid(row=0,column=2) w2.set(1500) w3 = Scale(master,command=setpos3,from_=500,to=2500,length=500) w3.grid(row=0,column=3) w3.set(2000) w4 = Scale(master,command=setpos4,from_=500,to=2500,length=500) w4.grid(row=0,column=4) w4.set(1500) #note that the initial servo values may differ slightly between arms setpos(0,1500) setpos(1,1500) setpos(2,1500) setpos(3,2000) setpos(4,1500) master.mainloop()

No comments: