Programing with Python

Does anyone know if it would be possible to program the NI CRIO using Python programming language? (www.python.org) I personally am a fan of labview, but many other memebers of the team prefer text-based programming. Of the different text-based programming languages avalible, Python is a favorite, and it’s wide range of use and extension modules have led us to believe that programming our robot with it would be possible. Assuming it’s possible, are there any already made Python modules for FRC?

Short answer, No

Long answer, NOOOOOOOOOOOOOOO :stuck_out_tongue:

Best bet would be to learn C++ and program the robot that way.

Middle Bet, write a library that makes programming similar to Python.

Longer bet would be write a way of compiling Python code to the C++ code then running it through the compiler that the C++ code uses.

Longest answer, write a compiler to compile to the CRIO assembly language…

Me? Id just learn C++.

There is currently no support in place for a python user.

To the best of my knowledge, there is no legal or technical reason that would preclude you from doing so. However, it would certainly require some doing and would require extensive C++ and python experience. If you are looking to do this because python is ‘easier’, turn back now. If you are doing this to score major geek points, be warned that upon success you will be overwhelmed with the downsides of awesomeness: Prepare yourself to fend off the fan(boy/girl)s.

The Java and C++ (and LV??) environments make calls into a unified block that handles the ‘sacred’ stuff, such as FPGA and field comm. Broadly (and slightly incorrectly) speaking, you could consider this unified block to be a dll or driver. Your python library would need to “simply” hook into this. No “cRIO assembly” required ;)!

My secret hope is that the community will develop a (e.g.) python environment next summer. It isn’t that I think python is better or worse than any of the other options, it is that I think it would be an amazing project with lots of community enhancing hidden benefits.

The point of python is to be extensible. Any way you could write it into a block inside a C++ program? You could possibly create macros/variables from C++, and then “do something” with them in the Python block. If you can interject the Python code into the C++ file, you should be able to “just” compile it, assuming the WindRiver compiler contains support for the Python wrapper. I’m not very familiar with the process of embedding languages, most I’ve really dealt with to any extent is wrapping assembly into C, so please forgive me if I’m way off.

The first thing you would have to do is port Python to vxworks on a power pc. A quick Google search shows several people asking about it, and there was even a patch set for a 10 year old version of python to a 10 year old version of vxworks, but that likely isn’t good anymore, not to mention the link is broken. I didn’t see anything from the last 5 years.

Once you’ve done that, they you can start on the things that Eric pointed out.

If the main reason you were looking at python is because you wanted a text based language, C++ or Java would sure be a lot simpler.

I’m not sure how much of the Java API is supported in the cRIO version, but you may want to look at Jython, which allows Python programs to be compiled to Java bytecode, and allows you to directly import existing Java classes into your Python code, which means you could use the cRIO’s Java API directly.

Disclaimer: I’ve never tried this, but this came to mind in reading your question and the previous responses as a possible course of action. Would probably be much easier than trying to cross compile the entire Python runtime using WindRiver

Good luck, and let us know of any results.

–Ryan