VEX Python Reference API

Hi guys, with the first spin up scrimmages fast approaching, my team has been working hard to get our robot programmed quickly and efficiently. As my team’s lead programmer, I am most comfortable using PyCharm, and am often made very aware of the lack of more advanced features of VEXCode V5. Of course, I could switch to VEXCode Pro, but we have already dedicated ourselves to Python, which (as far as I’m aware) is not support in VEXCode Pro.

Until now, using PyCharm to program our robot has been quite good, except for the code completion. I’ve searched through all the VEXCode files, even going so far as to decompress the .EXE file and search through all those files, as well as the JS contained therein. Unfortunately, despite my best efforts, I have yet to find a reference for the “vex” module imported at the start of every Python program.

Is a reference that I could import into Pycharm available anywhere? Or will I need to create my own? (Posting it on our team GitHub, of course :smiley:)

1 Like

As far as I aware (correct me if I am wrong), there isn’t a library that PyCharm can reference to generate autocompletions. However, the V5 Python API was documented on the Robot Mesh website here.

It’s not completely the same but is similar.

We may have something this summer that will allow auto completion in non-VEXcode editors.

9 Likes

I have no experience with using Pycharm with Vex, but I just looked up how to add external module references into Pycharm, and it looks quite simple. Apparently Pycharm uses websites to auto complete common modules like matplotlib or pandas. Following the directions of this website, it appears that the Robotmesh API can be included in Pycharm the same way. Of course, if the Robotmesh API is not the exact same as Vexcode it might wreck your code, so waiting until the official API is released would make sense. However, it might speed up your coding if you tried including the Robotmesh API. It is up to you to decide.

1 Like

How can we find out more about this, our school will most definitely be interested.

Until that happens, I did spend a few minutes today working on a library that can be imported and that contains the classes and functions of the official vex library, just without any functionality except for brain.screen.print(), which instead prints to the console. It is most definitely not complete, as it only contains around 20% of the functions in the official vex library. However, I will spend a bit more time on it over the next few days, so hopefully it will be feature-complete soon.

In the end, my aim is to turn it into a complete simulator for the V5 brain, which when combined with my VEX graphics library (currently only basic functionality) will allow Python users to create advanced and simple-to-use UIs, as well as proper code completion and code testing without access to a physical robot.

For now, if you want to use the reference API, just place it in the same directory as your robot’s Python script, and it should hopefully be picked up automatically. Enjoy!

The links to each project are below:

6 Likes

I finished the library to allow PyCharm to give you code completion and parameter hints.

It should be sufficient enough given your purposes (though I am open to making any changes necessary for it to work properly).

5 Likes