Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamSH-LLK committed Nov 24, 2024
1 parent 1908e5d commit 9c2276c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 56 deletions.
68 changes: 12 additions & 56 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
public class Robot extends TimedRobot {
private Command m_autonomousCommand;
private DriveTrain driveTrain = new DriveTrain();
private double buttonCooldown = 0;
private FieldMap fieldMap = new FieldMap() {

};
Expand Down Expand Up @@ -84,69 +83,25 @@ public Robot() {
driveTrain.setDefaultCommand(
new RunCommand(
() -> {
if(joystick.button(1).getAsBoolean()&&buttonCooldown<=0){
driveTrain.zeroHeading();
buttonCooldown = 0.25;
}
if(buttonCooldown>0) {
buttonCooldown-=0.02;
}
//System.out.println("here2");
int controltype = 2; // keyboard nonsense! 1=keyboard 2=logitech joystick 0=thrustmaster

double multiplier = (((joystick.getThrottle() * -1) + 1) / 2); // turbo mode
double z = joystick.getZ() * -.9;

double z = joystick.getZ();
double x = joystick.getX();
double y = joystick.getY();

// limiting x/y on input methods
if (controltype == 1) {
/*
var ogx = x;
var ogy = y;
x = Math.sin(Math.atan2(ogx, ogy)) * Math.min(Math.max(Math.abs(ogy), Math.abs(ogx)),1);
y = Math.cos(Math.atan2(ogx, ogy)) * Math.min(Math.max(Math.abs(ogy), Math.abs(ogx)),1);
*/
} else if (controltype == 2) {
/*
var ogx = x;
var ogy = y;
y = ogy;
x = ogx;
*/

if(x>=-.101&&x<=.101) {
x = 0;
}
if(y>=-.101&&y<=.101) {
y = 0;
}
if(x>=-.101&&x<=.101) {
x = 0;
}

/*
ogx = x;
ogy = y;
x = Math.sin(Math.atan2(ogx, ogy)) * Math.max(Math.abs(ogy), Math.abs(ogx));
y = Math.cos(Math.atan2(ogx, ogy)) * Math.max(Math.abs(ogy), Math.abs(ogx));
*/
}

var ogx = x;
var ogy = y;
x = Math.sin(Math.atan2(ogx, ogy)) * Math.min(Math.max(Math.abs(ogy), Math.abs(ogx)),1);
y = Math.cos(Math.atan2(ogx, ogy)) * Math.min(Math.max(Math.abs(ogy), Math.abs(ogx)),1);
x = Math.sin(Math.atan2(x, y)) * Math.min(Math.max(Math.abs(y), Math.abs(x)), 1);
y = Math.cos(Math.atan2(x, y)) * Math.min(Math.max(Math.abs(y), Math.abs(x)), 1);
double deadband = OperatorConstants.kLogitech ? OperatorConstants.kLogitechDeadband : OperatorConstants.kDriveDeadband;

driveTrain.drive(
MathUtil.applyDeadband(
y * -multiplier,
OperatorConstants.kDriveDeadband),
deadband),
MathUtil.applyDeadband(
x * -multiplier,
OperatorConstants.kDriveDeadband),
MathUtil.applyDeadband(z, OperatorConstants.kDriveDeadband),
deadband),
MathUtil.applyDeadband(z * -1, deadband),
true);
},
driveTrain));
Expand All @@ -155,7 +110,9 @@ public Robot() {
}

public void configureBindings() {

joystick.trigger().onTrue(Commands.run(() -> {
driveTrain.zeroHeading();
}));
}

/**
Expand Down Expand Up @@ -243,13 +200,12 @@ public void simulationInit() {
// Obtains the default instance of the simulation world, which is a Crescendo
// Arena.
SimulatedArena.getInstance();

// Add a Crescendo note to the field
SimulatedArena.getInstance().resetFieldForAuto();

// Get the positions of the notes (both on the field and in the air)
notesPoses = SimulatedArena.getInstance().getGamePiecesByType("Note");


}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/configs/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
*/
public final class Constants {
public static class OperatorConstants {
public static final boolean kLogitech = false;
public static final int kDriverJoystickPort = 0;
public static final double kDriveDeadband = 0.05;
public static final double kLogitechDeadband = 0.1;

}

}

0 comments on commit 9c2276c

Please sign in to comment.