Robot Mesh Python (and Blockly) for VEX EDR release [Free online programming]

Introducing the release 1.0 of Robot Mesh Python for VEX EDR. This is our free online programming tool using the Python language on the VEX EDR.

Highlights:
[LIST]
*]Python programming uses a clean syntax and is easy to learn while having powerful features such as classes, threads, data structures (including tuples, lists and dictionaries). API reference is online here.
*]Online editor requires only the installation of a small browser plug-in to connect to the VEX IQ controller. See Setup Instructions.
*]Projects are stored in the cloud at robotmesh.com so can be accessed from anywhere. Users can have many projects and can organize into folders (so teams and classes can also be productive online).
*]Blockly graphical project type available which uses scratch-like blocks for easy visual programming. These blocks generate python code which can be immediately viewed and exported into its own project.
*]Joystick Wizard project type allows actions to be hooked up to the joystick controls to quickly create a driver-control program.
*]Python and Blockly project templates available for VEX Robotics Competition programming.
*]Configure and see sensor values while programming.
*]Support for Chrome, Firefox and IE browsers on Windows.
[/LIST]

Coming soon:
[LIST]
*]Videos, tutorial and curriculum.
*]Mac OS X browser support.
*]Offline software version so Python can be used away from the internet. Offline version will not be free, and will be for Windows PC initially.
[/LIST]

Our hope in developing this solution is that it brings a free, powerful, high-level language choice to VEX IQ programmers everywhere enabling new and exciting driver controlled and autonomous solutions.

I welcome your questions and feedback here in the forums, on our forums at http://www.robotmesh.com/forum/python-for-vex or by email to [EMAIL=“support@robotmesh.com”]support@robotmesh.com

Thanks,

Anthony and the team at Robot Mesh.

We’re desperate for a Mac programming software for VEX. Most of the students at our school have Macs (We’re a “bring your own device” school).

We’ve been waiting for your Python solution–because we heard it’ll be for Macs.

How soon is “soon” for Macs? Our first scrimmage in NJ is in two weeks. Our first competition is November 23rd.

Chiara Shah

Not trying to steal thunder away from this IDE (the idea of Python for the Cortex is really quite interesting and I’m definitely going to be trying this out) but PROS is an existing language that works on Mac, as is ConVEX.

I’d advise PROS simply because it’s easier to get set up, although ConVEX is fairly straightforward from what I’ve heard.

EDIT: Assuming you’re in EDR and not IQ.

Has anyone used this? I’m going to be back home around Christmas and will have access to my Cortex hardware and was going to try it out. I’m looking for some info on how well it worked for you.

Thanks!

I guess I should take the lack of responses around robot mesh as a no. So I’ll also not spend any time on it

Foster

Taking a more comprehensive look at the RobotMesh Python/Blockly solution is on my “to do” list. I think the reason it has not been more widely discussed on the forums is because being online only is a disadvantage for competition teams who make up the majority of the members here. I understand it will be offered as a standalone program soon, the Mac version of the plugin (Chrome only) was also released recently. I think it deserves at least a few hours of our time for evaluation.

I am a mentor to team 3129, the Green MacHHHHine. I am a fan of Python, and have been using it for a while. I teach courses on computer programming, and for the past year, I have been teaching my classes using Python.

I first heard about this Python environment for VEX at the RobotMesh display booth at last year’s World Championships. Soon after, I contacted Anthony at RobotMesh, and became one of the first alpha/beta/release testers. I have taken our team’s old Gateway robot which we still have together, and in my spare time I have slowly been rewriting all the code from scratch in Python.

I had all the drive, lift, intake, pneumatics, lcd, and most sensor code working a while ago. I recently started working on the autonomous code and I can now demonstrate some basic autonomous routines working.

The good news is that the system seems like an excellent implementation of Python. I am heavily into object oriented programming, and Python allows programmers to build modular code this way. I’ve also found Python lists to be very helpful ways to package robotic data. In this implementation, Python ‘print’ statements are displayed in an output window in the browser for debugging. Anthony has been extremely responsive in helping resolve any issues that I have run into.

