I've seen the following kicker approach successfully implemented in LabVIEW. The same approach could be used in Java or C++.
put the following code in a separate concurrent periodic task using your language of choice. for a kicker, 20Hz is probably plenty fast enough.
Code:
/*
to establish the 50ms period (20Hz frequency) put your code here
to block wait for 50ms to elapse, releasing the CPU so this task
does not run at high speed and use CPU resources unnecessarily
when not kicking
*/
if (kickRequested && !kicking) {
kicking=1; // prevent reentrancy
/*put your sequential kicking code here.
if your code has places where it needs to wait for an event,
like elapsed time or a limit switch for example,
make sure you code it so that the CPU will be released
to use that time to service other tasks
while waiting for the event.
if your code uses data from other tasks,
make sure the access is protected.
*/
kicking=0;
}
"kickRequested" is a global boolean that is used by your code in Autononmous and/or TeleOp to request that a kick be performed.
"kicking" is a local boolean to control reentrancy: If a kick is presently in progress when the request is made, the request will be ignored (so as not to interrupt the ongoing kick cycle)