richrd / nxt-python Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/nxt-python
License: GNU General Public License v3.0
Automatically exported from code.google.com/p/nxt-python
License: GNU General Public License v3.0
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 Gnu GPL v3 license. It is based on NXT_Python, where releases halted in May 2007. Requirements: * Python 2.6 or greater, but not 3.x (http://www.python.org) And at least one comm library: * Bluetooth communications: Linux/Windows: PyBluez (http://code.google.com/p/pybluez/) (package python-bluez in deb-based linuxes) Mac: LightBlue (http://lightblue.sourceforge.net/) * USB communications: PyUSB (http://sourceforge.net/projects/pyusb/) * Fantom communications (tested on Mac OSX): Pyfantom (http://pyfantom.ni.fr.eu.org/) Installation (see http://code.google.com/p/nxt-python/wiki/Installation): * Untar/unzip source package. * In package directory, run "python setup.py install" (as root), or if under windows, double-click install.bat. * To use USB on Linux as non-superuser, at a root terminal type: groupadd lego usermod -a -G lego [username] echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0694", GROUP="lego", MODE="0660"' > /etc/udev/rules.d/70-lego.rules Getting Started: Take a look at the examples directory. Feel free to copy that code into your scripts and don't be afraid to experiment! If you are having trouble with something, you may find the solution in the docstrings (for example, help('nxt.sensor.Ultrasonic')) or even in the source code (especially for digital sensors). Notes/FAQ: (I have tried to put the most important stuff first, but it would be a good idea to read the whole section. In any case, read it all the way through before asking for help. Thanks!) -=-=-About v2-=-=- This version is part of the 2.x series of releases. Programs designed for NXT_Python or for the 1.x series of nxt-python will not work with this version. If you are trying to get an old program to work, it most likely needs a 1.x series release, which can be downloaded from the nxt-python downloads page at googlecode. New projects should use a 2.x series release (hint: this is one!) due to the new features and API improvements. Converting old projects is somewhat difficult and not officially supported, though as always you're welcome to ask for help. -=-=-Problems and Their Solutions-=-=- Support for a number of sensors has not been tested at all, due to lack of hardware. I have started a project to test this code, but the going is slow and I still can't test everything. If you have a problem with a digital sensor, see the troubleshooting guide below and don't forget to report your trouble! The Synchronized Motor support has not been extensively tested for accuracy. It seems to mostly work well but the accuracy of the braking function and the closeness of the two motors to each other have not been given a formal scientific assessment. NXT-Python has not been tested and may not work with custom nxt firmware versions (if you don't know what that means, you don't need to worry about it). However, if the firmware supports the standard LEGO USB/BT communications protocol, everything should more or less work. NXT-Python has been tested with bricks using LEGO firmware version up to 1.29 and is compatible with protocol version 1.124 (used by most if not all of the official firmwares). It has also been reported working with LeJOS. -=-=-If you co'd the SVN...-=-=- The arduino directory of an svn checkout (not included with release packages) contains a digital sensor unit test system called nxtduemu. It is intended for developers and advanced users who are looking to experiment with sensors and the digital sensor framework and classes. See Arduino/README for more info and usage instructions. Specific Stability Status: nxt.brick, nxt.telegram, nxt.direct, and nxt.system: Have been redone somewhat as of v2.2.0 but appear to work well. USB Communication System (nxt.usbsock) On Linux: Very stable and extensively tested. On Windows: Somewhat tested; seems to work pretty well. On Mac: Some users having problems. BlueTooth Communication System (nxt.bluesock, nxt.lightblueglue) On Linux: Stable; well tested with both pybluez and lightblue. On Windows: Stable; working last I checked. On Mac: Some users having problems. Internet Communications System (nxt.ipsock) Seems to work for the most part. Occasionally has hiccups. Fantom Communications System (nxt.fantomsock) On Linux: N/A (Fantom driver not supported) On Windows: Not tested. On Mac: Tested, USB interface working, Bluetooth not working. nxt.locator: Tested working with revamped logic and new code in v2.2.0. nxt.motor: Stable except for Synchronized Motor support, which is experimental at this stage and has not been extensively tested. nxt.sensor: Code not specific to a particular sensor is well-tested and working great. More than half of the sensor classes were last reported working; the rest have not to my knowlege been tested and were written blindly from the manuacturers' specifications. nxt.error: If there's a problem with this one, I'm gonna cry. Contact: NXT-Python's Head Developer: Marcus Wanner ([email protected]) The support and development mailing list: http://groups.google.com/group/nxt-python Report bugs and suggest new features at: http://code.google.com/p/nxt-python/issues/list Thanks to: Doug Lau for writing NXT_Python, our starting point. rhn for creating what would become v2, making lots of smaller changes, and reviewing tons of code. mindsensors.com (esp. Ryan Kneip) for helping out with the code for a lot of their sensors, expanding the sensors covered by the type checking database, and providing hardware for testing. HiTechnic for providing identification information for their sensors. I note that they have now included this information in their website. ;) Linus Atorf, Samuel Leeman-Munk, melducky, Simon Levy, Steve Castellotti, Paulo Vieira, zonedabone, migpics, TC Wan, jerradgenson, henryacev, Paul Hollensen, and anyone else I forgot for various fixes and additions. All our users for their interest and support! Troubleshooting Digital Sensors (don't read unless you have problems): If you are getting errors, strange behavor, or incorrect values from a digital sensor, chances are that there is a bug in our code. Follow these instructions to try and find out what's wrong: 1. Test the sensor with a different access library to make sure it's working right. 2. Check your code again. There are some weird "features" in the interfaces of some of the sensors; make sure you are doing things right. 3. Locate the sensor class's source code in nxt-python. It should be somewhere in nxt/sensor/<manufacturer>.py, under the heading "class SensorName( BaseDigitalSensor):". Read any comments for instructions on certain things. If you get to here and are still having a problem, you can either go ahead and report it now or continue to try and find and fix the problem and then report it (or not report it at all, but that wouldn't be very nice...). Python experience required beyond this point. 4. Get the sensor's specifications from the manufacturer's website. Make sure it includes a table of I2C registers and instructions for using them. 5. Pick one of the following depending on what the problem is: ####Errors: Cause: We screwed up. Solution: Check the line mentioned in the error for incorrect syntax or other problem. A bit of python experience and maybe some googling is needed here. ####Strange Behavior (in sensors with modes/commands): Cause: nxt-python's command enumerations are incorrect. Solution: Verify them using the sensor's specs, and correct any problems. See "Incorrect Values" for more. ####Incorrect Values: Cause: nxt-python is processing the value wrong. Solution: Check what goes on in the sampling method against what the spec says should be done. If there is an inconsistency, try to fix it. Cause: nxt-python has an incorrect register number or type in I2C_ADDRESS. Solution: Verify the address (the number) and the string (the struct format string). To verify the address, use the spec. To verify the struct format, you will need to read this: <http://docs.python.org/library/struct.html#format- strings> or have experience with struct. Read the spec for the sensor to determine how the given value should be read, then start at the sample method and read through it, checking for problems as you go. If it seems right, go back to the I2C_ADDRESS chunk (near the top of the class) and make sure that the correct struct format string is being used. The most common problem here is values that are off by plus or minus 128 or 32768 because of an incorrect signed/unsigned setting. This can be fixed by switching the case (as in upper or lower) of the letter in the string. Other problems could include the wrong size (B, H, or L) being used, or, in the two latter ones, the wrong byte order (< or >). As always, common sense required.
I have attached a patch that provides the methods for the hitechnic
gyro sensor. I haven't had time to add the calibration function yet but I
hope to do that in a couple days.
this is the description included in the class header
#This class is for the hitechnic gryo accelerometer. When the gryo is
#not moving there will be a constant offset that will change with
#temperature and other ambient factors. It might be appropriate to
#write a calibration function to account for this offset.
#
#TODO:calibration
Original issue reported on code.google.com by [email protected]
on 9 Jun 2010 at 1:27
Attachments:
Hey guys,
I've just been reading through the sensor.py code (current trunk). I might've
spotted a way to reduce the number of direct commands necessary to retrieve a
sample from a digital sensor. In Bluetooth connections (which are fairly slow
as you probably know), this can sometimes/often save one out of 3 direct
commands and reduce the time to query a digital sensor by roughly 30ms.
I'm not sure if I understood the whole nxt-python package correctly, but I
assume that all sample retrieval communication with digital sensors is
happening through the method "i2c_query()" from the class DigitalSensor (here:
http://code.google.com/p/nxt-python/source/browse/trunk/nxt/sensor.py#128 ). If
that's correct, then in line 135, _ls_get_status() get's called, which seems to
do busy waiting until the I2C bus / the sensor has finished its current
operation. Only when enough bytes are ready (or in case of a timeout), the
polling (direct command LSGetStatus) will stop.
Now the point: If LSGetStatus tells you "everything ok, data ready to be
retrieved", you have to issue the direct command LSRead. This is where you can
save time. You can totally ignore the LSGetStatus commands, and allways try
LSRead straight away. As long as there isn't enough data, you can detect this
situation from the status byte of the reply package. But if you're lucky, i.e.
once the sensor is ready, you already got the valid data as payload. In summary
this saves 1 command.
We've been using this method for a long time successfully, and it did greatly
improve the performance with all digital sensors (the US being most widely
used).
An implementation example with further explanations and some statusbyte-codes
can be found here:
http://www.mindstorms.rwth-aachen.de/trac/browser/tags/version-4.03/RWTHMindstor
msNXT/COM_ReadI2C.m#L139
I'd love to see you guys use that principle and see if you can improve your
Bluetooth performance. If not that's fine, but you could keep this in mind and
maybe on the to-do-list.
Thanks for reading.
Regards, Linus
Original issue reported on code.google.com by [email protected]
on 19 Aug 2010 at 12:36
I have attached a patch that provides the methods for the new lego NXT
color sensor. I haven't had time to add the calibration function yet but I
hope to do that in a couple days.
this is the description included in the class header
# this is a class for the lego NXT 2.0 RGB color sensor
# not to be confused with the hitechnic color sensor
# the color sensor can run in two modes:
# a light sensor which returns the reflected light from the lamp that is
# currently on (red, green, blue, off/ambient) on a scale of 1-1023
# a color sensor that returns a 1-6 decimal value corresponding to
# (black, blue, green, yellow, red, white) unfortunately the RGB values
# are not sent over the wire
# TODO: calibration
#note: if you create a new object everytime you make a call the light
# will flash on an off because each time the object is created the light
# color is set to none
Original issue reported on code.google.com by [email protected]
on 7 Jun 2010 at 2:57
Attachments:
Describe the new feature more precisely.
(Not sure, if this makes sense, and how much effort it would take to implement.)
I would like to have an API like this:
brick.startRecord(keepRunning)
[...]
prog = brick.stopRecord()
brick.upload(prog, "foo")
brick.run("foo")
`keepRunning` = False would only record all commands, but not execute them.
Why do you think it's important?
I used NXT-Python to drive a logo-'turtle'. This means mainly sending a
sequence of forward(10) - left(90) - pendown() - ...
When controlling the robot, we need a USB cable which is uncomfortable, or
bluetooth which is not always available (and uses batterie and is less
accurate?)
Any ideas on how to implement it?
If a program is only a list of telegrams as they are currently generated and
sent to the brick, then it may be possible to simply buffer them?
If not, then I guess its probably not worth the effort.
Also, this would not allow to react on sensors, but there are use cases where a
simple play-back would be nice.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 24 Oct 2010 at 3:15
After performing some tests I noticed that the loop time from data requested to
data received for a sensor with USB is ~10-20ms but with bluetooth it is
~100-150ms . This doesn't seem correct. Bluetooth can transmit and receive data
much faster than this.
Original issue reported on code.google.com by [email protected]
on 20 Jul 2010 at 6:35
I am working through trying to use python to run my NXT (Lejos is currently
what is running on the NXT) but am just starting out. Please forgive the basic
question, but what firmware do I need to start with?
I am on Windows XP using the nxt-python 2.2.0
Original issue reported on code.google.com by [email protected]
on 16 Aug 2011 at 10:59
Describe the new feature more precisely.
Uploading the package to PyPI would allow simple installation for those that
have EasyInstall running:
$sudo easy_install nxt-python
Any ideas on how to implement it?
Add 'register upload' to the command line when calling setup.py sdist
Original issue reported on code.google.com by [email protected]
on 24 Oct 2010 at 2:53
Describe the new feature more precisely.
Currently the Method() backend selection needs to be specified for
find_one_brick().
It should be specified either via configuration parameters or at the beginning
of the program.
Why do you think it's important?
Easy to modify / change backend without touching other code.
Any ideas on how to implement it?
Configure file, command line parameter, configuration method at begnning of
program.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 3 Jun 2011 at 9:52
here is a stack trace:
sensor = Ultrasonic( BRICK, inPort)
File "nxt-my\nxt\sensor\generic.py", line 95, in __init__
super(Ultrasonic, self).__init__(brick, port, check_compatible)
File "nxt-my\nxt\sensor\digital.py", line 73, in __init__
sensor = self.get_sensor_info()
File "nxt-my\nxt\sensor\digital.py", line 156, in get_sensor_info
version = self.read_value('version')[0].split('\0')[0]
File "nxt-my\nxt\sensor\digital.py", line 143, in read_value
raise I2CError, "read_value timeout"
this is with Mindstorm 1.0 and nxt-python-2.2.1 on Windows-7, brick is
connected via USB
The problem seems to go away if I insert a 10 ms delay between i2c write and
read in _i2c_query in sensor/digital.py
self.brick.ls_write(self.port, msg, n_bytes)
sleep(0.01)
try:
self._ls_get_status(n_bytes)
If I skip the version check, I can still use the sensor without the delay. (but
get_sensor_info() still does not work).
A similar problem happens when trying to get info from hitechnic color sensor.
get_sensor_info() times out...
But if I skip the version check, then I get a timeout when trying to retrieve
color information..
Inserting a delay of 15ms solves the problem..
And the last tidbit: if I initialize the color sensor as Ultrasonic one and
skip the version check, then get_distance() works even without delay.
Original issue reported on code.google.com by [email protected]
on 4 Dec 2011 at 7:56
I found that there is an indentation problem at the definition of method:
def reset_position(self, relative):
inside the file motor.py
Thank you!
Original issue reported on code.google.com by [email protected]
on 14 Sep 2009 at 9:22
What steps will reproduce the problem?
1. compass = hitechnic.Compass(brick, sensor.PORT_2)
2. compass.get_heading()
3. compass.set_mode(compass.Modes.CALIBRATE)
What is the expected output? What do you see instead?
Heading in degrees from North. An incorrect value is returned instead. So I
tried to calibrate the compass, and got the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "nxt/sensor/hitechnic.py", line 85, in set_mode
if mode != CompassMode.MEASUREMENT and \
NameError: global name 'CompassMode' is not defined
What version of nxt-python are you using? On what operating system?
revision 277 on Ubuntu 10.10
Please provide any additional information below.
Before calibrating the compass, I modified Compass.get_heading() to use the two
degree heading and adder instead of the low byte from register 0x44 (which
didn't appear to fully correspond with the spec).
Upon attempting to calibrate the compass, I discovered another bug, resulting
in the above exception. I also fixed this. I'm unsure if the original
get_heading() method would work now as well, but the modified method tests out
ok, so I suggest sticking with it.
Original issue reported on code.google.com by [email protected]
on 23 Jan 2011 at 5:00
Attachments:
Describe the new feature more precisely.
I have an NXT (v1) Lego set. I am recently begun learning Python. I want to
use the software you are developing. I have installed the software on my
laptop. Now what?
I would like some very basic, even condescending documentation, on how to
use this software -- perhaps an example or two with step-by-step
instructions on how to implement them would be helpful.
Why do you think it's important?
Lowering the barrier for entry will enable an increase in popularity which
should in turn result in a) people helping you with the project, and b)
people telling you how great you are for developing the project and sharing
your efforts with all of us -- it is nice to be appreciated.
Any ideas on how to implement it?
Ask someone who knows considerably less than you to try out this software;
whenever they say "What do I do now?" respond to them via the project wiki : )
Original issue reported on code.google.com by [email protected]
on 25 Mar 2010 at 7:05
To include the Hitechnic Tetrix controller for the NXT DC and servo controller
form Hitechnic
Why do you think it's important?
the exposure of Tetrix/NXT make the next level of robot enthusiasts, and with
the addition of ROS and other ROS nodes will make the NXT/Tetrix a suitable
platform to do basic research in robotics
Any ideas on how to implement it?
I don't have to much experience in this implementation that's why I'm asking
your help
Thanks
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 23 Nov 2010 at 8:29
What steps will reproduce the problem?
1. Attempt to instantiate nxt.sensor.hitechnic.EOPD:
import nxt
from nxt import sensor
from nxt.sensor import hitechnic
brick = nxt.find_one_brick()
laser = hitechnic.EOPD(brick, sensor.PORT_3)
What is the expected output? What do you see instead?
An EOPD object should be created; instead, the following exception is raised:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "nxt/sensor/hitechnic.py", line 245, in __init__
super(Light, self).__init__(brick, port)
NameError: global name 'Light' is not defined
What version of nxt-python are you using? On what operating system?
I'm using nxt-python version 2.0.1 on Ubuntu 10.10 64-bit. I also tested the
latest source code from the Subversion repo (revision 273), with the same
result.
Original issue reported on code.google.com by [email protected]
on 22 Jan 2011 at 11:25
Instead of the server module accepting string instructions, there shouldbe a
modified brick class that does all the communication. Essentially, if you
wanted to use an nxt on the server, you would create the
locator.get_network_brick() class instead of locator.find_one_brick(). Then,
functions linked to the network_brick class would simply be a server
implementation of the methods.
Another way to do this by transferring strings would be to transfer the
commands in python syntax as a string.
Original issue reported on code.google.com by [email protected]
on 22 Aug 2010 at 9:11
Hi,
I'm just an nxt beginner, so I just tried the examples.
Everything is ok, I just felt like contributing some minor pythonistic
enhancements to the mary.py example.
I introduced a loop that makes this file less verbose.
See the attached patch.
Original issue reported on code.google.com by [email protected]
on 29 Jun 2012 at 8:14
Attachments:
What steps will reproduce the problem?
1. Run nxt_test with fantom backend
2. Correct output is returned
3. Re-run nxt_test with fantom backend
4. nxt_test aborts with Fantom error
What is the expected output? What do you see instead?
Multiple sequential runs of nxt_test to return correct output.
This is due to a missing b.sock.close() for the normal execution case.
(proposed patch enclosed). I think the other scripts might also be similarly
impacted but I didn't test them.
Index: nxt_test
===================================================================
--- nxt_test (revision 364)
+++ nxt_test (working copy)
@@ -24,6 +24,7 @@
print 'Firmware version %s.%s' % fw_version
millivolts = b.get_battery_level()
print 'Battery level %s mV' % millivolts
+ b.sock.close()
except:
print "Error while running test:"
traceback.print_tb(sys.exc_info()[2])
Original issue reported on code.google.com by [email protected]
on 8 Jul 2011 at 3:36
I attempted to run the examples after having installed python2.6,
nxt-python-2.2.0, and pyUSB on my laptop (Windows 7 if that makes a
difference). I installed those and tried running the examples, starting with
spin.py.
When I try to connect to the brick using USB I get the "No back end" error.
"USB module unavailable, not searching there Bluetooth module unavailable, not
searching there".
I saw that there is a warning with the USB connection being buggy, so I purchased a bluetooth adapter for my laptop and installed it. I am able to pair with the brick via bluetooth, but when I run spin.py I get a different error, "USB module unavailable, not searching there". No longer does it mention Bluetooth being unavailable. And at the bottom it reads "BrickNotFoundError"
Any help? Thank you very much!
(appologies for not copy-pasting the exact errors but I am typing this from a
different machine as my laptop does not have internet at this moment).
Original issue reported on code.google.com by [email protected]
on 24 Aug 2011 at 5:12
Please relicense python-nxt to the LGPL because if it is gpl devlepoers are
forced to license their software GPL and cant combine gpl-incompatible software
with python-nxt
Original issue reported on code.google.com by samu.agarwal
on 12 Sep 2011 at 5:59
What steps will reproduce the problem?
1. Connect an NXT with USB.
2. Read Identification information from sensor.
What is the expected output? What do you see instead?
It should be like this:
Version: `V1.0`
0x56, 0x31, 0x2e, 0x30,
Product ID: `LEGO`
0x4c, 0x45, 0x47, 0x4f,
Type: `Sonar`
0x53, 0x6f, 0x6e, 0x61, 0x72,
But instead is like this:
Version: `Sonar`
0x53, 0x6f, 0x6e, 0x61, 0x72,
Product ID: `V1.0`
0x56, 0x31, 0x2e, 0x30,
Type: `LEGO`
0x4c, 0x45, 0x47, 0x4f,
As you can see, the version is replaced with the type, the manufacturer with
the version and the type with the manufacturer. It is as if each one is shifted
8 registers down and the last one is looped back to register 0. Why the heck is
this happening?
Please use labels and text to provide additional information.
The only explanation I can think of is that there is less latency when using
USB, but adding gaps in various places doesn't do anything.
Could someone on Windows or Mac please test this and see if it's everywhere or
just Linux?
Original issue reported on code.google.com by [email protected]
on 1 Sep 2010 at 4:15
What steps will reproduce the problem?
1. Install nxt-python
2. Install pyUSB
3. Attempt to run file from examples folder
What is the expected output? What do you see instead?
The expected output would be to successfully run the file (Ex: mary.py).
However, with all files, I receive the following output:
Host: 54:32:59:92:F9:39 Name: MyNXT Strict: True
USB: True BT: False Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
File "C:\Users\Student\Downloads\nxt-python-2.2.1 (1)\nxt-python-2.2.1\examples\mary.py", line 15, in <module>
b = nxt.locator.find_one_brick(debug=True)
File "C:\Python26\lib\site-packages\nxt\locator.py", line 137, in find_one_brick
raise BrickNotFoundError
BrickNotFoundError
(This is with passing debug=True)
What version of nxt-python are you using? On what operating system?
2.2.1, Windows 7
I realize it was stated using USB is buggy, but I would like to continue trying
to use it.
Original issue reported on code.google.com by [email protected]
on 26 Jan 2012 at 3:32
Hi,
I'm just an nxt beginner, so I just tried the examples.
Everything is ok, I just felt like contributing some minor formatting issues in
the example files.
I added some «#/usr/bin/env python» and
#comment
is now
# Comment.
See the attached patch.
Original issue reported on code.google.com by [email protected]
on 29 Jun 2012 at 8:00
Attachments:
What steps will reproduce the problem?
1. Examine the code.
2. Look at nxt/fantomsock.py line 46
3. See that it says: paired_addr = pair_bluetooth(addr)
4. Look for where pair_bluetooth is defined
What is the expected output? What do you see instead?
I would expect to find the function defined, but I don't. It turns out
pyfantom has such a function, so I think this is meant to be
pyfantom.pair_bluetooth.
What version of nxt-python are you using? On what operating system?
Version is 2.2.1. O/S is Linux (so this file isn't actually used). The error
was detected through an automated test.
Original issue reported on code.google.com by [email protected]
on 18 Mar 2012 at 2:16
What steps will reproduce the problem?
1. in motcont, ports 3 4 and 5 refer to multiple motors and if one activates
them, the "interval" is tracked for such port rather than for the motors
individually
2. so if one gives a command to ports 3, 4 or 5 and immediately after sends a
command to a single motor, the pause that motcont needs for that motor is not
enforced.
3. also, it would be more elegant/integrated in NXT-Python to use PORT_A +
PORT_B + PORT_B (which is "7") instead of "5" when giving orders to multiple
motors.
What is the expected output? What do you see instead?
What version of nxt-python are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 16 Oct 2012 at 9:46
It would be nice to have a driver-like socket interface function, meaning
that it would be easily usable over networks and different programming
languages.
It would use a command-type interface. Example:
<python>
import socket
com = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
com.bind(('localhost', 98712))
com.connect()
com.send('find_brick') #connect to brick command, this would cause the
driver to do x = find_one_brick()
rslt = com.recv(1) #get return code
if rslt != 0:
print 'no brick found.'
exit(1)
com.send('get_light_sample') #would trigger a get_sample() routine
dist = com.recv(10)
print dist
com.send('close_brick_sock') #would trigger brick's close() command
com.close()
</python>
There would be many commands, including 'kill_server', to be called when
the server has done its job.
To start the server, one would use, in a separate program:
<python>
import nxt.server
nxt.server.serve_forever()
</python>
I'll see what I can do to get started on this, it might take a while
because of socket and thread things. However, a single-thread server will
robably be relatively easy.
Original issue reported on code.google.com by [email protected]
on 4 Feb 2009 at 6:21
Oops! Looks like that last revision generated another bug.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "nxt/__init__.py", line 17, in <module>
from .sensor import *
File "nxt/sensor/__init__.py", line 32, in <module>
import hitechnic
File "nxt/sensor/hitechnic.py", line 244
from math import sqrt
Attached is a Subversion patch.
Original issue reported on code.google.com by [email protected]
on 23 Jan 2011 at 1:41
Attachments:
When I run the CNC example, it finds the brick over bluetooth and connects, but
the motors never spin. and I get about 2000 lines that look like this.
2011-04-08 15:31:57.844 Python[57997:7307] *** __NSAutoreleaseNoPool(): Object
0x103c89ac0 of class __NSCFDate autoreleased with no pool in place - just
leaking
The program stops after 4 seconds like it's supposed to.
What version of nxt-python are you using?
The latest SVN checkout
On what operating system?
Mac 10.6.6
Original issue reported on code.google.com by [email protected]
on 8 Apr 2011 at 10:37
My robotics group has been using RobotC for a long time, so we got HiTechnic
motors to make our robot faster. However, I want to use python but can not find
a way, in nxt-python to use our HiTechnic motors. I found nxt.sensors.hitechnic
but it isn't a sensor?
If there is a way to get HiTechnic motors to work, can I see an example? Our
motors are attached to PORT_1 (and only that, that's why I don't get to use it
from the examples haha)
Original issue reported on code.google.com by [email protected]
on 22 Mar 2012 at 6:28
What steps will reproduce the problem?
1. I have tried to import the file "tiltedtwister.rxe" (
http://tiltedtwister.com/download/tt2/tiltedtwister.zip ) on nxt 2.0
2. I use the command py-t2n -put tiltedtwister.rxe on ubuntu.
What is the expected output? What do you see instead?
This fails, and I obtain:
--------------------------------------------------------------------
>$ py-t2n -put tiltedtwister.rxe
Unexpected error
Traceback (most recent call last):
File "/usr/local/bin/py-t2n", line 99, in
put(b, f)
File "/usr/local/bin/py-t2n", line 67, in put
w = FileWriter(b, fname, len(data))
File "/usr/local/lib/python2.7/dist-packages/nxt/brick.py", line 150, in __init__
self.handle = self.brick.open_write(fname, size)
File "/usr/local/lib/python2.7/dist-packages/nxt/brick.py", line 31, in poll
return parse_func(igram)
File "/usr/local/lib/python2.7/dist-packages/nxt/system.py", line 47, in _parse_open_write
tgram.check_status()
File "/usr/local/lib/python2.7/dist-packages/nxt/telegram.py", line 114, in check_status
nxt.error.check_status(self.parse_u8())
File "/usr/local/lib/python2.7/dist-packages/nxt/error.py", line 85, in check_status
raise ex
nxt.error.SysProtError: No space
Exception AttributeError: "'FileWriter' object has no attribute 'handle'" in > ignored
---------------------------------------------------------------------------------
Additional remarks:
1) I have imported several files with extension .rxe with similar size on the
brick and this works.
2) I have suppress some files from nxt to make more space (as suggested by the
last line "nxt.error.SysProtError: No space"... but no way.
thank you in advance for your help
with best regards
jgl
Original issue reported on code.google.com by [email protected]
on 25 Feb 2012 at 10:35
What steps will reproduce the problem?
1. instantiate EOPD object
2. call EOPD.get_processed_value()
What is the expected output? What do you see instead?
A value that scales linearly as the distance from the target changes is
expected. An erratic or unchanging value is returned instead.
What version of nxt-python are you using? On what operating system?
Revision 275 on Ubuntu 10.10
Please provide any additional information below.
I've attached a Subversion patch.
Original issue reported on code.google.com by [email protected]
on 23 Jan 2011 at 2:47
Attachments:
What steps will reproduce the problem?
1. install libusb-win32 (on 32-bit or 64-bit Windows)
2. try to connect to NXT
3. connection fails because usb device is unconfigured
What version of nxt-python are you using? On what operating system?
nxt-python 2.2.0 on Win7 x64
Please provide any additional information below.
patch for usbsock.py:
>import os
...
def connect(self):
...
>if os.name != 'nt':
self.handle.reset()
see http://sourceforge.net/apps/trac/libusb-win32/wiki/libusbwin32_documentation
usb_reset() ... "Causes re-enumeration: After calling usb_reset, the device
will need to re-enumerate and thus requires you to find the new device and open
a new handle. The handle used to call usb_reset() will no longer work."
Original issue reported on code.google.com by [email protected]
on 7 Oct 2011 at 7:55
I had trouble getting BlueTooth to work on OS X 10.8 because it seems that none
of the bluetooth libraries are supported any more. However, I noticed that
when I paired my NXT with my Mac it created a device file corresponding to the
bluetooth serial port. I whipped up a simple 'socket' class to communicate via
the device file, and it seems to work. By default it searches for the first
device that matches the pattern "/dev/*-DevB" because mine came up as
"/dev/<BrickName>-DevB"; not sure if that's standard or not. Anyway, the patch
is here:
https://github.com/dgchurchill/nxt-python/commit/d3573d36c18064e6250833967c53694
494068456.patch
Cheers,
Dave
Original issue reported on code.google.com by [email protected]
on 22 Jan 2013 at 11:09
What steps will reproduce the problem?
1.import nxt
What is the expected output? What do you see instead?
Expected Output:
Instead:
SyntaxError
What version of nxt-python are you using? On what operating system?
I am using version 2.0.1 on Mac OSX G4 with Bluetooth.
Please provide any additional information below.
I think you would have to do this code:
try:
import nxt
except SyntaxError:
import nxt
As you may have figured out, it doesn't work if you do it one time but it does
if you do it 2 times.
Original issue reported on code.google.com by [email protected]
on 28 Dec 2010 at 7:44
What steps will reproduce the problem?
1. Run test_sensors.py
2. See crash
{{{
$python test_sensors.py
Touch: no
Light: 1023
Ultrasonic:
Traceback (most recent call last):
File "test_sensors.py", line 20, in <module>
test_sensors(sock.connect())
File "test_sensors.py", line 16, in test_sensors
print 'Ultrasonic:', UltrasonicSensor(b, PORT_3).get_sample()
File "/u/tfoote/nxt_devel/nxt/nxt_python/src/nxt/sensor.py", line 262, in
get_sample
return self.get_measurement_byte_0()
File "/u/tfoote/nxt_devel/nxt/nxt_python/src/nxt/sensor.py", line 79, in
query
data = self.i2c_query(address, n_bytes)
File "/u/tfoote/nxt_devel/nxt/nxt_python/src/nxt/sensor.py", line 122, in
i2c_query
self.brick.ls_write(self.port, msg, n_bytes)
File "/u/tfoote/nxt_devel/nxt/nxt_python/src/nxt/brick.py", line 24, in
poll
return parse_func(igram)
File "/u/tfoote/nxt_devel/nxt/nxt_python/src/nxt/direct.py", line 28, in
_parse_simple
tgram.check_status()
File "/u/tfoote/nxt_devel/nxt/nxt_python/src/nxt/telegram.py", line 112,
in check_status
nxt.error.check_status(self.parse_u8())
File "/u/tfoote/nxt_devel/nxt/nxt_python/src/nxt/error.py", line 85, in
check_status
raise ex
nxt.error.I2CError: Specified channel/connection not configured or busy
}}}
What is the expected output? What do you see instead?
{{{
$python test_sensors.py
Touch: no
Light: 1023
Ultrasonic: 7
}}}
What version of the product are you using? On what operating system?
This nxt-python-1.1.1 on Ubuntu Karmic64
Please provide any additional information below.
Doing some research it seems that there is a problem with requesting things
too fast. There are various discussions on nxtasy.org such as
http://forums.nxtasy.org/index.php?showtopic=2940 and
http://forums.nxtasy.org/index.php?showtopic=4153
Attached is our workaround. It's not likely the best place or time, but it
does make things work reliably. We will try to clean it up. If anyone
else has seen this or has suggestions on the best way to deal with this
please reply here.
Original issue reported on code.google.com by Tully.Foote
on 4 Jun 2010 at 11:59
Attachments:
What steps will reproduce the problem?
1.import the IRseekerv2 class
2.using the get_ac_values def
3.run program connected to brick an irseeker
What is the expected output? What do you see instead?
the direction and sensor values. Output is instead nxt.hitechnic.ACData
instance at a hexadecimal addresses which at the time I dont remeber what it
was.
What version of nxt-python are you using? On what operating system?
I'm using 2.1.0 on ubuntu version 10.0.4
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 30 Jun 2011 at 10:28
I am new to PYNXC.
On directly using the examples program without modification, i get the below error :
NoBackendError("No selected backends are available! Did you install the comm
modules?")
Should I install something in extra ?
Regards
Praveen
Original issue reported on code.google.com by [email protected]
on 2 Aug 2011 at 1:01
1. Enable several bluetooth devices near the computer
2. try locator.find_bricks() - it will return all of them
3. try locator.find_one_brick() - it will try to get a random device and will
raise an exception if connection fails (i.e. that random device is not paired).
A simple, but not clean though way to eliminate the problem is to ensure that
device's name is "NXT". At least the module wouldn't try to connect to
stranger's laptops.
Original issue reported on code.google.com by m%[email protected]
on 9 Nov 2010 at 2:25
What steps will reproduce the problem?
1. the mocont web page mentions ways to cancel commands that are being executed
by motors. This seems to be missing in motcont.py
It is an important functionality to implement: I am happy to do it if you give
me advice, Marcus.
What is the expected output? What do you see instead?
I expected to see all the functionalities of Motcontrol implemented as from
their web page.
I was expected to be able to cancel a command, like it is done in :
http://www.mindstorms.rwth-aachen.de/trac/browser/trunk/mfiles/%40NXTMotor/Stop.
m
Basically cancelling a command and stopping, without active breaking.
What version of nxt-python are you using? On what operating system?
Win7x64 nxt-python-2.2.2 bluetooth python 2.6
Please provide any additional information below.
I am referring to:
http://www.mindstorms.rwth-aachen.de/trac/wiki/MotorControl
"
Cancelling commands
When a certain motor is running, you can always cancel the current operation by
sending two types of "stop" commands. By "stop" I just mean a certain parameter
combination for SetOutputState. If you want to stop multiple motors, you have
to send a direct command to each one of them. The MotorControl program will
recognize this "cancellation request" and stop the control algorithm.
Reference implementation: @NXTMotor/Stop.m
We've got:
Stopping (coasting)
This means turning off power to a motor, leaving it spinning freely (coasting).
To do this, the corresping NXC-code looks like this:
SetOutput(port, Power, 0, OutputMode, OUT_MODE_COAST, RegMode,
OUT_REGMODE_IDLE, RunState, OUT_RUNSTATE_IDLE, UpdateFlags, UF_UPDATE_MODE +
UF_UPDATE_SPEED);
This is basically just setting a power of 0 and setting everything else to OFF
or IDLE…
Active braking
[...]
"
Original issue reported on code.google.com by [email protected]
on 15 Oct 2012 at 7:23
What steps will reproduce the problem?
1. run cnc.py on Windows 7 via Bluetooth on NXT latest standard firmware
2.
3.
What is the expected output? What do you see instead?
I expect to see two motors moving at the same time. I see one motor moving and
an error message as soon as the second motor is supposed to move.
What version of nxt-python are you using? On what operating system?
Win7x64 (but all sw installed as 32bit) Python 2.6Win32 PyBluez_win32_py2_6
PyScripterWin32
Please provide any additional information below.
*** Remote Interpreter Reinitialized ***
>>>
Tick 0
Tick 1
Unhandled exception in thread started by
Traceback (most recent call last):
File "<string>", line 532, in write
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 439, in _async_request
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 229, in _send_request
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 244, in _box
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\brine.py", line 369, in dumpable
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\brine.py", line 369, in <genexpr>
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\brine.py", line 369, in dumpable
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\brine.py", line 369, in <genexpr>
File "D:\_DOCUMENTS\_Learning_Python\Nxt20\cnc.py", line 16, in turnmotor
m.turn(power, degrees)
File "C:\Python26\Lib\site-packages\nxt\motor.py", line 211, in turn
raise BlockedException("Blocked!")
nxt.motor.BlockedException: Blocked!
Tick 2
Tick 3
Tick 4
>>>
Original issue reported on code.google.com by [email protected]
on 15 Oct 2012 at 2:25
is it possible to program the lego nxt robot to move in a square motion forming
a square based on odometry theory?
Original issue reported on code.google.com by [email protected]
on 27 Aug 2012 at 11:23
Describe the new feature more precisely.
Add a parameter to find_one_brick and find_bricks to disable preliminary error
output. (Such as USB not available) Of course, keep the catchall that throws an
official error. Another option would be to have a global nxt module variable
that specifies if output is requested.
Why do you think it's important?
It would allow automated programs to look more professional and output their
own error codes.
Any ideas on how to implement it?
Just add a parameter output=True to the functions, and have find_one_brick pass
to find_bricks. All outputs would then be wrapped with an if block.
Please provide any additional information below.
This is a quick and low priority change that does not change the overall
function of the program at all.
Original issue reported on code.google.com by [email protected]
on 11 Nov 2010 at 2:58
Describe the new feature more precisely.
Being able to run the nxt-python using python 3.x
Are there any plans on adding support for 3.x?
Why do you think it's important?
I've wanted to write a motion control script for a long time using nxt and
blender. I just read this post
(http://www.eibriel.com/2012/05/06/camera-motion-control-controlling-steppers-wi
th-blender-tutorial/) and really inspired I thought I'd check out if I would be
able to control my nxt from within blender. Blender uses python 3.x so...
Any ideas on how to implement it?
Sadly no, but I haven't done to much research either..
Please provide any additional information below.
Thank you very much for your time and effort on this module!
Original issue reported on code.google.com by [email protected]
on 14 Feb 2013 at 7:58
What steps will reproduce the problem?
1. Connect a NXT brick
2. Move a motor
What is the expected output? What do you see instead?
The motor moves farther than it should, because it coasts after it goes
the specified distance. Ideally, it should move the specified distance,
then brake or coast (whichever the user wants it to do).
Please use labels and text to provide additional information.
The way to do this is the same way the NXT-G "IDE" does it:
1. Go specified distance.
2. Immediately go backwards a bit.
3. Check how for off the motor is from where it should be.
4. Correct the difference.
5. Repeat steps 3 and 4 until it is within about 3-5 degrees of perfect.
I'll be working on this. If anyone already has a program that does the
same thing, say something!
Original issue reported on code.google.com by [email protected]
on 31 Mar 2009 at 3:12
* Describe the new feature more precisely.
As it doesn't seem you are bogged down with issues, I thought I would like to
address the following issue.
I have created a multiple Thread program, which has threads for the sensors and
threads to control the motors. In this way I aim to continually pole the
sensors and stop the motors when I detect a certain event. However, I get a
datagram error as I am sending multiple requests to the NXT controller
simultaneously. Is there currently a way to have the NXT control module handle
requests in a queue?
* Why do you think it's important?
Would then be able to have multiple threads monitoring sensors and issuing
commands to the motors
* Any ideas on how to implement it?
Yes, although I usually get slated for my workarounds! :)
* Please provide any additional information below.
My idea would be to create a queue in the control module, and then process each
request when possible.
Original issue reported on code.google.com by [email protected]
on 16 Jul 2010 at 2:45
The culprit is here (I don't have the sensor so I can't check):
http://code.google.com/p/nxt-python/source/browse/trunk/examples/mindsensors/ACC
L.py#13
I tried a code review for this too.
Cheers.
Original issue reported on code.google.com by [email protected]
on 30 Jun 2012 at 6:16
I thought I'd respond to:
https://code.google.com/p/nxt-python/issues/detail?id=18
As I have such hardware.
First run: http://sprunge.us/FRJI (motor controller first in chain) (set_power
worked as expected)
Second run: (motor controller second in chain) http://sprunge.us/fjaA
(set_power worked, but nothing else)
I thought I might mention as of something like 10 days ago, the lejos SVN has
100% working drivers for these controllers. I don't have an encoder, so I can't
test that functionality, but aside from that, I'd be happy to work with any
improvements you might consider making for this.
Original issue reported on code.google.com by [email protected]
on 27 Jul 2012 at 12:48
What steps will reproduce the problem?
1. Install pyusb
2. Install nxt-python
3. run `python spin.py`
What is the expected output? What do you see instead?
Traceback (most recent call last):
File "spin.py", line 12, in <module>
b = nxt.locator.find_one_brick()
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 112, in find_one_brick
for s in find_bricks(host, name, silent, method):
File "/Library/Python/2.7/site-packages/nxt/locator.py", line 43, in find_bricks
for s in socks:
File "/Library/Python/2.7/site-packages/nxt/usbsock.py", line 84, in find_bricks
for bus in usb.busses():
File "/Library/Python/2.7/site-packages/usb/legacy.py", line 333, in busses
return (Bus(),)
File "/Library/Python/2.7/site-packages/usb/legacy.py", line 329, in __init__
self.devices = [Device(d) for d in core.find(find_all=True)]
File "/Library/Python/2.7/site-packages/usb/core.py", line 846, in find
raise ValueError('No backend available')
ValueError: No backend available
What version of nxt-python are you using? On what operating system?
Mac OS X 10.7.2 with nxt-python 2.2.1
Please provide any additional information below.
NXT is turned on and connected. Same steps work on Linux.
PyFantom does not get detected, LightBlue does not even install. I'm able to
control the NXT with remote control software.
Original issue reported on code.google.com by pepijndevos
on 25 Nov 2011 at 12:19
The three provided scripts (nxt_push, nxt_filter and nxt_push) use the
unportable shebang line. This cuases problems when people use the script in a
nonstatndered environment, such as running scripts from inside "~/bin" in
restricted enviroments.
Implementing the fix below should unaffect any modern system but provide extra
portability.
change #!/usr/bin/python
to #!/usr/bin/env python
Original issue reported on code.google.com by [email protected]
on 3 Feb 2011 at 2:46
the method read_values is missing from the Accelerometer class.
File "/usr/local/lib/python2.6/dist-packages/nxt/sensor/hitechnic.py", line 73, in get_acceleration
xh, yh, zh, xl, yl, zl = self.read_values('all_data')
AttributeError: 'Accelerometer' object has no attribute 'read_values'
Original issue reported on code.google.com by [email protected]
on 6 Jul 2010 at 5:52
What steps will reproduce the problem?
1.Install Python 2.7.2
2.Install PyUSB 1.0.0a2 to python 2.7.2 directory
3.Run installer for nxt-python 2.2.1
What is the expected output? What do you see instead?
Expected successful installation of nxt-python. Instead console produced the
following:
Traceback (most recent call last):
File "P:\Pythin27\lib\site.py", line 563, in <module>
main()
File "P:\Pythin27\lib\site.py", line 552, in main
aliasmbcs()
File "P:\Pythin27\lib\locale.py", line 15, in <module>
File "P:\Pythin27\lib\encodings\)__init__.py", line 32, in <module>
from encodings import aliases
ValueError: bad marshal data (unknown type code)
-=-=-=-=-=-=-=-=-=-=-
There was an error during the installation.
Please check the above text for more information.
Press any key to continue...
What version of nxt-python are you using? On what operating system?
Version 2.2.1 on Windows XP
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 10 Jan 2012 at 7:41
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.