-
Notifications
You must be signed in to change notification settings - Fork 0
Miniberty #6
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
Open
libertyhar
wants to merge
22
commits into
main
Choose a base branch
from
side_shooter_miniberty
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Miniberty #6
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
de7cf24
did side shooter constanst
libertyhar dab5da7
added pid
libertyhar 7f47613
updated
libertyhar d7effcb
Update SideShooterConstants.java
libertyhar bb32e20
Update SideShooterConstants.java
libertyhar e4f2cd5
Update SideShooterConstants.java
libertyhar 6389cc6
Update SideShooterConstants.java
libertyhar 67b334a
finshed comand
libertyhar d53ff26
Update SideShooterConstants.java
libertyhar f3a9225
fixed logika name
libertyhar 43b1bba
fixed units
libertyhar a08c275
Update SideShooter.java
libertyhar 14edb27
added command
libertyhar fecff42
added command
libertyhar 711a5b8
fixed command
libertyhar 20dc464
added command class
libertyhar c328d69
Merge branch 'main' into side_shooter_miniberty
libertyhar 04deeb6
fixed riviu
libertyhar b30d25c
fixxed
libertyhar 3befdaf
added constanst and started the subsystem by adding angle profile
libertyhar 5634e7b
added ArmCommands
libertyhar 3ee8694
added somting
libertyhar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
src/main/java/frc/trigon/robot/subsystems/sideshooter/SideShooterConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| package frc.trigon.robot.subsystems.sideshooter; | ||
|
|
||
| import com.ctre.phoenix6.configs.CANcoderConfiguration; | ||
| import com.ctre.phoenix6.configs.TalonFXConfiguration; | ||
| import com.ctre.phoenix6.hardware.CANcoder; | ||
| import com.ctre.phoenix6.hardware.TalonFX; | ||
| import com.ctre.phoenix6.signals.AbsoluteSensorRangeValue; | ||
| import com.ctre.phoenix6.signals.InvertedValue; | ||
| import com.ctre.phoenix6.signals.NeutralModeValue; | ||
| import com.ctre.phoenix6.signals.SensorDirectionValue; | ||
| import com.revrobotics.CANSparkMax; | ||
| import com.revrobotics.CANSparkMaxLowLevel; | ||
| import edu.wpi.first.math.controller.PIDController; | ||
| import edu.wpi.first.math.geometry.Rotation2d; | ||
| import edu.wpi.first.math.trajectory.TrapezoidProfile; | ||
|
|
||
|
|
||
| public class SideShooterConstants { | ||
libertyhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
libertyhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private static final double VOLTAGE_COMPENSATION = 12; | ||
libertyhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private static final int | ||
| SHOOTING_MOTOR_ID = 0, | ||
| ANGLE_MOTOR_ID = 1, | ||
| ANGLE_ENCODER_ID = 2; | ||
|
|
||
|
|
||
libertyhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private static final double ANGLE_ENCODER_OFFSET = 0; | ||
| private static final AbsoluteSensorRangeValue ANGLE_ENCODER_RANGE = AbsoluteSensorRangeValue.Signed_PlusMinusHalf; | ||
| private static final InvertedValue SHOOTING_MOTOR_INVERTED_VALUE = InvertedValue.CounterClockwise_Positive; | ||
| private static final boolean ANGLE_MOTOR_INVERTED = false; | ||
|
|
||
libertyhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private static final SensorDirectionValue ANGLE_ENCODER_DIRECTION = SensorDirectionValue.Clockwise_Positive; | ||
| private static final NeutralModeValue SHOOTING_NEUTRAL_MODE_VALUE = NeutralModeValue.Coast; | ||
| private static final CANSparkMax.IdleMode ANGLE_MOTOR_IDLE_MODE = CANSparkMax.IdleMode.kBrake; | ||
|
|
||
libertyhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static final CANSparkMax ANGLE_MOTOR = new CANSparkMax(ANGLE_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless); | ||
| static final CANcoder ANGLE_ENCODER = new CANcoder(ANGLE_ENCODER_ID); | ||
| static final TalonFX SHOOTING_MOTOR = new TalonFX(SHOOTING_MOTOR_ID); | ||
|
|
||
| private static final double | ||
| MAX_ANGLE_VELOCITY = 600, | ||
| MAX_ANGLE_ACCELERATION = 500; | ||
|
|
||
| static final TrapezoidProfile.Constraints ANGLE_CONSTRAINTS = new TrapezoidProfile.Constraints(MAX_ANGLE_VELOCITY, MAX_ANGLE_ACCELERATION); | ||
libertyhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private static final double | ||
| ANGLE_MOTOR_P = 1, | ||
| ANGLE_MOTOR_I = 0, | ||
| ANGLE_MOTOR_D = 0; | ||
| static final PIDController ANGLE_PID_CONTROLLER = new PIDController(ANGLE_MOTOR_P, ANGLE_MOTOR_I, ANGLE_MOTOR_D); | ||
|
|
||
| static { | ||
| configureAngleEncoder(); | ||
| configureShootingMotor(); | ||
| configureAngleMotor(); | ||
| } | ||
|
|
||
| private static void configureShootingMotor() { | ||
| TalonFXConfiguration config = new TalonFXConfiguration(); | ||
| config.Audio.BeepOnBoot = false; | ||
| config.Audio.BeepOnConfig = false; | ||
| config.MotorOutput.Inverted = SHOOTING_MOTOR_INVERTED_VALUE; | ||
| config.MotorOutput.NeutralMode = SHOOTING_NEUTRAL_MODE_VALUE; | ||
| SHOOTING_MOTOR.getConfigurator().apply(config); | ||
| } | ||
|
|
||
| private static void configureAngleMotor() { | ||
| ANGLE_MOTOR.restoreFactoryDefaults(); | ||
| ANGLE_MOTOR.setIdleMode(ANGLE_MOTOR_IDLE_MODE); | ||
| ANGLE_MOTOR.setInverted(ANGLE_MOTOR_INVERTED); | ||
| ANGLE_MOTOR.enableVoltageCompensation(VOLTAGE_COMPENSATION); | ||
| } | ||
|
|
||
| private static void configureAngleEncoder() { | ||
| CANcoderConfiguration config = new CANcoderConfiguration(); | ||
| config.MagnetSensor.AbsoluteSensorRange = ANGLE_ENCODER_RANGE; | ||
| config.MagnetSensor.MagnetOffset = ANGLE_ENCODER_OFFSET; | ||
| config.MagnetSensor.SensorDirection = ANGLE_ENCODER_DIRECTION; | ||
| ANGLE_ENCODER.getConfigurator().apply(config); | ||
| } | ||
|
|
||
| public enum SideShooter { | ||
libertyhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| COLLECTION(new Rotation2d(-15), -5), | ||
| MIDDLE(new Rotation2d(30), 5), | ||
| HIGH(new Rotation2d(60), 10); | ||
libertyhar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| final Rotation2d angle; | ||
| final double power; | ||
|
|
||
| SideShooter(Rotation2d angle, double power) { | ||
| this.angle = angle; | ||
| this.power = power; | ||
| } | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.