Hi all,
First, i m sorry for my bad English!
I just received a Lego NXT Mindstorm Education Base Set and i would to control robot with nxt Python.
I followed different step and tutorial:
1- Installation:
I installed : Python 2.7.5
libusb-win32-bin-1.2.6.0
PyUSB 1.0.0.a3
nxt-python-2.2.2
2-First problems:
i launched, to try something, the spin.py example, and i got the following error:
Host: 00:16:53:40:84:E5 Name: MyNXT Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
File "C:\Python27\nxtControl\examples\spin.py", line 12, in <module>
b = nxt.locator.find_one_brick(debug=True)
File "C:\Python27\lib\site-packages\nxt\locator.py", line 112, in find_one_brick
for s in find_bricks(host, name, silent, method):
File "C:\Python27\lib\site-packages\nxt\locator.py", line 43, in find_bricks
for s in socks:
File "C:\Python27\lib\site-packages\nxt\usbsock.py", line 84, in find_bricks
for bus in usb.busses():
File "C:\Python27\lib\site-packages\usb\legacy.py", line 343, in busses
return (Bus(),)
File "C:\Python27\lib\site-packages\usb\legacy.py", line 339, in __init__
self.devices = [Device(d) for d in core.find(find_all=True)]
File "C:\Python27\lib\site-packages\usb\core.py", line 856, in find
raise ValueError('No backend available')
ValueError: No backend available
So i tried something: i launched the inf wizard of libusb, ( a different way that the one proposed in the video), and i launched spin.py. I Still got a problem.
3- Second problem: i got that:
Host: 00:16:53:40:84:E5 Name: MyNXT Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
File "C:\Python27\nxtControl\examples\spin.py", line 12, in <module>
b = nxt.locator.find_one_brick(debug=True)
File "C:\Python27\lib\site-packages\nxt\locator.py", line 137, in find_one_brick
raise BrickNotFoundError
BrickNotFoundError
#!/usr/bin/env python
import nxt.locator
from nxt.motor import *
b = nxt.locator.find_one_brick(debug=True)
and the result is:
#!/usr/bin/env python
import nxt.locator
from nxt.motor import *
b = nxt.locator.find_one_brick(debug=True)
4-Continuing with problems ^^
As Mr. Marcus Wanner advised in the topic i tried to create a file like this:
import usb
for bus in usb.busses():
for device in bus.devices:
print device.idVendor, device.idProduct
And i get:
1684 5
Then i wanted to verified if this device exists (just to try) and i completed the programm, so i had:
import usb
for bus in usb.busses():
for device in bus.devices:
print device.idVendor, device.idProduct
dev = usb.core.find(idVendor=0x1684, idProduct=0x0005)
print(dev)
and i got:
1684 5
None
5-Strange results?
I dont understand why the device doesnt exists with these parameters. So i launched from my folder (C:\Python27\modulesNXT\libusb-win32-bin-1.2.6.0\bin\amd64) the following program: "testlibusb-win" and it gaves different id Ventor and product :0694 and 0005
Then i wanted to verify, and create another python program:
dev = usb.core.find(idVendor=0x0694, idProduct=0x0005)
print(dev)
and that seems to work:
<usb.core.Device object at 0x02A8D490>
But nvm, i m still with this Brick witch is not found :/
6-going in the usbsock.py
Then, i opened in this folder: C:\Python27\Lib\site-packages\nxt, the following program: usbsock.py
And i saw two lines:
ID_VENDOR_LEGO = 0x0694
ID_PRODUCT_NXT = 0x0002
that i modified in:
ID_VENDOR_LEGO = 0x0694
ID_PRODUCT_NXT = 0x0005
i saved and launch the spin.py program and i got:
Host: 00:16:53:40:84:E5 Name: MyNXT Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\nxt\locator.py", line 119, in find_one_brick
info = b.get_device_info()
File "C:\Python27\lib\site-packages\nxt\brick.py", line 27, in poll
self.sock.send(str(ogram))
File "C:\Python27\lib\site-packages\nxt\usbsock.py", line 69, in send
self.handle.bulkWrite(self.blk_out.address, data)
File "C:\Python27\lib\site-packages\usb\legacy.py", line 148, in bulkWrite
return self.dev.write(endpoint, buffer, self.__claimed_interface, timeout)
File "C:\Python27\lib\site-packages\usb\core.py", line 626, in write
self.__get_timeout(timeout)
File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 495, in intr_write
timeout)
File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 559, in __write
timeout
File "C:\Python27\lib\site-packages\usb\backend\libusb0.py", line 387, in _check
raise USBError(errmsg, ret)
USBError: [Errno None] libusb0-dll:err [_usb_setup_async] invalid endpoint 0x81
Failed to connect to possible brick
Traceback (most recent call last):
File "C:\Python27\nxtControl\examples\spin.py", line 12, in <module>
b = nxt.locator.find_one_brick(debug=True)
File "C:\Python27\lib\site-packages\nxt\locator.py", line 137, in find_one_brick
raise BrickNotFoundError
BrickNotFoundError
7- Dont know what to do...
This message is really long, sorry for that, but i think that s this nxt python is really powerfull, and a very nice idea, that s why i would like to use it. But know, after hours trying to install, i dont know what to do... If someone can help, that would be really great!
Im on Windows 7
Thanks in advance.
Regards
JP