I have an intake sub system. When the arm of my robot is in the home position, I want the intake to go to the stow position, assuming I’m not pursuing an intake specific command like “intake note”.
I thought this would be an appropriate place to use a default command. However, the Java docs are fairly unclear as to how I set that up. Can someone explain it a little more clearly?
In this case, you might be better suited to have your “arm to home position” command also invoke the “intake to stow position” command.
A Default Command is the thing that runs when there are no other active commands. It’s great for things like drivetrains, where you typically want joystick/controller commands running any time you are not doing a special task. However, for something like an arm, you may not want the intake to always return to a “stow” position after every attempt to run a command that sets it to a specific angle.
However, if that is actually what you want, then Oblarg is right, you just call setDefaultCommand in your initialization code
To provide some extra clarification, you pass setDefaultCommand any command, be that a command class, a command factory method (in the subsystem or not), etc. You do not really need anything in the subsystem aside from whatever that command uses/needs (and the factory method if you are using one). setDefaultCommand can be called either from an outside class like RobotContainer or from inside the subsystem, depending on preference.