mirror of
https://github.com/TimeCrafters/FTC_2022
synced 2025-12-15 15:32:35 +00:00
Add Wait state
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
package org.timecrafters.minibots.cyberarm.chiron.states.autonomous;
|
||||||
|
|
||||||
|
import org.cyberarm.engine.V2.CyberarmState;
|
||||||
|
import org.timecrafters.minibots.cyberarm.chiron.Robot;
|
||||||
|
|
||||||
|
public class Wait extends CyberarmState {
|
||||||
|
private final Robot robot;
|
||||||
|
private final String groupName, actionName;
|
||||||
|
|
||||||
|
private final double timeInMS;
|
||||||
|
private final boolean stateDisabled;
|
||||||
|
|
||||||
|
public Wait(Robot robot, String groupName, String actionName) {
|
||||||
|
this.robot = robot;
|
||||||
|
this.groupName = groupName;
|
||||||
|
this.actionName = actionName;
|
||||||
|
|
||||||
|
timeInMS = robot.getConfiguration().variable(groupName, actionName, "timeInMS").value();
|
||||||
|
|
||||||
|
stateDisabled = !robot.getConfiguration().action(groupName, actionName).enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exec() {
|
||||||
|
if (stateDisabled) {
|
||||||
|
setHasFinished(true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runTime() >= timeInMS) {
|
||||||
|
stop();
|
||||||
|
|
||||||
|
setHasFinished(true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user