Periodic-Oriented Programming for FIRST Robotics

20 points by robalex 20 hours ago on lobsters | 3 comments

juliaaa | 13 hours ago

FRC is quite weird from a software point of view. I would say that probably 75% of teams struggle to design/build the hardware reliable enough to play the game. For these teams (I was on one of them) it doesn't really matter what software is running, you can't patch bad hardware. This is where a lot of the bits of advice in the article make less sense - it's impossible to not store arm position in software (estimation) if you want to attempt autonomous period work if you don't have a sensor (well, you can also do it purely on time here too). It's also impossible to be position-based instead of time-based without various sensors for position.

For the next 20% of teams that have competent hardware, then I would totally agree that dead simple periodic code without commands is the most appropriate fit. And these teams generally end up well funded enough to have sensors to be able to measure these and use it. (It seems like this is where you fit from a look at the blue alliance). But this is what I also see a lot of, though often quite spaghetti (these are high schoolers, after all).

I'll add here that WPILib (especially Tyler of 3512? iirc) has done a lot of wonderful work here on bringing a lot control theory beyond PID to be easier to implement for these teams, and having a lot of turnkey components for this, something previously limited to the top teams (or people using LABVIEW). Kudos also to Dalton (who I think works for CTRE now?) for doing a lot of work on documentation.

The top 5% of teams is where this changes. Listed in the advanced section of documentation, Command-based makes significantly more sense when your robot is heavily automated, and you have half a dozen different preplanned trajectories for your (hypothetical) double arm grabber claw mechanism for the different goals. You have a desire to do the many different "modes" of operation this article describes because you are doing many different things. This is mostly driven by team factors, and the current year's game, not software.

I'll add also that I believe command-based waz significantly reworked by (iirc) someone rom one of the top-scoring Israel teams. This is where it fits and makes sense.

Maybe this has changed, as I haven't been involved in a few years, but I do not recall seeing many command-based teams in the wild.

taciturnaxolotl | 10 hours ago

I graduated last year and it very well might just have been the teams I was interacting with and looking at their code but command based seems to have become far more common and at least for our team was the default choice. I am quite curious what the rewrite will look like as I graduated before we got to use it (and systemcore which is very sad). The WpiLib team has done a really good job trying to make it intuitive to use but the main issue from my standpoint was too many very similarly named options and very few docs beyond just javadoc. There are very different options that are all setup as commands almost identically to each other.

I may be coming at this from the 5% angle though. Our team was never super competitive but we did always have a workable bot that let us push for autonomous control (which was also very much my hobby. At least from the limited set of regional competitions I went to it seemed like most of them had a pretty good grasp on hardware. I’ve been really surprised how fast the manufacturing techniques have advanced for a lot of teams as it is largely not feeling possible be competitive without having a large metal shop and people who can design custom parts.

edit: This post seemed super familiar to me and I went digging back through our team slack and we discussed this approach about a year ago. It honestly would be a good idea to simplify a lot of frc code. I personally loved my baby of an amalgamation that was the codebase but that is a pretty terrible argument against simplicity

I would offer that the critique of command-based in this article largely seems to be referencing the old Commands v1 way of doing commands, which has changed significantly in the last few years. You now just define a single function to define a command now, rather than having to write an entire class. The semantics are also much clarified. Take a look at a modern robot project before deciding against it for the reason of verbosity.

That said, a lot of the critiques in this article are entirely fair, given different circumstances for different teams.