Program Your Robot in Rust - First Rust Competition Public Announcement


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.


Just last night I was talking to a friend about using Rust for an FRC bot. This is exciting, thank you for sharing!


How does the robo rio run rust, I thought it could only run java, c++ and python? This is way over my head but looks really interesting


Python is unsupported actually. Only C++, Java, and Labview are officially supported. IIRC kotlin is also unsupported but used by a couple teams.


Huh I didn’t know that, how can it run an unsupported language?


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.


You could get your robot to run LOLCODE if you can convince it to interop with C.


Kotlin can access java libraries and compiles down to a jar file. So it runs on the jvm just like java.


tfw your fork of ctre-rs has drastically diverged from mine


And thus, the “rewrite it in Rust” meme became real for FRC. :clap:t2:
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?


We have a summer “just for funzies” project in our queue to get a Chef interpreter (with spec!)up and running on our roboRIO, and to extend it with some basic ability to do motor & joystick IO.

1 Like

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).


What exactly is rust, and what are the advantages of using it?


For a concrete reason as to why one would use Rust, its compiler errors are significantly easier to understand than your typical C++ compile error messages from template hell.

1 Like

RoboRIO is just a linux device ( like a raspberry pi) it can run pretty much anything compiled for armv7


So would you recommend using rust over Java/C++?


I’d implement a server but the client code is already a mess as it is, and adding more surface area wont fix that


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…