Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button official #1

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

Button official #1

wants to merge 30 commits into from

Conversation

katyzhen
Copy link
Contributor

@katyzhen katyzhen commented Feb 8, 2023

button official contains all of the buttons and triggers for the xbox controller.

src/main/java/frc/robot/OI.java Outdated Show resolved Hide resolved
Comment on lines 18 to 25
//public static Button pitchPD = Button.kLeftBumper;//pitch pd for charge station
//public static Button stop = Button.kRightBumper;//stop drive bumper
//public static Trigger leftTrigger = Trigger.;

public static Button lowShelf = Button.kX; // low shelf height combo of elevator and arm angle
/*public static Button lowShelf = Button.kX; // low shelf height combo of elevator and arm angle
public static Button midShelf = Button.kA; // mid shelf
public static Button highShelf = Button.kB; // high shelf
public static Button turnNorth = Button.kY;//button to turn to true north

public static Button turnNorth = Button.kY;//button to turn to true north*/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want to comment all of these out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we changed the button code so it's different now

Comment on lines 15 to 24
//import frc.robot.autonomous.AutonomousBase.Paths;
//import frc.robot.Constants;
//import edu.wpi.first.math.controller.PIDController;
//import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.kinematics.ChassisSpeeds;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
//import edu.wpi.first.math.trajectory.Trajectory;
//import edu.wpi.first.math.geometry.Rotation2d;
//import edu.wpi.first.math.geometry.Translation2d;
//import edu.wpi.first.math.kinematics.ChassisSpeeds;
//import frc.robot.OI;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should either be uncommented out or deleted

Comment on lines 43 to 56
private AutonomousBasePD noGo = new AutonomousBasePD(new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0,0, new Rotation2d(0)), new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0,0, new Rotation2d(0)), new Pose2d(0,0, new Rotation2d(0)));
private AutonomousBasePD placeNLeave = new AutonomousBasePD(new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)));
private AutonomousBasePD antiCharge = new AutonomousBasePD(new Pose2d(86.840, -45.282, new Rotation2d(0)), new Pose2d(221.978, 19.463, new Rotation2d(0)), new Pose2d(135.091, -19.421, new Rotation2d(0)), new Pose2d(0, -22.277, new Rotation2d(0)), new Pose2d(222.491, -28.492, new Rotation2d(0)), new Pose2d(0, -43.502, new Rotation2d(0)), new Pose2d(0, -43.502, new Rotation2d(0)));
private AutonomousBasePD antiChargeOpposite = new AutonomousBasePD(new Pose2d(86.840, 45.282, new Rotation2d(0)), new Pose2d(221.978, -19.463, new Rotation2d(0)), new Pose2d(135.091, 19.421, new Rotation2d(0)), new Pose2d(0, 22.277, new Rotation2d(0)), new Pose2d(222.491, 28.492, new Rotation2d(0)), new Pose2d(0, 43.502, new Rotation2d(0)), new Pose2d(0, 43.502, new Rotation2d(0)));
private AutonomousBasePD engageCharge = new AutonomousBasePD(new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)));
private AutonomousBasePD placeTwoEngage = new AutonomousBasePD(new Pose2d(223.014, 16.468, new Rotation2d(0)), new Pose2d(0, 22.683, new Rotation2d(0)), new Pose2d(135.615, 25.539, new Rotation2d(0)), new Pose2d(222.191, 64.230, new Rotation2d(0)), new Pose2d(97.711, 64.230, new Rotation2d(0)), new Pose2d(97.711, 64.230, new Rotation2d(0)), new Pose2d(97.711, 64.230, new Rotation2d(0)));
private AutonomousBaseTimed timedPath = new AutonomousBaseTimed();
private AutonomousBasePD testPath = new AutonomousBasePD(new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)));
private AutonomousBaseMP motionProfiling = new AutonomousBaseMP(Trajectories.uno, Trajectories.dos, Trajectories.tres);

//above coordinates didn't work
private AutonomousBasePD leave = new AutonomousBasePD(new Pose2d(56.069, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)));
private AutonomousBasePD placeTwoEngageReal = new AutonomousBasePD(new Pose2d(56.069, 17.332, new Rotation2d(0)), new Pose2d(278.999, 37.193, new Rotation2d(0)), new Pose2d(257.650, 64.004, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0)));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want to delete all of these?

