I was researching Command Based Programming, and it seems to me like the ideal way to organize the code for a more complex robot, and our code is getting to the point where that sort of thing would be very helpful, but I can’t seem to find it in LabVIEW. Does anyone know how/where we’d find the WPILib command-based stuff in LabVIEW?
There’s been some casual discussion over the years about how one might implement Command Based Robot control. I don’t know of anyone who has actually done it.
I presented on this at championships a few years ago, but because of the roboRIO development, I didn’t have a chance to implement it.
I’m work working on it again. I can explain the techniques and patterns, but it is not ready for sharing with others.
At the moment, each subsystem is built up using what I refer to it as command & control elements. The controller is the core implementation that owns actuators and sensors, maintains state, and runs at the rate appropriate to the operation being carried out on that mechanism. The commander acts as the interface to the rest of the code, being handed operation requests and set points, sending them to the controller, and notifying clients when operations complete. In some cases such as vision, a few globals are sufficient and no commander is actually needed.
It is useful to build a number of wrappers that simplify making the requests to the commander and potentially wait for completion. These wrappers can then be sequenced or run in parallel, the client can start and forget in teleOp, and can use the same command in auto but wait for completion.
I’m actually testing this out with a local team, and I agree that the simple framework that has been used doesn’t offer enough structure for complex robots. I hope that we will offer both next season. Feel free to adopt any of this that makes sense, or if you find something else that works well, I’d love to hear about it.
Greg McKaskle
Do you have any example code?
I have code, but it isn’t really up to example standards yet.
My suggestion would be to use the current framework, but start moving subsystems that need control elements almost entirely into the Periodic Tasks. Have it respond to a set point global or collection of globals. Then build up some subVIs that set the globals in order to command the mechanism. If you need a notification mechanism, you can use a global, but may want to look at the Notifier data type.
There are many teams that already write the code this way. I don’t know if they consider it command based, but it helps to isolate and scale the code.
Greg McKaskle