Java Command Based Layout - Using a Command Twice

Looking at examples of command based robots online, I noticed that most people tend to instantiate commands within the subsystem that uses them.

Our code has two drive related subsystems, one for the strafe motor and one for the tank drive motors. Both of these subsystems use the same command- Drive.

I have a feeling that a single command shouldn’t be instantiated twice. Is the correct solution to use different commands? Or is it not proper convention to make these separate subsystems?

Can you link me to these ones you are seeing online?

Please take a look at our code from last year. We do as much as we can to make our commands reusable.

If you have any questions please don’t hesitate to ask.

Make the drive train subsystem have all the motors controlling the drive train. As for coding it I would suggest making your own drive code, if your going with the 5 wheel H drive its similar to arcade drive but assign the 5th or 3rd motor controller to some value like the x value of the joystick. Also you should have 1 default command for the drive train and that should be the one you use for teleop. Good question though!

I would tend to think that both parts of an H-drive should probably be part of the same subsystem. Is there ever a time that you would have two one command controlling tank drive and a different command controlling strafe?

A command can require multiple subsystems, which we’ve done before. I have not tried it, but I think that multiple subsystems should probably not add the same command as defaults. I think they would constantly interrupt each other.