Both of The Arm States

This commit is contained in:
SpencerPiha
2022-10-20 19:39:48 -05:00
parent 7442efa1c9
commit 09ab30ad8b

View File

@@ -0,0 +1,32 @@
package org.timecrafters.Autonomous.States;
import org.cyberarm.engine.V2.CyberarmState;
import org.timecrafters.testing.states.PrototypeBot1;
public class UpperArm extends CyberarmState {
PrototypeBot1 robot;
double UpperRiserRightPos, UpperRiserLeftPos;
long time;
long lastStepTime = 0;
public UpperArm(PrototypeBot1 robot, String groupName, String actionName) {
this.robot = robot;
this.UpperRiserLeftPos = robot.configuration.variable(groupName, actionName, "LowerRiserLeftPos").value();
this.UpperRiserRightPos = robot.configuration.variable(groupName, actionName, "LowerRiserRightPos").value();
this.time = robot.configuration.variable(groupName, actionName, "time").value();
}
@Override
public void exec() {
if (robot.HighRiserLeft.getPosition() > UpperRiserLeftPos) {
if (System.currentTimeMillis() - lastStepTime >= time) {
lastStepTime = System.currentTimeMillis();
robot.HighRiserLeft.setPosition(robot.HighRiserLeft.getPosition() - UpperRiserLeftPos);
robot.HighRiserRight.setPosition(robot.HighRiserRight.getPosition() - UpperRiserRightPos);
}
}
}
}