Skip to content

Commit e4558d6

Browse files
committed
added test stuff on test mode and added backward in cm
1 parent 52f6bd8 commit e4558d6

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,19 @@ public void teleopPeriodic() {
182182

183183
/** This function is called once when test mode is enabled. */
184184
@Override
185-
public void testInit() {}
185+
public void testInit() {
186+
try{
187+
drivebaseIODev.turndegress(1, 90, "left");
188+
Thread.sleep(1000);
189+
drivebaseIODev.turndegress(1, 90, "right");
190+
Thread.sleep(1000);
191+
drivebaseIODev.forwardincm(1, 5);
192+
Thread.sleep(1000);
193+
drivebaseIODev.backwardincm(1,5);
194+
}catch(Exception e){
195+
196+
}
197+
}
186198

187199
/** This function is called periodically during test mode. */
188200
@Override

src/main/java/frc/robot/subsystem/drivebase/drivebase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ public Command forwardincm(double velocity, int centermeters) {
3030
public Command turndegress(double velocity, int angle, String direction){
3131
return run(() -> io.turndegress(velocity, angle, direction));
3232
}
33+
public Command backwardincm(double velocity, int centermeters) {
34+
return run(() -> io.backwardincm(velocity, centermeters));
35+
}
3336

3437
}

src/main/java/frc/robot/subsystem/drivebase/drivebaseIO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public default void backward(double velocity){}
1818
public default void turn(double velocity, String direction){}
1919
public default void stop(){}
2020
public default void forwardincm(double velocity, int centermeters){}
21+
public default void backwardincm(double velocity, int centermeters){}
2122
public default void turndegress(double velocity, int angle, String direction){}
2223

2324
}

src/main/java/frc/robot/subsystem/drivebase/drivebaseIODev.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ public void forwardincm(double velocity, int centermeters){
7676
System.out.println("not yet");
7777
}
7878
stop();
79+
}
80+
@Override
81+
public void backwardincm(double velocity, int centermeters){
82+
topleft.getEncoder().setPosition(0);
83+
double position = topleft.getEncoder().getPosition();
84+
double cimcufarance = Math.PI * WheelDiameterinCM;
85+
double rotationstotake = centermeters / cimcufarance;
86+
backward(velocity);
87+
while (position != rotationstotake) {
88+
System.out.println("not yet");
89+
}
90+
stop();
7991
}
8092
@Override
8193
public void turndegress(double velocity, int angle, String direction){

0 commit comments

Comments
 (0)