When I learned Rust, I really wanted to use it in FRC, and I soon found out that others did too.
Since my team is at Houston basically right now, I figured this would be a good time to announce that I consider my passion project, First Rust Competition (FRC) ready for real use. 114’s RIO has only run Rust in 2019.
Accompanying this release is a small description of the project, and a tolerable post I wrote in a few hours about why Rust is a good choice for FRC and how it’s helped 114.
Rust doesn’t magically write 971’s IPC and State Space Controllers for you. But, I can say that the hardware libraries work and Rust as easy and fun to use on embedded as it is on desktop.
Please let me know if you check the project out or decide to use it! PRs welcome. If you’re at Houston and want to look at some of our Rust code, find the 114 pit and ask for Josh. We also have Rust-related stickers courtesy of Ferrous Systems. Our code will be released after we clean a few things up.
It’s just a linux based system with a few C libraries to link to to communicate with the DS and the FPGA. As long as your language can interface with a C library, and can be built for arm linux, its actually relatively easy to get other languages working at a basic level. I had C# and mono working a few years ago, just ran out of time to keep maintaining it. Python is the same, its just wrapper libraries, and getting python running on the system isn’t that difficult. Same with Rust.
And thus, the “rewrite it in Rust” meme became real for FRC.
Are the x-rs (ctre-rs, nt-rs) libraries similar to existing “vendor dependencies” in WPILib? And do you need nt-rs to work with the SmartDashboard, or just to allow access to any NT table/key?
Currently there is no Rust implementation of a NetworkTables server. nt-rs currently only acts as a NetworkTables client. (Maybe @Redrield or someone else might be willing to split up nt-rs and make it happen?)
Roughly. It’s better comparable to just declaring the dependency straight in your build.gradle (or using a library installed via pip if you’re familiar with Python).
I would recommend picking a language that your team is most comfortable with. If the benefits of Rust make you more comfortable than any of the alternatives, then go for it.
I suspect 4774 will be using Python for a while to come - Python is a rather popular language taught in schools around here that more of our students will be comfortable writing Python than any other language you could use in FRC, and the Python ecosystem has a lot of libraries…
Since nt-rs was mentioned, I figured I’d pop in to say a server mode for nt-rs has been painstakingly written by me, I haven’t published it on crates yet (there’s some more stuff i want to try to do before i publish), but it’s available at https://gitlab.com/Redrield/nt-rs/tree/v2
I started working on some bindings to the NI FPGA C interface a while ago, although it never went anywhere (waiting for const generics to be added before I continue). I was hoping to then write a sort of lvbitfile2rust program (like svd2rust) and eventually implement embedded_hal’s traits for the roboRIO once a CAN interface exists. This is definitely outside the realm of competition and just personal interest, but I’d be happy to help if someone less busy with work than me wants to take a crack at it
edit: hm I didn’t mean to make this a reply to anyone in particular