mirror of
https://github.com/TimeCrafters/UltimateGoal.git
synced 2025-12-16 06:02:33 +00:00
messing around and refactored magnetSensor
This commit is contained in:
2
.idea/compiler.xml
generated
2
.idea/compiler.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="1.8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -21,7 +21,7 @@ public class CalibrateRingBeltLoop extends CyberarmState {
|
|||||||
public void exec() {
|
public void exec() {
|
||||||
|
|
||||||
currentTick = robot.ringBeltMotor.getCurrentPosition();
|
currentTick = robot.ringBeltMotor.getCurrentPosition();
|
||||||
limit = robot.limitSwitch.isPressed();
|
limit = robot.magnetSensor.isPressed();
|
||||||
|
|
||||||
if (engine.gamepad1.x || (engine.gamepad1.a && !limit)) {
|
if (engine.gamepad1.x || (engine.gamepad1.a && !limit)) {
|
||||||
robot.ringBeltMotor.setPower(0.5);
|
robot.ringBeltMotor.setPower(0.5);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class Launch extends CyberarmState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//detect when limit switch is initially triggered
|
//detect when limit switch is initially triggered
|
||||||
boolean detectingPass = robot.limitSwitch.isPressed();
|
boolean detectingPass = robot.magnetSensor.isPressed();
|
||||||
int beltPos = robot.ringBeltMotor.getCurrentPosition();
|
int beltPos = robot.ringBeltMotor.getCurrentPosition();
|
||||||
if (detectingPass && !detectedPass) {
|
if (detectingPass && !detectedPass) {
|
||||||
//finish once the ring belt has cycled all the way through and then returned to
|
//finish once the ring belt has cycled all the way through and then returned to
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class FindLimitSwitch extends CyberarmState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
if (robot.limitSwitch.isPressed()) {
|
if (robot.magnetSensor.isPressed()) {
|
||||||
robot.ringBeltMotor.setPower(0);
|
robot.ringBeltMotor.setPower(0);
|
||||||
setHasFinished(true);
|
setHasFinished(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class ResetRingBelt extends CyberarmState {
|
|||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
//detect when limit switch is initially triggered
|
//detect when limit switch is initially triggered
|
||||||
boolean detectingPass = robot.limitSwitch.isPressed();
|
boolean detectingPass = robot.magnetSensor.isPressed();
|
||||||
int beltPos = robot.ringBeltMotor.getCurrentPosition();
|
int beltPos = robot.ringBeltMotor.getCurrentPosition();
|
||||||
|
|
||||||
if (detectingPass && !detectedPass) {
|
if (detectingPass && !detectedPass) {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class Robot {
|
|||||||
|
|
||||||
//Ring Belt
|
//Ring Belt
|
||||||
public DcMotor ringBeltMotor;
|
public DcMotor ringBeltMotor;
|
||||||
public RevTouchSensor limitSwitch;
|
public RevTouchSensor magnetSensor;
|
||||||
public int ringBeltStage;
|
public int ringBeltStage;
|
||||||
public int ringBeltGap = 700;
|
public int ringBeltGap = 700;
|
||||||
public static final double RING_BELT_SLOW_POWER = 0.2;
|
public static final double RING_BELT_SLOW_POWER = 0.2;
|
||||||
@@ -256,7 +256,7 @@ public class Robot {
|
|||||||
ringBeltMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
ringBeltMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||||
ringBeltMotor .setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
ringBeltMotor .setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
||||||
|
|
||||||
limitSwitch = hardwareMap.get(RevTouchSensor.class, "magLim");
|
magnetSensor = hardwareMap.get(RevTouchSensor.class, "magLim");
|
||||||
|
|
||||||
beltMaxStopTime = stateConfiguration.variable(
|
beltMaxStopTime = stateConfiguration.variable(
|
||||||
"system","belt", "maxStopTime").value();
|
"system","belt", "maxStopTime").value();
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package org.timecrafters.javaClass.samples.samples;
|
|
||||||
|
|
||||||
import org.cyberarm.engine.V2.CyberarmState;
|
|
||||||
import org.timecrafters.javaClass.samples.SampleRobot;
|
|
||||||
|
|
||||||
public class BlankStuff extends CyberarmState {
|
|
||||||
|
|
||||||
//here, you'll find some of your variables. you can add more as you need them.
|
|
||||||
private SampleRobot robot;
|
|
||||||
|
|
||||||
//This is the constructor. It lets other code bits run use the code you put here
|
|
||||||
public BlankStuff(SampleRobot robot) {
|
|
||||||
this.robot = robot;
|
|
||||||
}
|
|
||||||
|
|
||||||
//This is a method. methods are bits of code that can be run elsewhere.
|
|
||||||
//This one is set up to repeat every few milliseconds
|
|
||||||
@Override
|
|
||||||
public void exec() {
|
|
||||||
|
|
||||||
double targetDistance = robot.inchesToTicks(12);
|
|
||||||
if (robot.encoderLeft.getCurrentPosition() <= targetDistance) {
|
|
||||||
robot.driveBackRight.setPower(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.timecrafters.javaClass.samples.samples;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
|
||||||
|
import org.cyberarm.engine.V2.CyberarmState;
|
||||||
|
import org.timecrafters.UltimateGoal.Competition.Robot;
|
||||||
|
|
||||||
|
public class blankTHing extends CyberarmState {
|
||||||
|
|
||||||
|
private Robot robot;
|
||||||
|
private float trigger;
|
||||||
|
private int someOtherValue = 100;
|
||||||
|
|
||||||
|
|
||||||
|
public blankTHing(Robot robot) {
|
||||||
|
this.robot = robot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
robot.ringBeltMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||||
|
robot.ringBeltMotor.setTargetPosition(0);
|
||||||
|
robot.ringBeltMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exec() {
|
||||||
|
|
||||||
|
robot.magnetSensor.isPressed();
|
||||||
|
|
||||||
|
robot.ringBeltMotor.setTargetPosition(robot.ringBeltMotor.getCurrentPosition() + someOtherValue);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user