|
| 1 | +# Python Code to drive the Maplin/OWI "Edge" USB Robot arm |
| 2 | + |
| 3 | +The main repository for this is https://github.com/orionrobots/python_usb_robot_arm. |
| 4 | + |
| 5 | +[Video Demo](https://www.youtube.com/watch?v=dAvWBOTtGnU) |
| 6 | + |
| 7 | +## Quick Raspberry Pi Installation |
| 8 | + |
| 9 | +On a terminal at the Raspberry Pi enter these commands: |
| 10 | + |
| 11 | + curl https://raw.githubusercontent.com/orionrobots/python_usb_robot_arm/main/setup_arm.sh | sudo bash |
| 12 | + |
| 13 | +I suggest review the setup_arm.sh script above to see what it does. |
| 14 | + |
| 15 | +## Requirements for Other OS |
| 16 | + |
| 17 | +This has previously been tested on Linux, OSX and Windows. OSX and Windows require signed drivers which may not easily be available. |
| 18 | + |
| 19 | +* Python 3 or 2.7 |
| 20 | +* Libusb (on linux, mac or windows - <http://sourceforge.net/projects/libusb-win32/files/latest/download>) - the apt-get package will work. |
| 21 | +* pyusb via pip |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +As a library: |
| 26 | + |
| 27 | + >>> import usb_arm |
| 28 | + |
| 29 | +To initialise libusb and the arm |
| 30 | + |
| 31 | + >>> arm = usb_arm.Arm() |
| 32 | + |
| 33 | +This will tell you if all the dependencies work, and will throw an exception if it fails to find the arm and connect |
| 34 | + to it. |
| 35 | + |
| 36 | +Now lets test it by turning on the LED |
| 37 | + |
| 38 | + >>> arm.move(usb_arm.LedOn) |
| 39 | + |
| 40 | +It will turn on for 1 second, and automatically turn off. The moveArm function automatically turns off after each |
| 41 | +move. You can optionally specify another time, but since the Maplin arm doesn't have any sensors, beware that if |
| 42 | +it reaches limits before the time finishes, then it won't stop. |
| 43 | + |
| 44 | +### Actual movement |
| 45 | + |
| 46 | + >>> arm.move(usb_arm.ElbowUp) |
| 47 | + |
| 48 | +The elbow will move up. |
| 49 | +The movements possible: |
| 50 | + |
| 51 | +GripsOpen (OpenGrips) |
| 52 | +GripsClose (CloseGrips) |
| 53 | +WristUp |
| 54 | +WristDown |
| 55 | +ElbowUp |
| 56 | +ElbowDown |
| 57 | +ShoulderUp |
| 58 | +ShoulderDown |
| 59 | +BaseClockWise |
| 60 | +BaseCtrClockWise |
| 61 | + |
| 62 | +Stop |
| 63 | + |
| 64 | +LedOn |
| 65 | + |
| 66 | +## Combining Movements |
| 67 | + |
| 68 | +Movements are based upon the BitPattern class, and you can feed arbitrary bitpatterns to it, but all those the |
| 69 | +arm is currently capable of are represented above. |
| 70 | + |
| 71 | +However, you may want to make more than one movement at the same time. You can do this by combining patterns with the |
| 72 | +or operator: |
| 73 | + |
| 74 | + >>> arm.move(usb_arm.ElbowDown | usb_arm.BaseClockWise, 0.5) |
| 75 | + |
| 76 | +The arm should turn clockwise and bring the elbow up simultaneously for half a second. |
| 77 | + |
| 78 | +### Gear Lash |
| 79 | + |
| 80 | +The unmodified arm has a few flaws - it has fairly loose gear chains in the "servos" it uses for the movements. |
| 81 | +To see what I mean try the following: |
| 82 | + |
| 83 | + >>> arm.move(usb_arm.ShoulderUp, 0.5) |
| 84 | + >>> arm.move(usb_arm.ShoulderDown, 0.5) |
| 85 | + |
| 86 | +You will note the arm moves, but when it returns, it does not quite return to the same position - there is an error, |
| 87 | +which you will need to account for as you use the arm and in programmed sequences. |
| 88 | + |
| 89 | +You should now know enough to move the arm to any location. |
| 90 | + |
| 91 | +### Sequences of Actions |
| 92 | + |
| 93 | +You can create programmed sequences of actions for the robot. However, before you issue one of these, ensure you |
| 94 | +know the position of the arm, and wont move it past its limits - which could cause damage to it, |
| 95 | + |
| 96 | +Sequences are created as arrays of commands. Each command is an array of the bitpattern, followed by the |
| 97 | +optional time (defaulting to 1 second): |
| 98 | + |
| 99 | + >>> actions = [[usb_arm.ElbowDown, 0.5], [usb_arm.GripsClose, 0.5], [usb_arm.ElbowUp]] |
| 100 | + |
| 101 | +To issue the action list: |
| 102 | + |
| 103 | + >>> arm.doActions(actions) |
| 104 | + |
| 105 | +Note you can ctrl-c stop the movements. |
| 106 | +There are a couple of canned actions already in the module: |
| 107 | + |
| 108 | + block_left |
| 109 | + block_right |
| 110 | + left_and_blink |
| 111 | + |
| 112 | +## An Example Script |
| 113 | + |
| 114 | +Using this in a python file couldn't be easier. For example you could put this in demo_arm.py: |
| 115 | + |
| 116 | + import usb_arm |
| 117 | + arm = usb_arm.Arm() |
| 118 | + actions = [[usb_arm.ElbowDown, 0.5], [usb_arm.GripsClose, 0.5], [usb_arm.ElbowUp]] |
| 119 | + arm.doActions(actions) |
| 120 | + |
| 121 | +You can then run this with python3 demo_arm.py. |
| 122 | + |
| 123 | +## Troubleshooting |
| 124 | + |
| 125 | +### Linux - permissions |
| 126 | + |
| 127 | +You will either need to run as root (not recommended) or modify your system to allow all users access to the device. |
| 128 | + |
| 129 | + sudo nano /etc/udev/rules.d/42-usb-arm-permissions.rules |
| 130 | + |
| 131 | +and add: |
| 132 | + |
| 133 | + SUBSYSTEM=="usb", ATTR{idVendor}=="1267", ATTR{idProduct}=="0000", MODE:="0666" |
| 134 | + |
| 135 | +Plug in the device and you should be able to access it. Tested on Ubuntu and Mint Linux versions. |
| 136 | + |
| 137 | +## License |
| 138 | + |
| 139 | +CC BY SA 3.0 - http://creativecommons.org/licenses/by-sa/3.0/ |
| 140 | +Creative Commons By Attribution Share-Alike v3.0 |
| 141 | + |
| 142 | +## Related Work |
| 143 | + |
| 144 | +* The original reverse engineering of the UBS protocol was done by |
| 145 | +[Vadim Zaliva](http://www.crocodile.org/lord/) and published on [his blog](http://notbrainsurgery.livejournal.com/38622.html) |
| 146 | +* [An alternative Objective-C control program](https://armctrl.codeplex.com) |
| 147 | +* Device assembly manual <https://www.robotshop.com/media/files/pdf/owi-535_manual.pdf> |
| 148 | +* [OWI (manufacturer) information](http://www.owirobots.com/cart/catalog/OWI-535USB-ROBOTIC-ARM-KIT-with-USB-PC-INTERFACE-Assembled-103.html) |
| 149 | +* [PCB Scans](https://kyllikki.github.io/EdgeRobotArm/) |
0 commit comments