We currently have a dual-ball catapult design on our robot and we are trying to program it to automatically reload after shots. Does anyone know how to program something that can run a motor for a certain amount of rotations after a button is pressed within the driver control period? We are using C++ programming on Robot Mesh Studio.
My preference is to use events. I’m assuming you have a slip gear. Note that you’ll want to ■■■■ the catapult before using this. That could be done by another button or in autonomous. Also, this is with VCS, but I think most the commands are about the same.
Define this:
void fireAndCock(void) {
catapultMotor.rotateTo(double rotation, rotationUnits units, double velocity, velocityUnits units_v); // choose a speed that works well and choose the rotation units such that the slip gear turns exactly 360 degrees.
}
Inside your user control, before your possibly infinite loop include this:
Controller1.ButtonUp.pressed(fireAndCock); // choose your favorite button