Comment on lines 41 to 47
// private AutonomousBasePD blueCharge = new AutonomousBasePD(new Translation2d(221.353, 23.720), new Translation2d(0, 21.574), new Translation2d(96.902, 21.574), new Translation2d(96.902, 21.574), new Translation2d(96.902, 21.574), new Translation2d(96.902, 21.574));
// private AutonomousBasePD redCharge = new AutonomousBasePD(new Translation2d(222.624, 15.665), new Translation2d(0, 21.886), new Translation2d(221.671, 67.260), new Translation2d(97.188, 67.260), new Translation2d(97.188, 67.260), new Translation2d(97.188, 67.260));
// private AutonomousBasePD antiCharge = new AutonomousBasePD(new Translation2d(86.840, -45.282), new Translation2d(221.978, 19.463), new Translation2d(135.091, -19.421), new Translation2d(0, -22.277), new Translation2d(222.491, -28.492), new Translation2d(0, -43.502));
// private AutonomousBasePD mScore = new AutonomousBasePD(new Translation2d(222.037, 0), new Translation2d(135.091, -41.307), new Translation2d(0, -44.163), new Translation2d(222.894, -50.377), new Translation2d(0, -65.388), new Translation2d(0, -65.388));
// private AutonomousBaseTimed timedPath = new AutonomousBaseTimed();
// private AutonomousBasePD testPath = new AutonomousBasePD(new Translation2d(0, 20), new Translation2d(0, 20), new Translation2d(0, 20), new Translation2d(0, 20), new Translation2d(0, 20), new Translation2d(0, 20));
//private AutonomousBaseMP motionProfiling = new AutonomousBaseMP(Trajectories.uno, Trajectories.dos, Trajectories.tres);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these commented out?

Comment on lines 95 to 106
//public void armPID(double armLengthSetpoint){
// armLengthController.setSetpoint(armLengthSetpoint);
//double output = armLengthController.calculate(getArmLength(), armLengthSetpoint);
//System.out.println("output: " + output);
//armMotor.set(ControlMode.PercentOutput, output);//written as _talon.set(TalonFXControlMode.PercentOutput, leftYstick); in documentation. leftystick is joy.gety
//}

// if (Math.abs(leftYstick) < 0.10/*this number should be changed through testing*/) {
// /* Within 10% of zero */
// leftYstick = 0;//left joystick y axis in documentation. assign later
// }

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this or can we delete it?

Comment on lines 40 to 71
/*public void init(){
System.out.println("elevator init!!!!");
elevatorMotor.setInverted(true);
elevatorMotor.setNeutralMode(NeutralMode.Brake);

//configuring deadband
elevatorMotor.configAllowableClosedloopError(0, Constants.kPIDLoopIdx, Constants.kTimeoutMs);
/* Config Position Closed Loop gains in slot0, typically kF stays zero. */
/*elevatorMotor.config_kP(Constants.kPIDLoopIdx, elevatorGains.kP, Constants.kTimeoutMs);
elevatorMotor.config_kI(Constants.kPIDLoopIdx, elevatorGains.kI, Constants.kTimeoutMs);
elevatorMotor.config_kD(Constants.kPIDLoopIdx, elevatorGains.kD, Constants.kTimeoutMs);
}*/

/* public void periodic(){//still need to scale down the values or figure out why it is overshooting
System.out.println("periodic!!!!!!!");
if (elevatorState == ElevatorStates.STOP){ //emergency stop
elevatorMotor.set(ControlMode.PercentOutput, 0);
}else if (elevatorState == ElevatorStates.ZERO){ //facing forward, turning clockwise = going down
elevatorMotor.set(ControlMode.Position, 0);
} else if (elevatorState == ElevatorStates.LOW_ELEVATOR_HEIGHT){
elevatorMotor.set(ControlMode.Position, (5/scaleDown) * Constants.TICKS_PER_INCH); //change value once we know robot dimensions
} else if (elevatorState == ElevatorStates.MID_ELEVATOR_HEIGHT){
elevatorMotor.set(ControlMode.Position, (24.5/scaleDown) * Constants.TICKS_PER_INCH); //change value once we know robot dimensions
} else {
elevatorMotor.set(ControlMode.Position, 20 / scaleDown); //change value once we know robot dimensions
}

if(top_limit_switch.get() || bottom_limit_switch.get()){
setState(ElevatorStates.STOP);
System.out.println("Top/bottom limit switch triggered");
}
}*/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is all of this commented out?

