Hi VEX community!
I’m Aadish, a coder on V5RC team 315P and VEX AI team 3151A. I recently became interested in Python development on the brain for a few reasons.
- As part of 3151A, I developed a software stack to run on our coprocessor (a Jetson Nano). This involved fetching camera frames, running our custom model on them, doing post-processing efficiently on the GPU, and developing an efficient communications protocol to talk with the V5 brain. All of our coprocessor code (which spans over 2000 lines of code) is written in Python. However, our V5 code was entirely C++ in PROS, fracturing our codebase into two parts (not to mention our custom dashboard written in TypeScript
). - A member of 3151A, who goes by Chroma, came from a V5RC team, 3332A, he ran with his sister. All of 3332A’s code is Python, yet he was still able to do a lot of crazy stuff with it, such as a relatively consistent 50-point skills route. When I was the lead coder on 315P, we had also initially used Python, but switched to PROS for Over Under worlds and High Stakes because of the wealth of available libraries.
Despite this, using Python in V5RC is generally not considered a great idea. There are a few reasons for this.
- Multi-file support. Unlike VEXcode C++ or PROS, VEXcode’s Micropython implementation does not support having multiple files. This significantly decreases code organization and makes it hard to navigate Python code. Chroma’s Python code, for example, was a single, 3000-line file.
- Libraries. Because of the lack of multiple files, it is impossible to have good libraries in Python. The best thing you can get is copying-and-pasting thousands of lines of code into your program, which is obviously not ideal.
- Editors. If you want to use Python to write VEX code, you are restricted to writing code in VEXcode or VSCode, as VEX does not offer extensions for other editors or a universal CLI.
I decided to fix all three of these in one fell swoop with a new project I have been working on for a few weeks, DishPy. (Yes, it is a pun on my name!)
- DishPy adds multi-file support by
using dark magicmessing around with the AST of your code to combine everything into one file. - It has a simple package model inspired by PROS, with decentralized packages maintaining metadata and DishPy users having a local registry of packages on their computers.
- DishPy also has a simple CLI (also written in Python!) that allows you to build and upload DishPy projects from any editor (or, if you are a vim lover, from the terminal).
- The best part is that DishPy just works. Create a new DishPy project and paste in your current Python code — you can immediately start building and uploading it! Unlike PROS or vexide, which implement their own kernel, DishPy binds to the same Micropython VM as VEXcode Python does, so you can continue using the same APIs as you are used to. We also auto-generate docs for the API for easy reference.
- It is all OSS and on my GitHub.
I hope you’ll try out DishPy and maybe even open an issue if you find one (or ping me on VTOW)!
Quick links
- Install from PyPI — dishpy·PyPI
- Github repo — GitHub - aadishv/dishpy: Python development tool for the VEX V5 supporting multiple files, any editor, a CLI, and libraries
- Docs — Home - DishPy Docs
- Tutorial for beginners — 1. Installation - DishPy Docs
Thanks,
Aadish (315P V5RC; 3151A VAIRC)
