Skip to content

Commit 9d59906

Browse files
committed
Merge branch 'master' into packaging
2 parents e9e1660 + c84f402 commit 9d59906

File tree

3 files changed

+66
-18
lines changed

3 files changed

+66
-18
lines changed

readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
Python Code to drive the Maplin/OWI USB Robot arm
22

3+
[Video Demo](https://www.youtube.com/watch?v=dAvWBOTtGnU)
4+
35
Tested on:
46
* Raspbian
57
* Linux
68
* OSX (Lion, Mountain Lion)
79
May work on Windows.
10+
* Windows 8 [Windows Help](windows_setup/help.md)
811

912
Requirements
1013
============
1114
* Python 2.7 or 3
12-
* Libusb
13-
* pyusb
15+
* Libusb (on linux, mac or windows - http://sourceforge.net/projects/libusb-win32/files/latest/download) - the apt-get package will work.
16+
* pyusb via pip
1417

1518
Usage
1619
=====
@@ -54,6 +57,8 @@ BaseCtrClockWise
5457

5558
Stop
5659

60+
LedOn
61+
5762
Combining Movements
5863
-------------------
5964
Movements are based upon the BitPattern class, and you can feed arbitrary bitpatterns to it, but all those the

usb_arm/__init__.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
"""Maplin USB Robot arm control"""
2-
import os
3-
os.environ['DYLD_LIBRARY_PATH'] = '/opt/local/lib'
1+
"""Maplin USB Robot arm control.
2+
Usage -
3+
>>> import usb_arm
4+
>>> arm = usb_arm.Arm()
5+
>>> arm.move(usb_arm.OpenGrips)
6+
>>> arm.doActions(block_left) # WARNING - ARM SHOULD BE ALL THE WAY RIGHT BEFORE TRYING THIS
7+
8+
Trouble:
9+
"NO back end found" - you need to install a libusb driver on your system.
10+
"""
411
import usb.core
512
from time import sleep
613

@@ -74,9 +81,11 @@ def safe_tell(self, fn):
7481

7582
def move(self, pattern, time=1):
7683
"""Perform a pattern move with timing and stop"""
77-
self.tell(pattern)
78-
sleep(time)
79-
self.tell(Stop)
84+
try:
85+
self.tell(pattern)
86+
sleep(time)
87+
finally:
88+
self.tell(Stop)
8089

8190
def doActions(self, actions):
8291
"""Params: List of actions - each is a list/tuple of BitPattern and time
@@ -96,16 +105,16 @@ def doActions(self, actions):
96105
else:
97106
time = 1
98107
self.move(action[0], time)
99-
except:
108+
finally:
100109
self.move(Stop)
101-
raise
102110

111+
def makeGrabAndMove(baseDir):
112+
return [[CloseGrips, 1.1],
113+
[ShoulderUp | ElbowUp | WristDown | baseDir],
114+
[baseDir, 8.5],
115+
[ShoulderDown | ElbowDown | WristUp | baseDir],
116+
[OpenGrips]]
103117

104-
block_left = [[ShoulderDown], [GripsClose, 0.4], [ShoulderUp],
105-
[BaseClockWise, 10.2], [ShoulderDown],
106-
[GripsOpen, 0.4], [ShoulderUp, 1.2]]
107-
block_right = [[ShoulderDown], [GripsClose, 0.4], [ShoulderUp],
108-
[BaseCtrClockWise, 10.2], [ShoulderDown],
109-
[GripsOpen, 0.4], [ShoulderUp, 1.2]]
110-
left_and_blink = list(block_left)
111-
left_and_blink.extend([[LedOn, 0.5], [Stop, 0.5]] * 3)
118+
blink = [[LedOn, 0.5], [Stop, 0.5]] * 3
119+
block_left = makeGrabAndMove(BaseClockWise, 0.4) + blink
120+
block_right = makeGrabAndMove(BaseCtrClockWise, 0.4) + blink

windows_setup/help.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Help Setting Up On Windows
2+
==========================
3+
4+
Tested with Python 2.7, Windows 8 64 bit.
5+
6+
First ensure you have a version of python installed.
7+
8+
[Windows Installation Video](https://www.youtube.com/watch?v=sNp8Z_MH7iQ)
9+
10+
LibUSB - The Backend
11+
====================
12+
To get libusb running, the backend, go to http://sourceforge.net/projects/libusb-win32/files/ and pick up the latest release.
13+
14+
Extract this zipfile, then go into the extracted folder and find bin/inf-wizard.exe. Run this _as administrator_.
15+
When you are asked to find the device - it has Vendor ID 0x1267, Product ID 0000.
16+
17+
This should install a driver on your computer giving you access to the arm.
18+
If it complains about installing the driver, remember that this tool shoudl be run as administrator.
19+
20+
PyUSB
21+
=====
22+
Warning - confusingly there are two completely different python libraries of this name.
23+
24+
This is the correct one: http://walac.github.io/pyusb/
25+
This is the wrong one: http://bleyer.org/pyusb/
26+
27+
On the walac site, there is a zip. Download this, and extract it into a folder.
28+
Start a terminal, and CD into the folder.
29+
Then run :
30+
python setup.py
31+
32+
Now you should be able to run the usb_arm code. Import it and try some simple movements.
33+
34+

0 commit comments

Comments
 (0)