19
Hacking the OWI/Maplin Robotic Arm By Liz Quilty

Hacking the owi robotic arm presentation liz quilty

Embed Size (px)

DESCRIPTION

My kiwi PyCon slides for the robotic arm demonstration. Github is at https://github.com/lizquilty/roboticarm/ should you need the code

Citation preview

Page 1: Hacking the owi robotic arm presentation   liz quilty

Hacking the OWI/Maplin Robotic Arm

By Liz Quilty

Page 2: Hacking the owi robotic arm presentation   liz quilty

Confession

I don’t really know python.

My way is possibly not the best

I just like making things, and having fun :)

Page 3: Hacking the owi robotic arm presentation   liz quilty

Items Required

1 OWI/Maplin Robotic Arm kit

Page 4: Hacking the owi robotic arm presentation   liz quilty

Items Required

1 USB kit for the arm

Page 5: Hacking the owi robotic arm presentation   liz quilty

Items Required

1 Raspberry Pi + power/network etc

Page 6: Hacking the owi robotic arm presentation   liz quilty

Items RequiredA sick/bored child to assemble robotic arm

Page 7: Hacking the owi robotic arm presentation   liz quilty

Setup Your Raspberry Pi

Partition and install raspbianhttp://elinux.org/RPi_Easy_SD_Card_Setup

Unpack this to the SD card as instructed

Set up networking and connect via SSH

Page 8: Hacking the owi robotic arm presentation   liz quilty

Adding Dev rules

Create the file /etc/udev/rules.d/85-robotarm.rules with the contentsSUBSYSTEM=="usb", ATTRS{idVendor}=="1267", ATTRS{idProduct}=="0000", ACTION=="add", GROUP="plugdev", MODE="0666"

This allows non root users to access it.

For CGI add apache user to plugdev groupusermod -aG plugdev www-datausermod -aG audio www-data

Page 9: Hacking the owi robotic arm presentation   liz quilty

pyUSB

Install the custom pyUSBpyusb http://sourceforge.net/projects/pyusb

# wget "http://downloads.sourceforge.net/project/pyusb/PyUSB%201.0/1.0.0-alpha-3/pyusb-1.0.0a3.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fpyusb%2F&ts=1377736820&use_mirror=hivelocity"# unzip pyusb-1.0.0a3.zip# cd pyusb# python setup.py build# python setup.py install

Page 10: Hacking the owi robotic arm presentation   liz quilty

Command Line

Quick and easyhttps://github.com/lizquilty/roboticarm/

Better for more complex stuffhttps://github.com/peterlavelle/maplinarm

Page 11: Hacking the owi robotic arm presentation   liz quilty

Setting up the functions#ROBOT ARM CONTROL PROGRAM

#import the USB and Time librarys into Python

import usb.core, usb.util, time

#Allocate the name 'RoboArm' to the USB device

RoboArm = usb.core.find(idVendor=0x1267, idProduct=0x000)

#Check if the arm is detected and warn if not

if RoboArm is None:

raise ValueError("Arm not found")

#Create a variable for duration

Duration=1

#Define a procedure to execute each movement

def MoveArm(Duration, ArmCmd):

#Start the movement

RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)

#Stop the movement after waiting a specified duration

time.sleep(Duration)

ArmCmd=[0,0,0]

RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)

Page 12: Hacking the owi robotic arm presentation   liz quilty

MovingMoveArm(1,[0,1,0]) #Rotate base anti-clockwise

MoveArm(1,[0,2,0]) #Rotate base clockwise

MoveArm(1,[64,0,0]) #Shoulder up

MoveArm(1,[128,0,0]) #Shoulder down

MoveArm(1,[16,0,0]) #Elbow up

MoveArm(1,[32,0,0]) #Elbow down

MoveArm(1,[4,0,0]) #Wrist up

MoveArm(1,[8,0,0]) # Wrist down

MoveArm(1,[2,0,0]) #Grip open

MoveArm(1,[1,0,0]) #Grip close

MoveArm(1,[0,0,1]) #Light on

MoveArm(1,[0,0,0]) #Light off

Page 13: Hacking the owi robotic arm presentation   liz quilty

Demo Hello World + Waving

PIR sensor connected to + - and pin GPIO pin 18Sensor detects movement, greets and waves, then waits

Page 14: Hacking the owi robotic arm presentation   liz quilty

Test and use

Test the arm as rootPick up things, write some code, automate !Use cron for time basedsensors (motion) http://learn.adafruit.com/adafruits-raspberry-pi-lesson-12-sensing-movement/hardwarehttp://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-gpio

Speech - festivalVoice control

Page 15: Hacking the owi robotic arm presentation   liz quilty

Web Based

Install apache & configure with CGI

https://github.com/lizquilty/roboticarm/

Page 16: Hacking the owi robotic arm presentation   liz quilty

Simple UI

Page 17: Hacking the owi robotic arm presentation   liz quilty

Demo

● Connect to the Wireless Access point RoboticArm● Browse to http://10.0.0.2

Try not to overload it :)

Page 19: Hacking the owi robotic arm presentation   liz quilty

References

My GitHub https://github.com/lizquilty/roboticarm/CLI scripts https://github.com/peterlavelle/maplinarmPyUSB http://sourceforge.net/projects/pyusb

99 little bugs in the code99 little bugs in the codeTake one down, patch it around117 little bugs in the code