mirror of
https://github.com/TimeCrafters/FTC_2022
synced 2025-12-15 14:22:34 +00:00
Finish Arm state when Arm arrives
This commit is contained in:
@@ -8,7 +8,7 @@ public class Arm extends CyberarmState {
|
|||||||
private final String groupName, actionName;
|
private final String groupName, actionName;
|
||||||
|
|
||||||
private final double targetVelocity, timeInMS;
|
private final double targetVelocity, timeInMS;
|
||||||
private final int tolerance, targetPosition;
|
private final int tolerance, halfTolerance, targetPosition;
|
||||||
private final boolean stateDisabled;
|
private final boolean stateDisabled;
|
||||||
|
|
||||||
public Arm(Robot robot, String groupName, String actionName) {
|
public Arm(Robot robot, String groupName, String actionName) {
|
||||||
@@ -25,6 +25,8 @@ public class Arm extends CyberarmState {
|
|||||||
timeInMS = robot.getConfiguration().variable(groupName, actionName, "timeInMS").value();
|
timeInMS = robot.getConfiguration().variable(groupName, actionName, "timeInMS").value();
|
||||||
|
|
||||||
stateDisabled = !robot.getConfiguration().action(groupName, actionName).enabled;
|
stateDisabled = !robot.getConfiguration().action(groupName, actionName).enabled;
|
||||||
|
|
||||||
|
halfTolerance = Math.round(tolerance / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,5 +51,10 @@ public class Arm extends CyberarmState {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int position = robot.arm.getCurrentPosition();
|
||||||
|
if (robot.isBetween(position, position - halfTolerance, position + halfTolerance)) {
|
||||||
|
setHasFinished(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user