Python on VEX

Came across this ad recently, intriguing, from the author of Flowol presumably (due to the robotmesh link).



Just checked. So apparently they are releasing a Python based programming language.
Suppose we’re going a little more OOP here. It’ll be interesting to see how it works. I’ll definitely give it a try.

1 Like

Out of pure interest, I began googling Python with the Microcontroller within the cortex and found this.

Seems cool to me.

1 Like

Seems cool to me.

There have been implementations of Python on the STM32 processor before, the guys at leaflabs did it a couple of years ago on the Maple board using python-on-a-chip. However, there’s a reason 70% of embedded development is still done in C, I’m sure it will work but at the end of the day you’re left with the same functionality that the cortex already has.

1 Like

I can see where Python on VEX could be an incredible advancement for OOP programming (there sure is a lot that OOP would make easier), but I wonder if speed will be an issue (I know Python is supposed to be slow-ish, but haven’t run any tests on it myself).

I wonder if the full functionality of Python will be maintained, or if certain parts will be removed to make it “smaller” for memory usage…

The speed would probably be close to RobotC’s if they go the bytecode route. If they choose to interpret raw text it would probably be pretty slow.

I do agree that OOP is easier for some things, but honestly those things are very few and structs work just fine for them.

That is good to hear.

Hmmm… maybe. I could see building a finite state machine with separate objects to represent different states and the transfers between states, or a model-view-controller sort of pattern. As someone whose primary language is Java, I have grown quite used to objects in general (and perhaps overuse them).

Seriously–think about how well object oriented code would work for programs that actually interact with physical objects! I could have a Robot object made up of a DriveBase and Arm object. Each of those is made up of a variety of motors and sensors, etc. A Motor object could have PID control wrapped into it, etc. I’m looking forward to seeing OOP with VEX. :slight_smile:

1 Like

Trust me, from someone who’s first language was Java, you will become a much better programmer once you try it a different way. That’s why they teach Scheme in college - nobody actually uses it in real life but it helps you think in a different way. I honestly think that using real c for robotics stuff is a good educational opportunity to learn programming without OOP. I’m a huge fan of OOP for many things and use Java as my main language for computer applications, but I think it’s really a good idea to spend more time with c.

Honestly, the fact that you want to use so many objects for a robot (which is relatively simple) is a red flag that you need to spend more time programming without objects - it teaches you that sometimes you can get carried away with using objects when it’s really unnecessary and you can accomplish the same thing just as clearly without them. Like honestly, why do you need a motor object? It just seems excessive.

However, I am still open to new ideas and I do see how much easier programming libraries can be written to take care of an “Arm,” for example. It just seems weird and not microcontrollery, but I can see how it might make programming easier.

You can certainly program C using OOP techniques, one way is to simply hide functionality under very high level functions, for example, all I need to initialize an arm system is the following code. Once that’s done everything else “just happens”.

    // Arm system
    ArmSystemInit( EncArmR, MotorArmR, MotorArmL );
    ArmSystemAttachControls( Ch2, Btn8U, Btn8D, Btn7U, Btn7L );

The robots we create are quite simple and will generally only have one instance of many of the objects, there will only be one drive system, one arm system etc. A motor could make a good object if it had more functionality, all a motor really has is its command value. A “smartmotor” object could also include measured speed, current, temperature etc. but I’m still not sure OOP is necessary, we only have 10 motors and they all have very defined functionality in the program, it’s not like we would be creating and destroying motor objects dynamically.

1 Like

I totally agree that OOP is not necessary and all the same things can be done just as cleanly from the user’s perspective. However, I find it more awkward to write the library functions in C. As you said, you are hiding functionality under high-level functions whereas with OOP it actually is high-level from everybody’s perspective - no hiding necessary.

Again, I’m on your side here and I think C is the way to go here - it does everything we need it to and it’s a great educational experience.

I’m just saying that I understand why folks might want OOP. At the end of the day though, it helps only a very small subset of people - those who are advanced enough to write libraries but not advanced enough to do it in an unfamiliar environment.

1 Like

Eh… I sort-of agree. I just have recently been finding OOP kinda fun, and wanted to extend it to robots as well…
I’ve gotten tired of some parts of (ROBOT)C (e.g. I still haven’t figured out how to implement something like instantiating an arbitrary number of ArrayList structures, or some other type of data structure, (e.g. graph); I know how to make one, but I cannot figure out how to make multiple. But, that’s a topic for a different thread.)

I want to make sure that it’s clear I think learning C/procedural languages is important for educational purposes (as well as for embedded programming in general). I just think that Python/OOP could be interesting for robots, too. Not necessarily a hands-down better language, but something interesting.

Another reason having Python as a language for VEX is it makes robotics fit with more school programs; Python is gaining popularity in the education community (at least, in colleges… and, from the little I’ve heard, I think also in high schools), so it makes it easier for people who’ve had experience with Python to jump into robotics, rather than going from something like Python to C. Once we’ve got them hooked on robots, then we can introduce them to C. :stuck_out_tongue:

1 Like

Kinda funny - I got tired of OOP and now I’m finding procedural more fun :slight_smile:

It can probably be done with some clever use of structs. Not really feeling it tonight but maybe I’ll try to make an implementation some time. Why do you need an arraylist?

The problem is, why would people try C if they can do everything in a language they’re comfortable with? I think it’s better to force them to try something new.

1 Like

More of an academic interest than a practical interest. A while back, magicode wrote up an implementation of a hashmap (and something else, I forget) on the ROBOTC forums. However, IIRC, his implementation was only good for one usage; two hashmaps would require two duplicate files. I’d like to figure out a way (in general) to create multiple copies of one data structure from one program file.

What? Why, then, did I go from Visual BASIC, with which I was totally comfortable, to Java? :stuck_out_tongue: People would change if they were the type who wants to improve by nature–a team may enter with robots, and decide to try ROBOTC to see if it works better. I think adding Python lowers the entry knowledge barrier for new teams, which will increase team count over time. I don’t think we should “force” people to learn C-based languages to do robots, as that scares people (specifically teachers who feel that they have to learn a new language) away.

My $0.02. :slight_smile:

And our Python programming is now live…

It’s currently a pre-release beta and it’s free. The web-based environment has a small plug-in to download in order to connect and program your VEX Cortex. It currently supports the latest Chrome, FF and IE on Windows (Mac support will be coming later).

I hope you might find Python programming to be an interesting option. There are some example projects available to help users get started.

Look forward to any feedback you might have.


Anthony Bowker
Flowol & Robot Mesh developer.

1 Like

So you can only access it online? That would not work well in competition environments which often don’t have a stable internet connection.

Correct. Currently it’s browser based. We plan to have a standalone software install available for September 2014 - so it should be a very attractive option for next year’s VRC.

One of the main attractions of Python as a language for VEX robotics is in STEM/Computer Science classrooms where internet is more readily available.

1 Like

I’m a bit confused by the licensing terms for this.

This implies I cannot write Python for VEX and release it under GPL, is that right? What can code made public be licensed under?

Also, I thought PyMite was released under GPL V2.0 not the MIT License, from the PyMite web site.

Perhaps you have based this project on an older version.

1 Like

Code can be made public under a variety of licenses: MIT, Public Domain, LGPL. The issue is with our server based compile where we link to our propriety (non-GPL compatible) library for the VEX Cortex. So we cannot have users making Python code public on Robot Mesh where the code states it’s GPL. I’m looking into solutions to this.

Some of the information on the PyMite website is out of date. The licenses for different branches and different directories of code are different - the latest information is in their github. We worked with Dean, the PyMite author and maintainer, to use a suitable branch.

1 Like