mirror of
https://github.com/TimeCrafters/UltimateGoal.git
synced 2025-12-13 05:02:34 +00:00
Added unit conversion functions and made robot object functional with minibot modifications.
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -22,7 +22,7 @@ public class EncoderTest extends CyberarmState {
|
||||
|
||||
robot.setDrivePower(-0.2 * engine.gamepad1.left_stick_y, -0.2 * engine.gamepad1.right_stick_y);
|
||||
|
||||
ticksLeft=robot.encoderLeft.getCurrentPosition();
|
||||
ticksLeft= robot.encoderLeft.getCurrentPosition();
|
||||
ticksRight=robot.encoderRight.getCurrentPosition();
|
||||
|
||||
|
||||
@@ -50,16 +50,16 @@ public class EncoderTest extends CyberarmState {
|
||||
@Override
|
||||
public void telemetry() {
|
||||
|
||||
engine.telemetry.addData("controler", engine.gamepad1.left_stick_y);
|
||||
engine.telemetry.addData("controller", engine.gamepad1.left_stick_y);
|
||||
engine.telemetry.addLine("Latency Values");
|
||||
engine.telemetry.addData("Y", robot.getLocationY());
|
||||
engine.telemetry.addData("X", robot.getLocationX());
|
||||
engine.telemetry.addData("Y", robot.ticksToInches(robot.getLocationY()));
|
||||
engine.telemetry.addData("X", robot.ticksToInches(robot.getLocationX()));
|
||||
engine.telemetry.addLine();
|
||||
engine.telemetry.addData("Rotation", robot.getRotation());
|
||||
engine.telemetry.addLine();
|
||||
engine.telemetry.addLine("Actual Values");
|
||||
engine.telemetry.addData("Left", ticksLeft);
|
||||
engine.telemetry.addData("Right", ticksRight);
|
||||
engine.telemetry.addData("Left", robot.ticksToInches(ticksLeft));
|
||||
engine.telemetry.addData("Right", robot.ticksToInches(ticksRight));
|
||||
|
||||
// engine.telemetry.addLine("");
|
||||
// engine.telemetry.addData("Front", robot.encoderFront);
|
||||
|
||||
@@ -25,8 +25,11 @@ public class Robot {
|
||||
public DcMotor encoderBack;
|
||||
public DcMotor encoderRight;
|
||||
|
||||
double BIAS_LEFT = 1.0;
|
||||
double BIAS_RIGHT = 0.87;
|
||||
double BIAS_LEFT = -1.0;
|
||||
double BIAS_RIGHT = -0.87;
|
||||
|
||||
double Circumference_Encoder = Math.PI * 3.8;
|
||||
int Counts_Per_Revolution = 8192;
|
||||
|
||||
//Robot Localizatoin
|
||||
private double locationX;
|
||||
@@ -46,7 +49,7 @@ public class Robot {
|
||||
// encoderBack = hardwareMap.dcMotor.get("encoderBack");
|
||||
encoderRight = hardwareMap.dcMotor.get("encoderRight");
|
||||
|
||||
encoderLeft.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||
encoderRight.setDirection(DcMotorSimple.Direction.REVERSE);
|
||||
|
||||
encoderLeft.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||
encoderRight.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||
@@ -100,4 +103,12 @@ public class Robot {
|
||||
public double getLocationY() {
|
||||
return locationY;
|
||||
}
|
||||
|
||||
public double ticksToInches(double ticks) {
|
||||
return ticks * (Circumference_Encoder / Counts_Per_Revolution);
|
||||
}
|
||||
|
||||
public double inchesToTicks(double inches) {
|
||||
return inches * (Counts_Per_Revolution / Circumference_Encoder);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user