small tweaks: added loop times measurement and simplified SortedSpindexerTest
This commit is contained in:
@@ -14,6 +14,7 @@ import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
|||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.constants.Color;
|
import org.firstinspires.ftc.teamcode.constants.Color;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
|
import org.firstinspires.ftc.teamcode.pedroPathing.Constants;
|
||||||
|
import org.firstinspires.ftc.teamcode.utils.MeasuringLoopTimes;
|
||||||
import org.firstinspires.ftc.teamcode.utilsv2.*;
|
import org.firstinspires.ftc.teamcode.utilsv2.*;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.utilsv2.Turret.limelightUsed;
|
import static org.firstinspires.ftc.teamcode.utilsv2.Turret.limelightUsed;
|
||||||
@@ -31,6 +32,7 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
Flywheel flywheel;
|
Flywheel flywheel;
|
||||||
VelocityCommander commander;
|
VelocityCommander commander;
|
||||||
ParkTilter parkTilter;
|
ParkTilter parkTilter;
|
||||||
|
MeasuringLoopTimes loopTimes;
|
||||||
|
|
||||||
public static Pose relocalizePose = new Pose(128, 83, 0);
|
public static Pose relocalizePose = new Pose(128, 83, 0);
|
||||||
|
|
||||||
@@ -57,6 +59,9 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
parkTilter = new ParkTilter(robot);
|
parkTilter = new ParkTilter(robot);
|
||||||
parkTilter.unpark();
|
parkTilter.unpark();
|
||||||
|
|
||||||
|
loopTimes = new MeasuringLoopTimes();
|
||||||
|
loopTimes.init();
|
||||||
|
|
||||||
shooter = new Shooter(robot, TELE, follower, Color.redAlliance, turret, flywheel, commander);
|
shooter = new Shooter(robot, TELE, follower, Color.redAlliance, turret, flywheel, commander);
|
||||||
shooter.setState(Shooter.ShooterState.TRACK_GOAL);
|
shooter.setState(Shooter.ShooterState.TRACK_GOAL);
|
||||||
shooter.setRedAlliance(Color.redAlliance);
|
shooter.setRedAlliance(Color.redAlliance);
|
||||||
@@ -142,6 +147,11 @@ public class TeleopV4 extends LinearOpMode {
|
|||||||
parkTilter.unpark();
|
parkTilter.unpark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loopTimes.loop();
|
||||||
|
TELE.addData("Average Loop Time", loopTimes.getAvgLoopTime());
|
||||||
|
TELE.addData("Max Loop Time", loopTimes.getMaxLoopTimeOneMin());
|
||||||
|
TELE.addData("Min Loop Time", loopTimes.getMinLoopTimeOneMin());
|
||||||
|
|
||||||
TELE.addData("Distance From Goal", commander.getDistance());
|
TELE.addData("Distance From Goal", commander.getDistance());
|
||||||
TELE.addData("Hood Position", commander.getHoodPredicted());
|
TELE.addData("Hood Position", commander.getHoodPredicted());
|
||||||
TELE.addData("Transfer Power", robot.transfer.getPower());
|
TELE.addData("Transfer Power", robot.transfer.getPower());
|
||||||
|
|||||||
@@ -106,22 +106,6 @@ public class SortedSpindexerTest extends LinearOpMode {
|
|||||||
spindexerTransferIntake.startSortedShoot();
|
spindexerTransferIntake.startSortedShoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamepad1.right_trigger > 0.5 &&
|
|
||||||
(state == SpindexerTransferIntake.RapidMode.INTAKE ||
|
|
||||||
state == SpindexerTransferIntake.RapidMode.TRANSFER_OFF)) {
|
|
||||||
|
|
||||||
spindexerTransferIntake.setRapidMode(
|
|
||||||
SpindexerTransferIntake.RapidMode.HOLD_BALLS
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (gamepad1.rightBumperWasPressed()
|
|
||||||
&& state == SpindexerTransferIntake.RapidMode.HOLD_BALLS) {
|
|
||||||
|
|
||||||
spindexerTransferIntake.setRapidMode(
|
|
||||||
SpindexerTransferIntake.RapidMode.INTAKE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gamepad1.dpad_down){
|
if (gamepad1.dpad_down){
|
||||||
parkTilter.park();
|
parkTilter.park();
|
||||||
} else if (gamepad1.dpad_up) {
|
} else if (gamepad1.dpad_up) {
|
||||||
|
|||||||
@@ -43,13 +43,12 @@ public class MeasuringLoopTimes {
|
|||||||
|
|
||||||
public void loop() {
|
public void loop() {
|
||||||
currentTime = getTimeSeconds();
|
currentTime = getTimeSeconds();
|
||||||
if ((MeasurementStart + 5.0) < currentTime)
|
if ((MeasurementStart + 60) < currentTime)
|
||||||
{
|
{
|
||||||
minLoopTime = 9999999.0;
|
minLoopTime = 9999999.0;
|
||||||
maxLoopTime = 0.0;
|
maxLoopTime = 0.0;
|
||||||
MeasurementStart = currentTime;
|
MeasurementStart = currentTime;
|
||||||
|
|
||||||
avgLoopTime = avgLoopTimeSum / (double) avgLoopTimeTicker;
|
|
||||||
avgLoopTimeSum = 0.0;
|
avgLoopTimeSum = 0.0;
|
||||||
avgLoopTimeTicker = 0;
|
avgLoopTimeTicker = 0;
|
||||||
}
|
}
|
||||||
@@ -59,6 +58,7 @@ public class MeasuringLoopTimes {
|
|||||||
|
|
||||||
avgLoopTimeSum += mainLoopTime;
|
avgLoopTimeSum += mainLoopTime;
|
||||||
avgLoopTimeTicker++;
|
avgLoopTimeTicker++;
|
||||||
|
avgLoopTime = avgLoopTimeSum / (double) avgLoopTimeTicker;
|
||||||
minLoopTime = Math.min(minLoopTime,mainLoopTime);
|
minLoopTime = Math.min(minLoopTime,mainLoopTime);
|
||||||
maxLoopTime = Math.max(maxLoopTime,mainLoopTime);
|
maxLoopTime = Math.max(maxLoopTime,mainLoopTime);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user