Difference between revisions of "Installation of WeDo Python Support"
From wikidb
(→Reference) |
|||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | == Up == | ||
+ | |||
+ | [[Lego WeDo]] | ||
+ | |||
+ | == Reference == | ||
+ | |||
+ | * [[http://klaig.blogspot.com/2013/03/proper-python-support-for-lego-wedo-kit.html Klaig]] | ||
+ | |||
== Software Dependancies == | == Software Dependancies == | ||
− | Some or all of the following are required. | + | Some or all of the following are required. Several were install in desperation to solve problems below. |
<pre> | <pre> | ||
Line 7: | Line 15: | ||
aptitude install python-dev | aptitude install python-dev | ||
aptitude install python-usb | aptitude install python-usb | ||
+ | aptitude install python-serial | ||
aptitude install git | aptitude install git | ||
</pre> | </pre> | ||
− | == Standard install for WeDo Library - | + | == Standard install for WeDo Library - Failed == |
<pre> | <pre> | ||
Line 24: | Line 33: | ||
</pre> | </pre> | ||
− | == Workaround install for WeDo Library == | + | == Workaround install for WeDo Library that was Used == |
+ | The CHANGES.rst file is present in this method. | ||
<pre> | <pre> | ||
git clone git://github.com/itdaniher/WeDoMore.git | git clone git://github.com/itdaniher/WeDoMore.git | ||
Line 31: | Line 41: | ||
sudo python setup.py install | sudo python setup.py install | ||
</pre> | </pre> | ||
+ | |||
+ | == Fixing the Missing usb.core == | ||
+ | |||
+ | This is the symptom. | ||
+ | <pre> | ||
+ | sudo python | ||
+ | >>> from wedo import WeDo | ||
+ | Traceback (most recent call last): | ||
+ | File "<stdin>", line 1, in <module> | ||
+ | File "/usr/local/lib/python2.7/dist-packages/wedo-1.0.0-py2.7.egg/wedo/__init__.py", line 8, in <module> | ||
+ | import usb.core | ||
+ | ImportError: No module named core | ||
+ | </pre> | ||
+ | |||
+ | The problem is an old version of pyusb. It should be 1.0 or greater. | ||
+ | [http://comments.gmane.org/gmane.comp.python.pyusb.user/687 pyusb fix link] | ||
+ | I found it at: [http://sourceforge.net/projects/pyusb/?source=dlp] | ||
+ | |||
+ | <pre> | ||
+ | unzip pyusb-1.0.0a3.zip | ||
+ | cd pyusb-1.0.0a3/ | ||
+ | sudo python setup.py install | ||
+ | ls /usr/local/lib/python2.7/dist-packages/ | ||
+ | easy-install.pth pyusb-1.0.0a3.egg-info usb wedo-1.0.0-py2.7.egg | ||
+ | </pre> | ||
+ | |||
+ | == Example Run == | ||
+ | |||
+ | Python support for the Lego WeDo kit: [[http://klaig.blogspot.com/2013/03/proper-python-support-for-lego-wedo-kit.html Klaig]] | ||
+ | <pre> | ||
+ | |||
+ | sudo python | ||
+ | Python 2.7.3 (default, Jan 13 2013, 11:20:46) | ||
+ | [GCC 4.6.3] on linux2 | ||
+ | Type "help", "copyright", "credits" or "license" for more information. | ||
+ | >>> from wedo import WeDo | ||
+ | >>> wd = WeDo() | ||
+ | >>> wd.motor_a = 100 | ||
+ | >>> wd.motor_a = 0 | ||
+ | >>> | ||
+ | </pre> | ||
+ | |||
+ | From the Klaig site | ||
+ | |||
+ | To install it: | ||
+ | pip install wedo | ||
+ | |||
+ | To initialize it if you have a single device: | ||
+ | >>> from wedo import WeDo | ||
+ | >>> wd = WeDo() | ||
+ | Activating the first motor full forward: | ||
+ | >>> wd.motor_a = 100 | ||
+ | Activating the second motor half speed/force backward: | ||
+ | >>> wd.motor_b = -50 | ||
+ | Current value of the tilt sensor, you can find the matching constants FLAT, TILT_BACK, TILT_FORWARD, TILT_LEFT, TILT_RIGHT in the wedo package: | ||
+ | >>> wd.tilt | ||
+ | 3 | ||
+ | Current distance value in meters of the distance sensor: | ||
+ | >>> wd.distance | ||
+ | 0.21 |
Latest revision as of 12:38, 12 May 2013
Contents
Up
Reference
- [Klaig]
Software Dependancies
Some or all of the following are required. Several were install in desperation to solve problems below.
aptitude install python-pip aptitude install python-dev aptitude install python-usb aptitude install python-serial aptitude install git
Standard install for WeDo Library - Failed
pip install wedo
A possible workaround for the missing CHANGES.rst file.
cd build/wedo/ cat one two three > CHANGES.rst python setup.py install
Workaround install for WeDo Library that was Used
The CHANGES.rst file is present in this method.
git clone git://github.com/itdaniher/WeDoMore.git cd WeDoMore/ sudo python setup.py install
Fixing the Missing usb.core
This is the symptom.
sudo python >>> from wedo import WeDo Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/wedo-1.0.0-py2.7.egg/wedo/__init__.py", line 8, in <module> import usb.core ImportError: No module named core
The problem is an old version of pyusb. It should be 1.0 or greater. pyusb fix link I found it at: [1]
unzip pyusb-1.0.0a3.zip cd pyusb-1.0.0a3/ sudo python setup.py install ls /usr/local/lib/python2.7/dist-packages/ easy-install.pth pyusb-1.0.0a3.egg-info usb wedo-1.0.0-py2.7.egg
Example Run
Python support for the Lego WeDo kit: [Klaig]
sudo python Python 2.7.3 (default, Jan 13 2013, 11:20:46) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from wedo import WeDo >>> wd = WeDo() >>> wd.motor_a = 100 >>> wd.motor_a = 0 >>>
From the Klaig site
To install it: pip install wedo
To initialize it if you have a single device:
>>> from wedo import WeDo >>> wd = WeDo()
Activating the first motor full forward:
>>> wd.motor_a = 100
Activating the second motor half speed/force backward:
>>> wd.motor_b = -50
Current value of the tilt sensor, you can find the matching constants FLAT, TILT_BACK, TILT_FORWARD, TILT_LEFT, TILT_RIGHT in the wedo package:
>>> wd.tilt 3
Current distance value in meters of the distance sensor:
>>> wd.distance 0.21