-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/intake phx6 alon #6
base: main
Are you sure you want to change the base?
Changes from 12 commits
3919d2b
1e831bc
721eaa5
a51c911
1d09951
903dce0
48cee81
d6f81c5
12fe8b5
3d809ce
a250571
3b00257
00e3cf8
fda897a
5495eb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import edu.wpi.first.wpilibj.XboxController; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import edu.wpi.first.wpilibj2.command.RunCommand; | ||
import edu.wpi.first.wpilibj2.command.button.JoystickButton; | ||
import edu.wpi.first.wpilibj2.command.button.Trigger; | ||
import frc.robot.commandgroups.PickUpCubeTeleop; | ||
|
@@ -16,18 +17,26 @@ | |
import frc.robot.subsystems.gripper.Gripper; | ||
import frc.robot.subsystems.intake.Intake; | ||
import frc.robot.subsystems.intake.commands.HoldIntakeInPlace; | ||
import frc.robot.subsystems.intake.commands.IntakeKeyboardControl; | ||
import frc.robot.subsystems.intake.commands.ProximitySensorDefaultCommand; | ||
import frc.robot.subsystems.intake.commands.Retract; | ||
import frc.robot.subsystems.leds.Leds; | ||
import swerve.SwerveDrive; | ||
import swerve.commands.XboxDrive; | ||
import utils.Utils; | ||
|
||
|
||
public class RobotContainer { | ||
private static RobotContainer INSTANCE = null; | ||
private final Arm arm = Arm.getINSTANCE(); | ||
private final Leds leds = Leds.getInstance(); | ||
private final SwerveDrive swerveDrive = SwerveDrive.getInstance(Robot.isReal()); | ||
static { | ||
SwerveDrive.setInstance(Robot.isReal(), | ||
Ports.SwerveDrive.DRIVE_IDS, | ||
Ports.SwerveDrive.ANGLE_IDS, | ||
Ports.SwerveDrive.ENCODER_IDS); | ||
} | ||
private final SwerveDrive swerveDrive = SwerveDrive.getInstance(); | ||
private final Intake intake = Intake.getInstance(); | ||
private final Gripper gripper = Gripper.getInstance(); | ||
private final XboxController xboxController = new XboxController(0); | ||
|
@@ -77,35 +86,12 @@ private void configureDefaultCommands() { | |
new XboxDrive(swerveDrive, xboxController) | ||
); | ||
// arm.setDefaultCommand(new ArmXboxControl(xboxController)); | ||
intake.setDefaultCommand(new HoldIntakeInPlace()); | ||
intake.setDefaultCommand(new IntakeKeyboardControl()); | ||
leds.setDefaultCommand(new ProximitySensorDefaultCommand()); | ||
} | ||
|
||
private void configureButtonBindings() { | ||
leftJoystickTrigger.onTrue(new InstantCommand(swerveDrive::resetGyro)); | ||
y.whileTrue(new ArmWithSpline(ArmPosition.TOP_SCORING)); | ||
x.whileTrue(new ArmWithSpline(ArmPosition.MIDDLE_SCORING)); | ||
b.whileTrue(new ArmWithSpline(ArmPosition.FEEDER)); | ||
back.whileTrue(new ArmWithSpline(ArmPosition.FEEDER_CONE)); | ||
a.whileTrue(new ArmWithSpline(ArmPosition.NEUTRAL)); | ||
|
||
lb.onTrue(new InstantCommand(gripper::toggle)); | ||
|
||
start.onTrue(new InstantCommand(leds::toggle)); | ||
|
||
leftJoystickTopBottom.toggleOnTrue( | ||
new InstantCommand(swerveDrive::lock, swerveDrive) | ||
); | ||
leftJoystickTopBottom.onTrue( | ||
new InstantCommand(leds::toggleRainbow) | ||
); | ||
|
||
xboxLeftTrigger.whileTrue(new PickUpCubeTeleop()) | ||
.onFalse(new Retract(Retract.Mode.UP).andThen(new InstantCommand(() -> intake.setSpinMotorPower(0)))); | ||
xboxRightTrigger.whileTrue(new ReturnIntake()); | ||
|
||
rb.whileTrue(new ArmAxisControl(0.02, 0.02) | ||
.until(() -> gripper.getDistance() < ArmConstants.FEEDER_DISTANCE)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you delete all of that? |
||
// a.whileTrue(new RunCommand(()-> intake.setAngleMotorAngle(Math.PI))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package frc.robot.commandgroups; | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; | ||
import edu.wpi.first.wpilibj2.command.RunCommand; | ||
import frc.robot.subsystems.intake.Intake; | ||
|
@@ -12,7 +13,7 @@ public FeedTeleop(boolean outtake) { | |
|
||
addCommands( | ||
new Retract(Retract.Mode.DOWN) | ||
.andThen(new RunCommand(() -> intake.setAngleMotorAngle(IntakeConstants.ANGLE_DOWN))), | ||
.andThen(new RunCommand(() -> intake.setAngleMotorAngle(Rotation2d.fromDegrees(IntakeConstants.ANGLE_DOWN)))), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating a |
||
intake.run(outtake ? -IntakeConstants.INTAKE_POWER : IntakeConstants.INTAKE_POWER) | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
public class CheckSwerve extends SequentialCommandGroup { | ||
public CheckSwerve() { | ||
SwerveDrive swerveDrive = SwerveDrive.getInstance(Robot.isReal()); | ||
SwerveDrive swerveDrive = SwerveDrive.getInstance(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be changed here. You can use interactive rebasing to remove this diff. |
||
addCommands( | ||
new RunCommand(swerveDrive::checkSwerve, swerveDrive).withTimeout(5), | ||
new ZeroPositionSwerve().withTimeout(2) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import com.ctre.phoenix.motorcontrol.ControlMode; | ||
import edu.wpi.first.math.geometry.Pose3d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Rotation3d; | ||
import edu.wpi.first.wpilibj.smartdashboard.Mechanism2d; | ||
import edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d; | ||
|
@@ -14,6 +15,7 @@ | |
import frc.robot.Robot; | ||
import frc.robot.subsystems.intake.commands.HoldIntakeInPlace; | ||
import org.littletonrobotics.junction.Logger; | ||
import utils.Utils; | ||
|
||
public class Intake extends SubsystemBase { | ||
private static Intake INSTANCE; | ||
|
@@ -70,26 +72,26 @@ public void setSpinMotorPower(double power) { | |
inputs.setpointSpinMotorPower = power; | ||
} | ||
|
||
public double getAngleMotorAngle() { | ||
public Rotation2d getAngleMotorAngle() { | ||
return inputs.angleMotorAngle; | ||
} | ||
|
||
/** | ||
* Sets the angles position. | ||
* | ||
* @param angle is the angle of the retractor. [degrees] | ||
* @param angleMotorAngle is the angle of the retractor. [degrees] | ||
*/ | ||
public void setAngleMotorAngle(double angle) { | ||
inputs.setpointAngleMotorAngle = Math.toRadians(angle); | ||
public void setAngleMotorAngle(Rotation2d angleMotorAngle) { | ||
inputs.setpointAngleMotorAngle = angleMotorAngle; | ||
angleMode = ControlMode.Position; | ||
} | ||
|
||
private double getAngleMotorVelocity() { | ||
private Rotation2d getAngleMotorVelocity() { | ||
return inputs.angleMotorVelocity; | ||
} | ||
|
||
public double getCurrent() { | ||
return inputs.angleMotorcurrent; | ||
return inputs.angleMotorAppliedCurrent; | ||
} | ||
|
||
public void setAnglePower(double power) { | ||
|
@@ -103,9 +105,12 @@ public void resetEncoder(double angle) { | |
|
||
public Command lowerIntake() { | ||
return new InstantCommand(() -> resetEncoder(IntakeConstants.ANGLE_UP), this) | ||
.andThen(new RunCommand(() -> setAngleMotorAngle(-40), this)); | ||
.andThen(new RunCommand(() -> setAngleMotorAngle(Rotation2d.fromDegrees(-40)), this)); | ||
} | ||
|
||
// You Jerk :) 😎 | ||
// I'm gonna kill them all. | ||
// All the juice must die | ||
Comment on lines
+111
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't you going to delete it? |
||
public Command run(double power) { | ||
return new RunCommand(() -> this.setSpinMotorPower(power)); | ||
} | ||
|
@@ -127,9 +132,11 @@ public void periodic() { | |
!(lastCommand instanceof HoldIntakeInPlace); | ||
lastCommand = currentCommand; | ||
|
||
intakeP1.setAngle(Math.toDegrees(getAngleMotorAngle()) + IntakeConstants.INTAKE_MECH_OFFSET); | ||
intakeP1.setAngle(getAngleMotorAngle().getDegrees() + IntakeConstants.INTAKE_MECH_OFFSET); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
Logger.recordOutput("IntakePose", getPose3d(getAngleMotorAngle() + IntakeConstants.INTAKE_SIM_ANGLE_OFFSET)); | ||
|
||
var intake3d = getPose3d(getAngleMotorAngle().getRadians() + Math.toRadians(IntakeConstants.INTAKE_SIM_ANGLE_OFFSET)); //TODO: ??!?!! check | ||
Logger.recordOutput("IntakePose", Utils.pose3dToArray(intake3d)); | ||
Logger.processInputs("Intake", inputs); | ||
SmartDashboard.putData("IntakeMech", mech); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import com.ctre.phoenix6.configs.Slot0Configs; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
import utils.units.Units; | ||
|
||
public class IntakeConstants { | ||
public static final double ANGLE_GEAR_RATIO = 35.26; | ||
public static final double SPIN_GEAR_RATIO = 10; //Not a real value | ||
public static final double kP = 2; | ||
public static final double kP = 0.1*ANGLE_GEAR_RATIO; | ||
public static final double kI = 0; | ||
public static final double kD = 0.2; | ||
public static final double kF = 0; | ||
public static final double kD = 0; | ||
public static final double kF = 0; // not relevant anymore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If that's not relevant, delete it. Why isn't it, though? |
||
public static final Slot0Configs PIDGains = new Slot0Configs().withKP(IntakeConstants.kP).withKI(IntakeConstants.kI).withKD(IntakeConstants.kD); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to create individual constants, just put the numbers on this line instead. |
||
|
||
public static final double FALCON_TICKS_PER_ROTATION = 2048; | ||
public static final double TICKS_PER_DEGREE = FALCON_TICKS_PER_ROTATION / 360 * ANGLE_GEAR_RATIO; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this here? It's not related to this branch.