-
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 all 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 |
---|---|---|
|
@@ -3,11 +3,11 @@ | |
import edu.wpi.first.wpilibj2.command.RunCommand; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import frc.robot.Robot; | ||
import swerve.SwerveDrive; | ||
import frc.robot.swerve.SwerveDrive; | ||
|
||
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 lib.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; | ||
import lib.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.
Instead of creating a
Rotation2d
here,ANGLE_DOWN
should already be aRotation2d
.