Running Python on your NXT
-
- Posts: 3
- Joined: 13 Dec 2011, 23:55
Running Python on your NXT
Hi,
I started to write a new firmware which runs python. Actually it should only run compiled python programs (the ones from CPython) due to memory restrictions. I'll use PyMite, a python VM for embedded systems, which already has nice support for AT91SAM7S256. For the base OS and hardware drivers I'll use NxOS since it has very clean code and it's easy to create new kernels with it.
I'll also try to keep the USB/Bluetooth interface compatible with the one of the LEGO firmware and I'll use the same file formats for image, sound, melody files, etc.
Nevertheless I don't really know how fast this will run and how big programs could be. So this will be rather experimental. But I'm very optimistic and for as a python fan I just can't wait to run some python code on my NXT
Preliminary project name is "PythoNXT" short for Python on NXT. At the moment I haven't done very much, except setting up a development environment and writing a simple test program combining PyMite and NxOS. Now I first have to wait for LEGO to replace my NXT, since my display is broken.
I started to write a new firmware which runs python. Actually it should only run compiled python programs (the ones from CPython) due to memory restrictions. I'll use PyMite, a python VM for embedded systems, which already has nice support for AT91SAM7S256. For the base OS and hardware drivers I'll use NxOS since it has very clean code and it's easy to create new kernels with it.
I'll also try to keep the USB/Bluetooth interface compatible with the one of the LEGO firmware and I'll use the same file formats for image, sound, melody files, etc.
Nevertheless I don't really know how fast this will run and how big programs could be. So this will be rather experimental. But I'm very optimistic and for as a python fan I just can't wait to run some python code on my NXT
Preliminary project name is "PythoNXT" short for Python on NXT. At the moment I haven't done very much, except setting up a development environment and writing a simple test program combining PyMite and NxOS. Now I first have to wait for LEGO to replace my NXT, since my display is broken.
Re: Running Python on your NXT
Very cool, I look forward to seeing what you'll do with this project!
- Xander
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
Re: Running Python on your NXT
can you pls explain with a few words which advantages (and disadvantages) Python has got compared to NXC or Java?
Re: Running Python on your NXT
Yeah, great attitude. Really liking this idea! . Make sure to keep us posted!janosch_graef wrote:But I'm very optimistic and for as a python fan I just can't wait to run some python code on my NXT
Biggest difference: Python is a weakly typed language (opposed to Java, C, NXC). Variables and function parameters don't get type information from the code, so simple example: You can pass a string or an integer. While you lose the compiler as safety net (no type checks), you gain flexibility.doc-helmut wrote:can you pls explain with a few words which advantages (and disadvantages) Python has got compared to NXC or Java?
This results in a flexible thing called "duck typing". If something acts like a duck, let's assume it's a duck. So if a method expects an object and calls its ".quack()" function, you can pass anything that has a .quack() function. You can even bind a quack-function dynamically to an object.
Another big pro is the "batteries included" principle: Huge standard library, well documented, always available (comparable to .net or Java).
Biggest disadvantage: Performance. It's slow. In Python you tend to write nice & compact code, but it's difficult to get a feeling for performance or "to write fast code" (but that's just my 2 cents).
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
-
- Posts: 3
- Joined: 13 Dec 2011, 23:55
Re: Running Python on your NXT
Development is delayed at the moment until I've got a new NXT (display broken). At the latest I'll start coding in February when semester break begins. Eventually, I can borrow another NXT from a friend until I got a new one, then of course I could start coding ealier.linusa wrote: Yeah, great attitude. Really liking this idea! . Make sure to keep us posted!
Of course I won't port all modules of CPython to the NXT. I'll port some standard modules: io, os, sys and of course I'll write a module for controlling the NXT (nxt.motor, .sensor, .usb, ...). And later I'll possibly write some modules like navigation, behaviour, AI, etc.linusa wrote: Another big pro is the "batteries included" principle: Huge standard library, well documented, always available (comparable to .net or Java).
If anyone wants to contribute to the project, I'll setup a GIT repository or even a Gobby server.
Re: Running Python on your NXT
Hi,janosch_graef wrote:Hi,
Preliminary project name is "PythoNXT" short for Python on NXT. At the moment I haven't done very much, except setting up a development environment and writing a simple test program combining PyMite and NxOS. Now I first have to wait for LEGO to replace my NXT, since my display is broken.
I'm using NxOS as the base for writing Assembly Language code on the NXT. Currently it is hosted on GitHUB as https://github.com/tcwan/nxos-armdebug.
I've developed a firmware-based ARM instruction Debugger for the NXT, which is present in the nxos-armdebug project. If you host your code on GitHUB, I'd be interested in tracking your progress, and it'd make code exchange easier. I've merged in most of the NxOS variants hosted on Github into my code base.
With nxos-armdebug, you can use the USB connection (via the Fantom Drivers + nxt-python 2.2+ http://code.google.com/p/nxt-python/) for debugging with GDB.
if you're interested in finding out more please contact me.
Unfortunately I don't think I can contribute actively to your project right now, Python is cool but I'm still trying to flesh out the ARM assembly stuff for teaching my university level course on ARM assembly language programming.
(There's not been any update to the repository for the past 3 months due to teaching commitments, I hope to resume after the start of the new year).
Re: Running Python on your NXT
Great project, I also thinks that NxOS is a good base for new firmwares.
I look forward to see the first steps!
I look forward to see the first steps!
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
Re: Running Python on your NXT
Howdy!
I look forward to seeing the results of this - I've become a recent Python convert.
I should note - I'm having some trouble finding Bluetooth drivers for Python on my 64 bit Windows 7 desktop. You may find yourself writing a driver .
Joe
I look forward to seeing the results of this - I've become a recent Python convert.
I should note - I'm having some trouble finding Bluetooth drivers for Python on my 64 bit Windows 7 desktop. You may find yourself writing a driver .
Joe
Re: Running Python on your NXT
I'm sorry to say, but you are about to try something impossible. The NXT doesn't have enough RAM to run a Python interpreter.
I used to work for several years on a Python interpreter port to a mobile device. We tried hard to squeeze it as small as possible, but even then it was hundreds of kilobytes at a minimum. The NXT has 64 kB.
I used to work for several years on a Python interpreter port to a mobile device. We tried hard to squeeze it as small as possible, but even then it was hundreds of kilobytes at a minimum. The NXT has 64 kB.
Re: Running Python on your NXT
After checking out the PyMite link, I sit corrected. Interesting!
Who is online
Users browsing this forum: Semrush [Bot] and 0 guests