Quote:
Originally Posted by zackd97
The subsystem in question is intended to have two switches. One switch would stop the arm from moving too far, and the other switch would be so that it would stop in a ready position. When the arm moves, it is to move to the ready position, hit the second switch, and then move backwards until it hit the first switch. This process is intended to be run by a joystick button. I know very little about c++ and have not yet managed to program any sensors whatsoever.
|
You could make two commands, one to move it to the ready position. It would start the motor moving in the initialize() method then check the limit switch in the isFinished() method. In the end() method, stop the motor.
A second command would start the motor moving in the other direction in its initialize() method and its isFinished() method waits for the other limit switch. Its end() method also stops the motor.
In both cases, make sure the interrupted() method also calls end() so the motors stop if something else uses that subsystem.
With those two commands working individually, make a command group that does the two commands sequentially.
It's two classes, but you only have to write a few lines of code in each one. And it's easy to test - put the commands to the SmartDashboard and you'll see buttons to test each command.
Brad