Skip to content

Commit b8737c2

Browse files
new code
1 parent d629b56 commit b8737c2

File tree

2 files changed

+29
-41
lines changed

2 files changed

+29
-41
lines changed

src/main/java/frc/robot/Robot.java

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,32 @@
2020

2121
public class Robot extends LoggedRobot {
2222
private Command m_autonomousCommand;
23+
2324
private final RobotContainer m_robotContainer;
24-
private final Servo phlapServo;
2525

26-
// ✅ Added: reference to localization subsystem
27-
private final localizationSubsystem m_localization = new localizationSubsystem();
26+
private final Servo phlapServo;
2827

2928
public Robot() {
3029

3130
phlapServo = new Servo(3);
3231

3332
PurpleManager.initialize(
34-
this,
35-
Constants.Field.FIELD_LAYOUT,
36-
Path.of("/media/sda1"),
37-
BuildConstants.MAVEN_NAME,
38-
BuildConstants.GIT_SHA,
39-
BuildConstants.BUILD_DATE,
40-
false,
41-
false);
42-
33+
this,
34+
Constants.Field.FIELD_LAYOUT,
35+
Path.of("/media/sda1"),
36+
BuildConstants.MAVEN_NAME,
37+
BuildConstants.GIT_SHA,
38+
BuildConstants.BUILD_DATE,
39+
false,
40+
false
41+
);
42+
4343
m_robotContainer = new RobotContainer();
4444

4545
CameraServer.startAutomaticCapture();
4646

4747
RobotController.setBrownoutVoltage(6.75);
4848

49-
// ✅ Initialize Limelight calibration ranges once here
50-
m_localization.setCalibrationRanges(
51-
new double[] {29000, 31000},
52-
new double[] {12200, 12400},
53-
new double[] {6200, 6400},
54-
new double[] {3600, 3800},
55-
new double[] {1900, 2100});
56-
5749
// Threads.setCurrentThreadPriority(true, 99);
5850
}
5951

@@ -63,23 +55,13 @@ public void robotPeriodic() {
6355
LoopTimer.resetTimer();
6456
CommandScheduler.getInstance().run();
6557
LoopTimer.addTimestamp("CommandScheduler");
66-
67-
// ✅ Feed real-time heading into localization subsystem each loop
68-
try {
69-
double headingDeg =
70-
m_robotContainer.DRIVE_SUBSYSTEM.getPose().getRotation().getDegrees();
71-
m_localization.setRobotHeadingDeg(headingDeg);
72-
} catch (Exception e) {
73-
Logger.recordOutput(
74-
"Localization/HeadingUpdateError",
75-
e.getMessage() == null ? "unknown" : e.getMessage());
76-
}
77-
7858
Threads.setCurrentThreadPriority(false, 0);
7959
}
8060

8161
@Override
82-
public void disabledInit() {}
62+
public void disabledInit() {
63+
64+
}
8365

8466
@Override
8567
public void disabledPeriodic() {
@@ -93,7 +75,7 @@ public void disabledExit() {}
9375
public void autonomousInit() {
9476
Logger.recordOutput("Auto/Lift/State", "starting");
9577
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
96-
78+
9779
phlapServo.set(1);
9880

9981
if (m_autonomousCommand != null) {
@@ -121,13 +103,7 @@ public void teleopInit() {
121103
@Override
122104
public void teleopPeriodic() {
123105
m_robotContainer.checkRumble();
124-
125-
// ✅ Optional: log plan outputs for testing
126-
var plan = m_localization.getPlan();
127-
Logger.recordOutput("Teleop/AlignRecommendation", plan.recommendation);
128-
Logger.recordOutput("Teleop/ForwardError_m", plan.forwardErrorMeters);
129-
Logger.recordOutput("Teleop/StrafeError_m", plan.strafeErrorMeters);
130-
Logger.recordOutput("Teleop/HeadingError_deg", plan.headingErrorDeg);
106+
//localizationSubsystem.localizationSubsystem();
131107
}
132108

133109
@Override

src/main/java/frc/robot/subsystems/localization/localizationSubsystem.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ private void calculateDiagonalsAndMidpoint() {
154154
// diag2, midX, midY);
155155
}
156156

157+
public void calculateMovment() {
158+
int footOne = 30000;
159+
int footThree = 12300;
160+
int footFive = 6300;
161+
int footSeven = 3700;
162+
int footTen = 2000;
163+
double realTimeTA = ta;
164+
double realTimeDistance = 12.23504 * Math.pow(0.999818, realTimeTA) + 1.19735;
165+
Logger.recordOutput("Localization/realTimeDistance", realTimeDistance);
166+
167+
}
168+
157169
// Accessors
158170
public double getTx() {
159171
return tx;

0 commit comments

Comments
 (0)