Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/frc/robot/DeviceIDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ public static class drivetrainIDs {
public static final int BACK_RIGHT_ABSOLUTE_ENCODER_CAN = 3;
}

// Rotor and Motion IDs: 10~29
public static class rotorIDs {
public static final int SERIALIZER_ROLLERS_CAN = 10;
public static final int INTAKE_ROLLERS_WEST_CAN = 11;
public static final int INTAKE_ROLLERS_EAST_CAN = 18;
public static final int TRANSFER_ROLLERS_WEST_CAN = 13;
public static final int TRANSFER_ROLLERS_EAST_CAN = 12;
public static final int FLYWHEEL_TOP_WEST_CAN = 15;
public static final int SHOOTER_TRANSFER_EAST_CAN = 12;
public static final int SHOOTER_TRANSFER_WEST_CAN = 13;

public static final int FLYWHEEL_TOP_EAST_CAN = 14;
public static final int FLYWHEEL_BOTTOM_WEST_CAN = 17;
public static final int FLYWHEEL_TOP_WEST_CAN = 15;
public static final int FLYWHEEL_BOTTOM_EAST_CAN = 16;
public static final int FLYWHEEL_BOTTOM_WEST_CAN = 17;
}

// Motion Profile IDs: 30~49
public static class motionIDs {
public static final int HOOD_PIVOT_CAN = 32;
public static final int INTAKE_PIVOT_CAN = 30;
public static final int HOOD_CAN = 32;
}
}
12 changes: 10 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
Expand All @@ -21,8 +22,10 @@
import edu.wpi.first.wpilibj2.command.DeferredCommand;
import frc.robot.DeviceIDs.controllerIDs;
import frc.robot.commands.AddVisionMeasurement;
import frc.robot.commands.ResetPose;
import frc.robot.commands.states.Intaking;
import frc.robot.commands.states.RetractIntake;
import frc.robot.commands.states.Shooting;
import frc.robot.constants.ConstSystem;
import frc.robot.constants.ConstSystem.constControllers;
import frc.robot.subsystems.DriverStateMachine;
Expand Down Expand Up @@ -57,13 +60,15 @@ public class RobotContainer {
private final StateMachine loggedStateMachineInstance = stateMachineInstance;
public static final RobotPoses robotPose = new RobotPoses();
private final RobotPoses loggedRobotPose = robotPose;
public static final Intaking intakingInstance = new Intaking();
public static final RetractIntake RetractingInstance = new RetractIntake();
public static final Vision visionInstance = new Vision();
private final Vision loggedVisionInstance = visionInstance;
public static final Telemetry telemetryInstance = new Telemetry();
private final Telemetry loggedTelemetryInstance = telemetryInstance;

public static final Intaking intakingInstance = new Intaking();
public static final RetractIntake RetractingInstance = new RetractIntake();
public static final Shooting shooting = new Shooting();

Command TRY_NONE = Commands.deferredProxy(
() -> stateMachineInstance.tryState(RobotState.NONE));

Expand Down Expand Up @@ -103,6 +108,9 @@ private void configDriverBindings() {
.whileTrue(intakingInstance);
conDriver.btn_LeftTrigger
.whileTrue(RetractingInstance);
conDriver.btn_RightBumper
.whileTrue(shooting);
conDriver.btn_North.whileTrue(new ResetPose());
// Example Pose Drive
conDriver.btn_X
.whileTrue(EXAMPLE_POSE_DRIVE)
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/frc/robot/commands/states/Intaking.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ public Intaking() {
@Override
public void initialize() {
RobotContainer.motionInstance.setIntakePivotAngle(ConstMotion.INTAKE_PIVOT_DEPLOY);
RobotContainer.rotorsInstance.setIntakeRollersSpeed(0.5);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why hardcoded? should be in constants

}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
RobotContainer.rotorsInstance.setIntakeRollersSpeeds(ConstRotors.INTAKE_ROLLERS_SPEED);

}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
RobotContainer.rotorsInstance.setIntakeRollersSpeeds(ConstRotors.STOP);
RobotContainer.rotorsInstance.setIntakeRollersSpeeds(ConstRotors.STOP_ALL);

}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/states/Shooting.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void execute() {
public void end(boolean interrupted) {
RobotContainer.rotorsInstance.setFlywheelSpeeds(ConstRotors.STOP_ALL);
RobotContainer.rotorsInstance.setTransferRollersSpeeds(ConstRotors.STOP_ALL);
RobotContainer.rotorsInstance.setSerializerRollersSpeed(ConstRotors.STOP_ALL);
RobotContainer.rotorsInstance.setSerializerRollersSpeed(ConstRotors.STOP);

}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/frc/robot/constants/ConstDrivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public class ConstDrivetrain {
public static final Time ROTATION_DELAY = Seconds.of(0.5);

// TODO: Swoffsets
public static final Angle FRONT_LEFT_ABS_ENCODER_OFFSET = Rotations.of(-0.178466796875);
public static final Angle FRONT_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(-0.498779296875);
public static final Angle BACK_LEFT_ABS_ENCODER_OFFSET = Rotations.of(-0.459716796875);
public static final Angle BACK_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(-0.31201171875);
public static final Angle FRONT_LEFT_ABS_ENCODER_OFFSET = Rotations.of(0.229248046875);
public static final Angle FRONT_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(0.406005859375);
public static final Angle BACK_LEFT_ABS_ENCODER_OFFSET = Rotations.of(0.476806640625);
public static final Angle BACK_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(-0.144775390625);

public static class PRACTICE_BOT {
// TODO: Swoffsets
public static final Angle FRONT_LEFT_ABS_ENCODER_OFFSET = Rotations.of(-0.199462890625);
public static final Angle FRONT_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(0.474365234375);
public static final Angle BACK_LEFT_ABS_ENCODER_OFFSET = Rotations.of(-0.447265625);
public static final Angle BACK_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(-0.3193359375);
public static final Angle FRONT_LEFT_ABS_ENCODER_OFFSET = Rotations.of(0.229248046875);
public static final Angle FRONT_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(0.406005859375);
public static final Angle BACK_LEFT_ABS_ENCODER_OFFSET = Rotations.of(0.476806640625);
public static final Angle BACK_RIGHT_ABS_ENCODER_OFFSET = Rotations.of(-0.144775390625);
}

public static final double SLOW_MODE_MULTIPLIER = 0.5;
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/frc/robot/constants/ConstRotors.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ public class ConstRotors {
public static final TalonFXConfiguration TRANSFER_ROLLERS_WEST_CONFIGURATION = new TalonFXConfiguration();
public static final TalonFXConfiguration FLYWHEEL_EAST_CONFIGURATION = new TalonFXConfiguration();
public static final TalonFXConfiguration FLYWHEEL_WEST_CONFIGURATION = new TalonFXConfiguration();
public static final AngularVelocity INTAKE_ROLLERS_SPEED = Units.RPM.of(3);
public static final AngularVelocity FLYWHEEL_SHOOTING_SPEED = Units.RPM.of(1000);
public static final AngularVelocity INTAKE_ROLLERS_SPEED = Units.RPM.of(1000);
public static final AngularVelocity FLYWHEEL_SHOOTING_SPEED = Units.RPM.of(3000);
public static final AngularVelocity INTAKE_ROLLER_SPEED = Units.RPM.of(2000);
public static final AngularVelocity INTAKE_TRANSFER_SPEED = Units.RPM.of(3000);
public static final AngularVelocity SERIALIZER_SHOOTING_SPEED = Units.RPM.of(4000);
public static final double SERIALIZER_SHOOTING_SPEED = 1;
public static final AngularVelocity STOP_ALL = Units.RPM.of(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not a good name

public static final double STOP = 0;

static {

Expand Down Expand Up @@ -83,7 +84,4 @@ public class ConstRotors {
TRANSFER_ROLLERS_WEST_CONFIGURATION.MotorOutput.Inverted = InvertedValue.Clockwise_Positive;

}

public static final AngularVelocity STOP = Units.RPM.of(0);

}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/Motion.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class Motion extends SubsystemBase {
/** Creates a new Motion. */
final TalonFX intakePivot = new TalonFX(DeviceIDs.motionIDs.INTAKE_PIVOT_CAN);
final TalonFX hoodPivot = new TalonFX(DeviceIDs.motionIDs.HOOD_PIVOT_CAN);
final TalonFX hoodPivot = new TalonFX(DeviceIDs.motionIDs.HOOD_CAN);

MotionMagicExpoVoltage hoodPivotMotionRequest = new MotionMagicExpoVoltage(0);
MotionMagicExpoVoltage intakePivotMotionRequest = new MotionMagicExpoVoltage(0);
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/frc/robot/subsystems/Rotors.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class Rotors extends SubsystemBase {
final TalonFX serializerRollers = new TalonFX(rotorIDs.SERIALIZER_ROLLERS_CAN);
final TalonFX intakeRollersWest = new TalonFX(rotorIDs.INTAKE_ROLLERS_WEST_CAN);
final TalonFX intakeRollersEast = new TalonFX(rotorIDs.INTAKE_ROLLERS_EAST_CAN);
final TalonFX transferRollersWest = new TalonFX((rotorIDs.TRANSFER_ROLLERS_WEST_CAN));
final TalonFX transferRollersEast = new TalonFX((rotorIDs.TRANSFER_ROLLERS_EAST_CAN));
final TalonFX transferRollersWest = new TalonFX((rotorIDs.SHOOTER_TRANSFER_WEST_CAN));
final TalonFX transferRollersEast = new TalonFX((rotorIDs.SHOOTER_TRANSFER_EAST_CAN));
final TalonFX flywheelTopWest = new TalonFX((rotorIDs.FLYWHEEL_TOP_WEST_CAN));
final TalonFX flywheelTopEast = new TalonFX((rotorIDs.FLYWHEEL_TOP_EAST_CAN));
final TalonFX flywheelBottomWest = new TalonFX((rotorIDs.FLYWHEEL_BOTTOM_WEST_CAN));
Expand Down Expand Up @@ -77,8 +77,8 @@ public AngularVelocity getTransferRollersVelocity() {
return transferRollersEast.getVelocity().getValue();
}

public void setSerializerRollersSpeed(AngularVelocity speed) {
serializerRollers.setControl(serializerVelocityRequest.withVelocity(speed));
public void setSerializerRollersSpeed(Double speed) {
serializerRollers.set(speed);
}
Comment thread
Wu-Fan-529 marked this conversation as resolved.

public void setIntakeRollersSpeeds(AngularVelocity speed) {
Expand Down Expand Up @@ -111,6 +111,11 @@ public boolean isFlyWheelAtSpeed(AngularVelocity tolerance) {

}

public void setIntakeRollersSpeed(double speed) {
intakeRollersWest.set(speed);
intakeRollersEast.setControl(intakeRollerEastFollower);
}
Comment on lines +114 to +117

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Its following itself


@Override
public void periodic() {
// This method will be called once per scheduler run
Expand Down