edited Flywheel.java
This commit is contained in:
@@ -1,19 +1,9 @@
|
|||||||
package org.firstinspires.ftc.teamcode.teleop;
|
package org.firstinspires.ftc.teamcode.teleop;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.constants.Poses.teleStart;
|
import static org.firstinspires.ftc.teamcode.constants.Poses.teleStart;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_intakePos1;
|
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.*;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_outtakeBall1;
|
import static org.firstinspires.ftc.teamcode.constants.ShooterVars.*;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_outtakeBall2;
|
import static org.firstinspires.ftc.teamcode.utils.PositionalServoProgrammer.*;
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.spindexer_outtakeBall3;
|
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_in;
|
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.transferServo_out;
|
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ServoPositions.turrDefault;
|
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ShooterVars.waitTransfer;
|
|
||||||
import static org.firstinspires.ftc.teamcode.constants.ShooterVars.waitTransferOut;
|
|
||||||
import static org.firstinspires.ftc.teamcode.tests.ShooterTest.kP;
|
|
||||||
import static org.firstinspires.ftc.teamcode.tests.ShooterTest.maxStep;
|
|
||||||
import static org.firstinspires.ftc.teamcode.utils.PositionalServoProgrammer.restPos;
|
|
||||||
import static org.firstinspires.ftc.teamcode.utils.PositionalServoProgrammer.scalar;
|
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.firstinspires.ftc.teamcode.tests;
|
package org.firstinspires.ftc.teamcode.tests;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.constants.ShooterVars.*;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
||||||
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
import com.acmerobotics.dashboard.telemetry.MultipleTelemetry;
|
||||||
@@ -17,8 +19,6 @@ public class ShooterTest extends LinearOpMode {
|
|||||||
public static double parameter = 0.0;
|
public static double parameter = 0.0;
|
||||||
// --- CONSTANTS YOU TUNE ---
|
// --- CONSTANTS YOU TUNE ---
|
||||||
public static double MAX_RPM = 4500; // your measured max RPM
|
public static double MAX_RPM = 4500; // your measured max RPM
|
||||||
public static double kP = 0.001; // small proportional gain (tune this)
|
|
||||||
public static double maxStep = 0.06; // prevents sudden jumps
|
|
||||||
|
|
||||||
//TODO: @Daniel FIX THE BELOW CONSTANTS A LITTLE IF NEEDED
|
//TODO: @Daniel FIX THE BELOW CONSTANTS A LITTLE IF NEEDED
|
||||||
public static double transferPower = 0.0;
|
public static double transferPower = 0.0;
|
||||||
|
|||||||
@@ -13,15 +13,16 @@ public class Flywheel {
|
|||||||
double stamp = 0.0;
|
double stamp = 0.0;
|
||||||
double stamp1 = 0.0;
|
double stamp1 = 0.0;
|
||||||
double ticker = 0.0;
|
double ticker = 0.0;
|
||||||
double stamp2 = 0.0;
|
|
||||||
double currentPos = 0.0;
|
double currentPos = 0.0;
|
||||||
boolean prevSteady = false;
|
|
||||||
double velo = 0.0;
|
double velo = 0.0;
|
||||||
double prevVelo = 0.0;
|
double velo1 = 0.0;
|
||||||
|
double velo2 = 0.0;
|
||||||
|
double velo3 = 0.0;
|
||||||
|
double velo4 = 0.0;
|
||||||
|
double velo5 = 0.0;
|
||||||
double targetVelocity = 0.0;
|
double targetVelocity = 0.0;
|
||||||
double powPID = 0.0;
|
double powPID = 0.0;
|
||||||
boolean steady = false;
|
boolean steady = false;
|
||||||
|
|
||||||
public Flywheel () {
|
public Flywheel () {
|
||||||
//robot = new Robot(hardwareMap);
|
//robot = new Robot(hardwareMap);
|
||||||
}
|
}
|
||||||
@@ -41,15 +42,22 @@ public class Flywheel {
|
|||||||
|
|
||||||
|
|
||||||
public double manageFlywheel(int commandedVelocity, double shooter1CurPos) {
|
public double manageFlywheel(int commandedVelocity, double shooter1CurPos) {
|
||||||
targetVelocity = (double) commandedVelocity;
|
targetVelocity = commandedVelocity;
|
||||||
|
|
||||||
ticker++;
|
ticker++;
|
||||||
if (ticker % 8 == 0) {
|
if (ticker % 2 == 0) {
|
||||||
|
velo5 = velo4;
|
||||||
|
velo4 = velo3;
|
||||||
|
velo3 = velo2;
|
||||||
|
velo2 = velo1;
|
||||||
|
|
||||||
currentPos = shooter1CurPos / 2048;
|
currentPos = shooter1CurPos / 2048;
|
||||||
stamp = getTimeSeconds(); //getRuntime();
|
stamp = getTimeSeconds(); //getRuntime();
|
||||||
velo = -60 * ((currentPos - initPos) / (stamp - stamp1));
|
velo1 = -60 * ((currentPos - initPos) / (stamp - stamp1));
|
||||||
initPos = currentPos;
|
initPos = currentPos;
|
||||||
stamp1 = stamp;
|
stamp1 = stamp;
|
||||||
|
|
||||||
|
velo = (velo1 + velo2 + velo3 + velo4 + velo5) / 5;
|
||||||
}
|
}
|
||||||
// Flywheel control code here
|
// Flywheel control code here
|
||||||
if (targetVelocity - velo > 500) {
|
if (targetVelocity - velo > 500) {
|
||||||
@@ -74,19 +82,12 @@ public class Flywheel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// really should be a running average of the last 5
|
// really should be a running average of the last 5
|
||||||
if ((Math.abs(targetVelocity - velo) < 150.0) && (Math.abs(targetVelocity - prevVelo) < 150.0))
|
steady = (Math.abs(targetVelocity - velo) < 100.0);
|
||||||
{
|
|
||||||
steady = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
steady = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return powPID;
|
return powPID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
Reference in New Issue
Block a user