Up until last week, I had been doing all the programming using a PC with a Chrome browser. The files are saved “in the cloud”. But a few days ago, I got a message from Anthony that a Mac driver was ready. I am a Mac guy, so this was exciting news. I tried it out, and it seems to work great running via Chrome on my Mac.

Here are the only downsides that I can see now:

  1. The documentation is lacking. Certainly understandable for a new environment. RobotMesh has said that generating more detailed documentation is a high priority for them.
  2. I sometimes run into situations where new a version of my code fails to download. RobotMesh said that they are currently looking at this problem.
  3. Currently, all code must be contained in a single file. While this is workable, I would much prefer the ability to break up my code into smaller files, and then use an “import” statement to have them all compile together. RobotMesh says that this is in the plans for the future.
  4. Currently, your code is only accessible through a browser. This is probably not be ideal for use at a competition site, but it is working fine for me in a test environment.

Overall, I am very excited about a real object oriented language becoming available on the VEX platform and I think that RobotMesh is doing an excellent job is making it a reality.

I would be happy to answer any questions about the environment.

Irv

I had no luck getting this working on a Mac running 10.9.5. Which programming kit are you using Irv? old prolific or new vex version?

The other thing I notice is that performance (ie. speed of running the code) is terrible, I’m still looking into that but my first reaction is that this is never going to run anything significant. Just to toggle an IO line is taking close to 1mS whereas ROBOTC does that in about 3uS (ConVEX is even faster). Trying to run something at a constant 10mS rate (for PID etc.) was all over the map. I also ran out of memory multiple times unless I forced garbage collection to run. I’m still working on a review for RobotMesh so won’t post any more details yet.

I am also running Mac OSX 10.9.5. I installed the RobotMesh Mac driver for Chrome, here: http://www.robotmesh.com/project/install

I’m not sure what you mean by ‘programming kit’. I am using an orange USB VEX programming cable that is about a year old. It connects to a VEX Joystick that about 2 years old. I’m using VexNet 2.0 white keys. And my robot has a Cortex that is about 3 years old (with latest firmware).

I am looking at this at a different level. My code is running on a competition-ready VEX robot. All driver functionality is working perfectly. In addition, I have implemented a PID loop for autonomous driving, and it seems to be working with excellent precision. I have yet to run into any limits of the development environment.

One of the things that makes Python a good learning environment for new programmers, is that Python handles memory management and garbage collection automatically. I’m running some fairly sophisticated code, and I have not seen any memory problems at all. I’m curious about what you are trying to do that is leading to your memory problems.

I look forward to your review.

I would be happy to talk to you about my findings. If you would like, please contact me via a private message.

Irv

I was running one of my standard benchmark functions ported to python. Memory error after a few seconds.


# VEX EDR Python-Project
import sys
import math
import vex

dgtl1 = vex.DigitalOutput(1)

MotorLut=[None]*128
MotorLutFactor=20.0
MotorLutOffset=10


def makelut():
    i = 0
    
    #while i < 128:
    for i in range(0,127):
        if MotorLutFactor > 1:
            x = math.pow( MotorLutFactor, i / 127.0 )
            if i >= (MotorLutOffset/2):
               MotorLut* = (((x - 1.0) / (MotorLutFactor - 1.0)) * (127-MotorLutOffset)) + MotorLutOffset;
            else:
               MotorLut* = i * 2;

        else:
            MotorLut* = i
    #    i = i + 1

def b6():
  while True:
    dgtl1.on()
    makelut()
    dgtl1.off()

b6()

while True:
    pass

The Mac & Linux support was released this past weekend. And as noticed there are issues with the download over the wireless VEX Programming Hardware Kit on the Mac. The USB A to A cable should work ok for a wired download on the Mac. I’m currently looking into why, which is why I haven’t announced Mac support broadly here yet.

