ReiberLabs RobotWiki - Welcome!

NXT Python

NXT_Python

About

NXT_Python is a package for controlling a LEGO NXT robot using the Python programming language. It can communicate using either USB or Bluetooth. It is available under the Free Software Foundation's GPL license. It was developed on Fedora Core (Linux), but it has been reported to work on Windows XP and Mac OS X as well. Here's a sample program:

#!/usr/bin/env python

import nxt.locator

sock = nxt.locator.find_one_brick()
if sock:
	brick = sock.connect()
	name, host, signal_strength, user_flash = brick.get_device_info()
	print 'NXT brick name: %s' % name
	print 'Host address: %s' % host
	print 'Bluetooth signal strength: %s' % signal_strength
	print 'Free user flash: %s' % user_flash
	sock.close()

Requirements

Download

  • Version 0.7
    —Added a get_sample() method to CompassSensor? class.
    —Simplified return values for message_read() method.
    —Added message_test.py to examples directory.

Installation

  • Untar/unzip source package
  • In package directory, run "python setup.py install" (as root)
  • For USB on Linux:
    • Create "lego" group, and make your user-id a member
    • Open a terminal as root, and type:
      groupadd lego
      usermod -a -G lego [user-id]
    • Create a udev rule
    • Create file at /etc/udev/rules.d/70-lego.rules, containing one line:
      BUS=="usb", SYSFS{idVendor}=="0694", GROUP="lego", MODE="0660"

Contact

NXT_Python was written by Douglas P Lau. See README file in the package for contact information.

</html

Topic revision: r1 - 15 Mar 2009 - 04:19:58 - PaulReiber
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RobotWiki? Send feedback