2020 Command Based Tutorial

So like many of you I have time on my hands.
One area we have always needed help in is programming. The students have been
very eager and quite bright, but the programming group has not had a dedicated
mentor. As the head coach I want to better understand the Command Based programming
methodology. I have a CS degree and have programmed in both Java and C++ in my career,
however it has been some time.

I have read the WPI docs, they are helpful, but a little dry.
https://docs.wpilib.org/en/latest/docs/software/commandbased/index.html

I also found this wonderful tutorial from FRC 4627 from Manning Robotics

which I have watched several times. However it is for the old Command based programming
not the 2020 rewrite. I understand that RobotContainer = OI and Constants = RobotMap but there are some other significant changes.

My hope is to really grasp this and run a programming boot camp over the summer.
Does anyone know of any other tutorials, video would be great, on the paradigm?

Thanks in advance

3 Likes

Triple Helix has a great introduction to the relevant pieces that you need to know in order to do Command-Based programming well.

It is the old framework, but 95% of it still applies. The only things that have changed are things like RobotMap -> Constants.java, and adding in explicit dependency injection.

There is definitely not going to be much as of yet that specifically targets the new framework. With the framework having only being released ~3months ago, and most of that time having been build season, there hasn’t exactly been time to develop updated tutorials for the rewrite.

The only other really significant changes that I’ve noticed are the use of dependency injection for commands, lambdas for passing data outside of command’s subsystem to commands, and more pushing to have as much of your logic in the RobotContainer as possible through the availability of:

  • InstantCommands
  • inline Command Declarations
  • Command Decorators
  • Inline CommandGroup Declarations
  • Chaining Trigger Objects, my personal favorite, with the and(), or(), and negate() methods.
    and I’m sure i missed a few things!

As for other really useful resources, I found the CommandBased WPILIB Examples to be a great source for looking at how some common things may be done within the new framework.

I was actually just saying the other day that now that we’ll be switching over to the new structure I need to update this presentation.

2 Likes

Your presentation is very good. What resources did you use to gain a better understanding of the Command based structure. Like I said before, I did read the WPI Docs and they are a little dry.

1 Like

Honestly, it’s 12 years of mentoring combined with being a software engineer professionally.

If you have any specific questions feel free to ask.

The Docs are good enough to get through it. I actually went digging through the wpilib source to try and figure out what the Scheduler was doing to try and figure it out because the docs weren’t telling me what I wanted to know. I don’t recommend that route.

I think the thing that has helped me the most, and the thing that helps the students the most, is to visualize the problems and the state of the robot.

Using shuffleboard has been a game changer for our students. They learn how to add their components to tabs in Shuffleboard, to include the subsystem itself (helps to see what is scheduled and when), we run ALL of our commands from Shuffleboard to include tuning values like motor speeds etc, as that gives the students a very easy way to see what’s going wrong with their code.

Introduce Command-Based for sure, as I think it’s really simple for kids to understand, once they are over the hump. Do it in a way that helps the visual learners see what is going on, and you’ll be able to get to everything much more quickly in a build season.

I think they’re good enough for an experienced software developer AND someone who has been mentoring (or around) FRC for a while. And maybe that’s the intended target! My students struggled with it initially and needed alot more guidance as compared to some other FRC topics.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.