I’ve added a simple timing to jpearman’s program and made public here: http://www.robotmesh.com/project/387/

I haven’t observed any memory problems with it, and it’s been running for 10 minutes now. We’ve done several soak tests with the memory management, so it should be pretty solid. If there’s a bug, we’ll find it.

The standalone version (PC first) is almost ready and should be released in the New Year.

Regards,
Anthony

I was working wired from joystick to cortex and using the new programming kit, no VEXnet involved.

I tried that version and it works. What I had posted was an excerpt from a larger program (trying to simplify the post when at work), adding back in some additional digital ports I use elsewhere caused the crash to come back. I ran this exact code.

# VEX EDR Python-Project
import sys
import math
import vex

dgtl1 = vex.DigitalOutput(1)
dgtl2 = vex.DigitalOutput(2)
dgtl3 = vex.DigitalOutput(3)
dgtl4 = vex.DigitalOutput(4)

MotorLut=[None]*128
MotorLutFactor=20.0
MotorLutOffset=10

def makelut():
    i = 0
    
    #while i < 128:
    for i in range(0,127):
        if MotorLutFactor > 1:
            x = math.pow( MotorLutFactor, i / 127.0 )
            if i >= (MotorLutOffset/2):
               MotorLut* = (((x - 1.0) / (MotorLutFactor - 1.0)) * (127-MotorLutOffset)) + MotorLutOffset;
            else:
               MotorLut* = i * 2;

        else:
            MotorLut* = i
    #    i = i + 1

def b6():
  while True:
    start = sys.clock()
    dgtl1.on()
    makelut()
    dgtl1.off()
    duration = sys.clock() - start
    print "b6 loop end " + str(duration) + "s"
    print sys.heap()

# Invoke b6
b6()

#Should never get here
while True:
    pass

added digital ports 2, 3 and 4 (and a print heap just to see what’s going on). That causes this error.
[ATTACH]8819[/ATTACH]

Even without the additional ports added I notice that the heap is used up really quickly, looks like garbage collection runs about once every second or so.***
python_err_1.JPG

One more benchmark result until I talk with Anthony privately.

def b2():
  while True:
    start = sys.clock()
    dgtl1.on()
    i = 0
    while i < 1000:
        i = i + 1
    dgtl1.off()
    duration = sys.clock() - start
    print "b2 loop end " + str(duration) + "s"

In EasyC it takes 0.2mS, in RobotC 5.4mS (due to VM), in PROS and ConVEX it usually gets optimized out but if I force the loop to run (declare the variable volatile) then it takes 0.17mS. In python it takes 75mS, 15x longer than RobotC and around 400x longer than the native C compilers. Now I realize that this is an artificial benchmark, but I’m seeing similar performance across the board which IMHO is going to make anything but trivial drive code (for example, my smart motor library) difficult to implement.

I’m measuring all times using a scope not the embedded timing statements I included above. note, the EasyC and RobotC measurements were made back in 2011 and I need to recheck with the current versions sometime.

Thank you for the repro case of the out of memory issue! We’ve identified a bug and we’re working on a fix.

With our initial release we haven’t focused on high levels of speed from the Python VM or the Python VEX library. We have been mostly focused on memory usage (in particular on the VEX IQ).

jpearman’s measurements highlight how critical the performance of the platform is if you’re writing time-critical code, in particular high-frequency PID motor control loops. I very much appreciate his results. As we begin to optimize the python platform over the coming months the performance will steadily improve.

However, since Python is a dynamically typed object-oriented language the structure of some things will be different (e.g. the range(…) function creates an integer object instance for each value in the range), so it may be the case that we create new APIs to support some high-performance operations.

Regards,
Anthony

are ARM processors supported? I would love to program on the Raspberry Pi.

Currently, no, we don’t support the Raspberry Pi/other ARM computers.

We do have a Chrome plug-in, but Chrome doesn’t run well on the RPi, so we’d need to develop an Epiphany plug-in.

If there are other users out there who want RPi support, please email us support@robotmesh.com