Pages

Sunday 16 January 2011

New version!

Well the code I posted earlier was just about the simplest control you could have for the robotic arm.  I've been playing around tidying it up a lot into some functions and have just tested a new version.  Its far from perfect - but I think it represents the next milestone in development: the arm movement is defined through a series of command line arguments / switches.  You can download the file here.

The simplest way to understand how to use it (as a user rather than a programmer) will be to run the following command:
python arm_1.py --help
 which will bring up something like:
 Python program for connecting to USB Robotic Arm
Usage: arm_1.py [options]

Options:
  -h, --help            show this help message and exit
  -s SHOULDER, --shoulder=SHOULDER
                        Value 0,1,2 for shoulder motor (off/up/down)
  -e ELBOW, --elbow=ELBOW
                        Value 0,1,2 for elbow motor (off/up/down)
  -w WRIST, --wrist=WRIST
                        Value 0,1,2 for wrist motor (off/up/down)
  -g GRIP, --grip=GRIP  Value 0,1,2 for grip (off/in/out)
  -r ROTATE, --rotate=ROTATE
                        Value 0,1,2 for rotation (off/cw/ccw)
  -l LIGHT, --light=LIGHT
                        Value 0,1 for light (on/off)
  -t TIMEDELAY, --time=TIMEDELAY
                        Time (s) to wait before off default0.1
So e.g. python arm_1.py -g 1 -w 2 will close the gripper and move the wrist down simultaneously for 0.1 seconds.  Whilst python arm_1.py -r 2 -l 1 -t 3 will rotate the arm in the base counter clockwise and turn the light on for 3 seconds.

NOTE Depending on how you have your user privilidges set up you may not have access to the USB port - I need to run all these commands as root, e.g. sudo python arm_1...



4 comments:

  1. Hi!
    I cannot import usb.core....were can I check for errors?
    (when I start the script the error is :"ImportError: No module named core")

    ReplyDelete
  2. Stefano,

    usb.core is part of the PyUSB module - which you can download here: http://sourceforge.net/projects/pyusb/

    You unzip the contents, and run:

    python setup.py install

    in the directory where you unzipped it. Let me know if it works... ...or feel free to post more info about what you have done / what you have set up etc. Can't promise to fix it - but I'll try.

    ReplyDelete
  3. Thank You Poly,
    the problem is the ubuntu pyusb package...it doesn't work!
    The latest version on sourceforge work well.

    ReplyDelete
  4. Stefano, glas its sorted. It looks like ubuntu is still using v.0 (http://packages.ubuntu.com/source/hardy/pyusb) so I'll try to work out how to "force" an upgrade when I get onto bundling this up in a package.

    ReplyDelete