@@ -56,6 +56,9 @@ public final class Constants {
public static final int BACK_RIGHT_MODULE_DRIVE_MOTOR = 22;
public static final int BACK_RIGHT_MODULE_STEER_MOTOR = 23;
public static final int BACK_RIGHT_MODULE_STEER_ENCODER = 3;

//public static final double BACK_RIGHT_MODULE_STEER_OFFSET = -Math.toRadians(267.45); // FIXME Measure and set back right steer offset
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed still or can we delete it?

public static final int ELEVATOR_CAN_ID = 9;

public static final double TELESCOPING_ARM_GEAR_RATIO = 36.0;
public static final double FIRST_WHEEL_DIAMETER= 1.13;//0.9; //0.75 inches - rough estimate by sara 2/2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do both of these say 0.75 inches?

public class ArmTelescopingSubsystem {

//PIDController armLengthController = new PIDController(armLengthKP, armLengthKI, armLengthKD);
public static TelescopingStates tState = TelescopingStates.RETRACTED;//should this be retracted or mid? what is the equivalent to off?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be public static? Can it be private?

Comment on lines +20 to +21
public int _kIzone = 0;
public double _kPeakOutput = 1.0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be public? Usually when a variable has _ in front of it, it means it's private.

}
}

public void determineRightTicks(){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function would be a bit cleaner if it returned desiredTicks instead of setting a class variable. That way above it would be

desiredTicks = determineRightTicks();

And then it's more obvious where desiredTicks comes from.

double milliTime = time * 1000;
System.out.println("milli time: " + milliTime);
if(forwards == true){
while(System.currentTimeMillis() - startTime <= milliTime){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general while loops are scary for robot code. When you're waiting in this while loop the rest of the robot will be paused and the repeated calling of periodic won't happen at the frequency it's supposed to.

public static double pitchKP = 0.025;
public static double pitchKI = 0.0;
public static double pitchKD = 0.001;
public static double MINOUTPUT = 0.1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final?

Comment on lines +42 to +44
public static double pitchKP = 0.025;
public static double pitchKI = 0.0;
public static double pitchKD = 0.001;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be public static?

Comment on lines 249 to 271
public void scoreLow(){
ArmTelescopingSubsystem.setTState(TelescopingStates.LOW_ARM_LENGTH);
}

public void scoreHigh(){
ArmTelescopingSubsystem.setTState(TelescopingStates.HIGH_ARM_LENGTH);
}

public void scoreMid(){
ArmTelescopingSubsystem.setTState(TelescopingStates.MID_ARM_LENGTH);
}

public void substation(){
ArmTelescopingSubsystem.setTState(TelescopingStates.SHELF_ARM_LENGTH);
}

public void intake(){
PneumaticIntakeSubsystem.setState(PneumaticIntakeStates.ACTUATING);
}

public void outtake(){
PneumaticIntakeSubsystem.setState(PneumaticIntakeStates.RETRACTING);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these really belong in DrivetrainSubsystem? They don't seem to have anything to do with the drivetrain.

Comment on lines -95 to +100

boolean purpleNotRedThreshold = (Math.abs(detectedColor.red-kPurpleTarget.red)>COLOR_THRESHOLD);
boolean purpleNotGreenThreshold = (Math.abs(detectedColor.green-kPurpleTarget.green)>COLOR_THRESHOLD);
boolean purpleNotBlueThreshold = (Math.abs(detectedColor.blue-kPurpleTarget.blue)>COLOR_THRESHOLD);

boolean yellowNotRedThreshold = (Math.abs(detectedColor.red-kYellowTarget.red)>COLOR_THRESHOLD);
boolean yellowNotGreenThreshold = (Math.abs(detectedColor.green-kYellowTarget.green)>COLOR_THRESHOLD);
boolean yellowNotBlueThreshold = (Math.abs(detectedColor.blue-kYellowTarget.blue)>COLOR_THRESHOLD);

if((purpleNotRedThreshold && purpleNotGreenThreshold) || (purpleNotRedThreshold &&purpleNotBlueThreshold) || (purpleNotGreenThreshold && purpleNotBlueThreshold)){
// System.out.println("diff w/ purple red: " + (detectedColor.red-kPurpleTarget.red));
// System.out.println("diff w/ purple green: " + (detectedColor.green-kPurpleTarget.green));
// System.out.println("diff w/ purple blue: " + (detectedColor.blue-kPurpleTarget.blue));
if((Math.abs(detectedColor.red-kPurpleTarget.red)>colorThreshold && Math.abs(detectedColor.green-kPurpleTarget.green)>colorThreshold) || (Math.abs(detectedColor.red-kPurpleTarget.red)>colorThreshold && Math.abs(detectedColor.blue-kPurpleTarget.blue)>colorThreshold) || (Math.abs(detectedColor.green-kPurpleTarget.green)>colorThreshold && Math.abs(detectedColor.blue-kPurpleTarget.blue)>colorThreshold)){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a bad merge - we lost the changes we made before with the separate booleans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants