Difference between revisions of "LEGO IGT Compilation"
(New page: About NXT_USB: This is a C++ library used to control a LEGO Mindstorms NXT robot over a USB connection. This code was modified from: -NXT++: http://nxtpp.sourceforge.net -Device::...) |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | NXT_USB is a C++ library used to control a LEGO Mindstorms NXT robot over a USB connection. | |
− | |||
This code was modified from: | This code was modified from: | ||
− | + | *NXT++: http://nxtpp.sourceforge.net | |
− | + | *Device::USB: http://search.cpan.org/~gwadej/Device-USB-0.21 | |
− | + | = Linux Installation = | |
− | |||
− | |||
− | + | == Reqirements == | |
+ | # This code can be used only on a Linux distribution with root access. Remember to run any software utilizing this code as root. | ||
+ | # libusb: http://libusb.sourceforge.net/ | ||
+ | == Instructions == | ||
Download libusb from: | Download libusb from: | ||
− | http://libusb.sourceforge.net | + | http://libusb.sourceforge.net (version 0.1.12) |
− | (version 0.1.12) | ||
Then run: | Then run: | ||
− | tar zxvf libusb-0.1.12.tar.gz | + | tar zxvf libusb-0.1.12.tar.gz |
− | cd libusb-0.1.12/ | + | cd libusb-0.1.12/ |
− | ./configure CFLAGS=-funsigned-char --prefix=<your libusb directory> --exec-prefix=<your libsub directory> | + | ./configure CFLAGS=-funsigned-char --prefix=<your libusb directory> --exec-prefix=<your libsub directory> |
− | make | + | make |
− | make install | + | make install |
Then add the libusb directory to your $LD_LIBRARY_PATH variable. | Then add the libusb directory to your $LD_LIBRARY_PATH variable. | ||
Line 28: | Line 27: | ||
Another alternative is to use CMake: | Another alternative is to use CMake: | ||
− | SET(CMAKE_CXX_FLAGS | + | SET(CMAKE_CXX_FLAGS |
− | + | "-funsigned-char" | |
− | ) | + | ) |
− | INCLUDE_DIRECTORIES( | + | INCLUDE_DIRECTORIES( |
− | + | ... | |
− | + | <your libusb directory (can be a relative path)> | |
− | ) | + | ) |
− | ADD_LIBRARY(<your library name> | + | ADD_LIBRARY(<your library name> |
− | + | ... | |
− | + | NXT_USB.cxx | |
− | + | NXT_USB_linux.cxx | |
− | ) | + | ) |
− | FIND_LIBRARY(LIBUSB_LIB | + | FIND_LIBRARY(LIBUSB_LIB |
− | + | NAMES libusb-lib | |
− | + | PATHS | |
<your libusb directory (can be a relative path)>/lib | <your libusb directory (can be a relative path)>/lib | ||
− | ) | + | ) |
− | TARGET_LINK_LIBRARIES(Lego | + | TARGET_LINK_LIBRARIES(Lego |
− | + | ... | |
− | + | <your libusb directory (should be an absolute path)>/lib/libusb.so | |
− | ) | + | ) |
The simplest way to use this library is to keep the four NXT_USB files (NXT_USB.h, NXT_USB.cxx, NXT_USB_linux.h, and NXT_USB_linux.cxx) in the same directory as your program. Simply #include "NXT_USB.h" and compile as usual. | The simplest way to use this library is to keep the four NXT_USB files (NXT_USB.h, NXT_USB.cxx, NXT_USB_linux.h, and NXT_USB_linux.cxx) in the same directory as your program. Simply #include "NXT_USB.h" and compile as usual. | ||
− | Contact information | + | = Windows Installation = |
+ | |||
+ | The Windows installation of the NXT_USB requires the windows port of libusb using libusb-win32 open-source project. | ||
+ | |||
+ | # Go to [http://sourceforge.net/project/showfiles.php?group_id=78138&package_id=79216 SourceForge] | ||
+ | # Install libusb-win32-filter-bin-0.1.12.1.exe by following the instructions | ||
+ | # Download libusb-win32-device-bin-0.1.12.1.tar.gz from [http://sourceforge.net/project/showfiles.php?group_id=78138&package_id=79216 SourceForge] | ||
+ | # Extract libusb-win32-device-bin-0.1.12.1.tar.gz using winrar or cygwin (tar -zxf) | ||
+ | # Plug the USB cable to your computer and start the Lego NXT (it won't be recognized, just wait if you got the windows device wizrd | ||
+ | # Start libusb-win32-device-bin-0.1.12.1/bin/inf-wizard | ||
+ | # Select the device corresponding to the Lego NXT | ||
+ | # Enter some information: name, etc.. (this is arbitrary) | ||
+ | # inf-wizard will create a .cat, .ing, .PNF files | ||
+ | # In the same directory where the generated files have been written copy the libusb0.dll and libusb0.sys (located in the libsb-win32-device-bin) | ||
+ | # Using the Windows device wizard, select the .inf file generated | ||
+ | # Go to 'Start Menu'->'Programs'->'LibUSB-Win32'->'Test Program', you should see the NXT device: | ||
+ | |||
+ | bus-0/\\.\libusb0-0005--0x0694-0x0002 0694/0002 | ||
+ | Serial Number: 00165304BDE2 | ||
+ | wTotalLength: 32 | ||
+ | bNumInterfaces: 1 | ||
+ | bConfigurationValue: 1 | ||
+ | iConfiguration: 0 | ||
+ | bmAttributes: c0h | ||
+ | MaxPower: 0 | ||
+ | bInterfaceNumber: 0 | ||
+ | bAlternateSetting: 0 | ||
+ | bNumEndpoints: 2 | ||
+ | bInterfaceClass: 255 | ||
+ | bInterfaceSubClass: 255 | ||
+ | bInterfaceProtocol: 255 | ||
+ | iInterface: 0 | ||
+ | bEndpointAddress: 01h | ||
+ | bmAttributes: 02h | ||
+ | wMaxPacketSize: 64 | ||
+ | bInterval: 0 | ||
+ | bRefresh: 0 | ||
+ | bSynchAddress: 0 | ||
+ | bEndpointAddress: 82h | ||
+ | bmAttributes: 02h | ||
+ | wMaxPacketSize: 64 | ||
+ | bInterval: 0 | ||
+ | bRefresh: 0 | ||
+ | bSynchAddress: 0 | ||
+ | |||
+ | = Contact information = | ||
I would be more than happy to reply to any questions and comments emailed to dpace [at] bwh.harvard.edu. | I would be more than happy to reply to any questions and comments emailed to dpace [at] bwh.harvard.edu. |
Latest revision as of 14:42, 25 June 2008
Home < LEGO IGT CompilationNXT_USB is a C++ library used to control a LEGO Mindstorms NXT robot over a USB connection.
This code was modified from:
- NXT++: http://nxtpp.sourceforge.net
- Device::USB: http://search.cpan.org/~gwadej/Device-USB-0.21
Contents
Linux Installation
Reqirements
- This code can be used only on a Linux distribution with root access. Remember to run any software utilizing this code as root.
- libusb: http://libusb.sourceforge.net/
Instructions
Download libusb from:
http://libusb.sourceforge.net (version 0.1.12)
Then run:
tar zxvf libusb-0.1.12.tar.gz cd libusb-0.1.12/ ./configure CFLAGS=-funsigned-char --prefix=<your libusb directory> --exec-prefix=<your libsub directory> make make install
Then add the libusb directory to your $LD_LIBRARY_PATH variable. Note that the INSTALL.libusb file has information about the installation process.
Another alternative is to use CMake:
SET(CMAKE_CXX_FLAGS "-funsigned-char" )
INCLUDE_DIRECTORIES( ... <your libusb directory (can be a relative path)> )
ADD_LIBRARY(<your library name> ... NXT_USB.cxx NXT_USB_linux.cxx )
FIND_LIBRARY(LIBUSB_LIB NAMES libusb-lib PATHS <your libusb directory (can be a relative path)>/lib )
TARGET_LINK_LIBRARIES(Lego ... <your libusb directory (should be an absolute path)>/lib/libusb.so )
The simplest way to use this library is to keep the four NXT_USB files (NXT_USB.h, NXT_USB.cxx, NXT_USB_linux.h, and NXT_USB_linux.cxx) in the same directory as your program. Simply #include "NXT_USB.h" and compile as usual.
Windows Installation
The Windows installation of the NXT_USB requires the windows port of libusb using libusb-win32 open-source project.
- Go to SourceForge
- Install libusb-win32-filter-bin-0.1.12.1.exe by following the instructions
- Download libusb-win32-device-bin-0.1.12.1.tar.gz from SourceForge
- Extract libusb-win32-device-bin-0.1.12.1.tar.gz using winrar or cygwin (tar -zxf)
- Plug the USB cable to your computer and start the Lego NXT (it won't be recognized, just wait if you got the windows device wizrd
- Start libusb-win32-device-bin-0.1.12.1/bin/inf-wizard
- Select the device corresponding to the Lego NXT
- Enter some information: name, etc.. (this is arbitrary)
- inf-wizard will create a .cat, .ing, .PNF files
- In the same directory where the generated files have been written copy the libusb0.dll and libusb0.sys (located in the libsb-win32-device-bin)
- Using the Windows device wizard, select the .inf file generated
- Go to 'Start Menu'->'Programs'->'LibUSB-Win32'->'Test Program', you should see the NXT device:
bus-0/\\.\libusb0-0005--0x0694-0x0002 0694/0002 Serial Number: 00165304BDE2 wTotalLength: 32 bNumInterfaces: 1 bConfigurationValue: 1 iConfiguration: 0 bmAttributes: c0h MaxPower: 0 bInterfaceNumber: 0 bAlternateSetting: 0 bNumEndpoints: 2 bInterfaceClass: 255 bInterfaceSubClass: 255 bInterfaceProtocol: 255 iInterface: 0 bEndpointAddress: 01h bmAttributes: 02h wMaxPacketSize: 64 bInterval: 0 bRefresh: 0 bSynchAddress: 0 bEndpointAddress: 82h bmAttributes: 02h wMaxPacketSize: 64 bInterval: 0 bRefresh: 0 bSynchAddress: 0
Contact information
I would be more than happy to reply to any questions and comments emailed to dpace [at] bwh.harvard.edu.