-
Notifications
You must be signed in to change notification settings - Fork 0
Ofir #8
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
ofirKAMInetsky
wants to merge
49
commits into
main
Choose a base branch
from
arm
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
Ofir #8
Changes from 14 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
5ad3e66
Constants
ofirKAMInetsky 8e2b938
Update ArmConstants.java
ofirKAMInetsky 99e624e
Update ArmConstants.java
ofirKAMInetsky 8769ff4
updated ArmConstants
ofirKAMInetsky 7a39af8
updated ArmConstants
ofirKAMInetsky 8128bdf
updated ArmConstants.java
ofirKAMInetsky 2328764
Update ArmConstants.java
ofirKAMInetsky 28a7ab0
FIX
ofirKAMInetsky 82882a0
FIX
ofirKAMInetsky 99805bb
changed the names
ofirKAMInetsky 773f4f3
___FIXED___
ofirKAMInetsky 113172a
Update ArmConstants.java
ofirKAMInetsky cb29753
Update ArmConstants.java
ofirKAMInetsky b5f06cb
Update ArmConstants.java
ofirKAMInetsky b10639e
Create ArmSubsystem.java
ofirKAMInetsky 75998fa
Update ArmConstants.java
ofirKAMInetsky 50fbce0
____added___motors___
ofirKAMInetsky b75612e
made it static
ofirKAMInetsky 32bb477
Update ArmSubsystem.java
ofirKAMInetsky ca981c8
==!!!___updated___!!!==
ofirKAMInetsky 2385256
i dont know what it is
ofirKAMInetsky 1dcd1e4
added angle methods
ofirKAMInetsky 1372f92
I added the profile of the elevator
ofirKAMInetsky 656b3d8
corrected the last profile generate
ofirKAMInetsky 2227ae3
added and fixed things
ofirKAMInetsky f8d3f49
Update Arm.java
ofirKAMInetsky aa18345
Fixed .run folder
ofirKAMInetsky 41faad4
Fixed the .gitignore file
ofirKAMInetsky 097d24d
Revert "Fixed .run folder"
ofirKAMInetsky fc7840a
Fixed the .run folder
ofirKAMInetsky bb4e12b
Update Arm.java
ofirKAMInetsky 6586e6d
Update ArmConstants.java
ofirKAMInetsky 847ed6d
fixed something
ofirKAMInetsky b19c37d
fix
ofirKAMInetsky 14a9e97
!@#$%^&*()_FIX_)(*&^%$#@!
ofirKAMInetsky 2aa4458
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--FIX--!!!!!!!!!!!!!!!!!!…
ofirKAMInetsky a35019b
FFFFFFFFFFFFFIXXXXXXXXXXXXXXX
ofirKAMInetsky 2f10641
Update Arm.java
ofirKAMInetsky ddae22a
Update Arm.java
ofirKAMInetsky a8023f9
Merge branch 'main' into arm
ofirKAMInetsky 77bd329
-=+=-__FIX__added the Deferred Command__FIX__-=+=-
ofirKAMInetsky 6e55d4c
updated and fixed
ofirKAMInetsky 7a8efe6
Update Arm.java
ofirKAMInetsky fc4b2b5
Update Arm.java
ofirKAMInetsky 71b1adb
Update Arm.java
ofirKAMInetsky a5dc6d7
Update Arm.java
ofirKAMInetsky aecf2a1
Update Arm.java
ofirKAMInetsky af693b1
Update Arm.java
ofirKAMInetsky 6f5dbc0
Moved all the commands ArmCommands class.
ofirKAMInetsky 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
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
150 changes: 150 additions & 0 deletions
150
src/main/java/frc/trigon/robot/subsystems/arm/ArmConstants.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,150 @@ | ||
| package frc.trigon.robot.subsystems.arm; | ||
|
|
||
| import com.ctre.phoenix.motorcontrol.FeedbackDevice; | ||
| import com.ctre.phoenix.motorcontrol.can.TalonSRX; | ||
| import com.ctre.phoenix6.configs.CANcoderConfiguration; | ||
| import com.ctre.phoenix6.hardware.CANcoder; | ||
| import com.ctre.phoenix6.signals.AbsoluteSensorRangeValue; | ||
| import com.ctre.phoenix6.signals.SensorDirectionValue; | ||
| import com.revrobotics.CANSparkMax; | ||
| import com.revrobotics.CANSparkMaxLowLevel; | ||
| import edu.wpi.first.math.controller.ArmFeedforward; | ||
| import edu.wpi.first.math.controller.ElevatorFeedforward; | ||
| import edu.wpi.first.math.controller.PIDController; | ||
| import edu.wpi.first.math.geometry.Rotation2d; | ||
| import edu.wpi.first.math.trajectory.TrapezoidProfile; | ||
|
|
||
| public class ArmConstants { | ||
ofirKAMInetsky marked this conversation as resolved.
Show resolved
Hide resolved
ofirKAMInetsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private static final double VOLTAGE_COMPENSATION_SATURATION = 12; | ||
|
|
||
| private static final int | ||
| MASTER_ANGLE_MOTOR_ID = 0, | ||
| FOLLOWER_ANGLE_MOTOR_ID = 1, | ||
| MASTER_ELEVATOR_MOTOR_ID = 2, | ||
| FOLLOWER_ELEVATOR_MOTOR_ID = 3, | ||
| ELEVATOR_ENCODER_ID = 4, | ||
| ANGLE_ENCODER_ID = 5; | ||
|
|
||
| private static final double | ||
| ELEVATOR_ENCODER_OFFSET = 0.0, | ||
| ANGLE_ENCODER_OFFSET = 0.0; | ||
|
|
||
| private static final boolean | ||
| MASTER_ANGLE_INVERTED = false, | ||
| FOLLOWER_ANGLE_INVERTED = false, | ||
| MASTER_ELEVATOR_INVERTED = false, | ||
| FOLLOWER_ELEVATOR_INVERTED = true, | ||
| ELEVATOR_ENCODER_PHASE = true; | ||
| private static final SensorDirectionValue ANGLE_ENCODER_SENSOR_DIRECTION = SensorDirectionValue.Clockwise_Positive; | ||
|
|
||
| private static final CANSparkMax.IdleMode | ||
| ANGLE_IDLE_MODE = CANSparkMax.IdleMode.kBrake, | ||
| ELEVATOR_IDLE_MODE = CANSparkMax.IdleMode.kBrake; | ||
| private static final AbsoluteSensorRangeValue ANGLE_ENCODER_SENSOR_RANGE = AbsoluteSensorRangeValue.Signed_PlusMinusHalf; | ||
|
|
||
| static final CANSparkMax | ||
| MASTER_ANGLE_MOTOR = new CANSparkMax(MASTER_ANGLE_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless), | ||
| FOLLOWER_ANGLE_MOTOR = new CANSparkMax(FOLLOWER_ANGLE_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless), | ||
| MASTER_ELEVATOR_MOTOR = new CANSparkMax(MASTER_ELEVATOR_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless), | ||
| FOLLOWER_ELEVATOR_MOTOR = new CANSparkMax(FOLLOWER_ELEVATOR_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless); | ||
| static final TalonSRX ELEVATOR_ENCODER = new TalonSRX(ELEVATOR_ENCODER_ID); | ||
| static final CANcoder ANGLE_ENCODER = new CANcoder(ANGLE_ENCODER_ID); | ||
|
|
||
| private static final double | ||
| ELEVATOR_P = 1.32, | ||
| ELEVATOR_I = 3.1, | ||
| ELEVATOR_D = 0, | ||
| ANGLE_P = 1.32, | ||
| ANGLE_I = 3.1, | ||
| ANGLE_D = 0; | ||
| private static final PIDController | ||
| ELEVATOR_PID_CONTROLLER = new PIDController(ELEVATOR_P, ELEVATOR_I, ELEVATOR_D), | ||
| ANGLE_PID_CONTROLLER = new PIDController(ANGLE_P, ANGLE_I, ANGLE_D); | ||
|
|
||
| private static final double | ||
| ANGLE_MOTOR_KS = 0, | ||
| ANGLE_MOTOR_KV = 0, | ||
| ANGLE_MOTOR_KA = 0, | ||
| ANGLE_MOTOR_KG = 0, | ||
| ELEVATOR_MOTOR_KS = 0, | ||
| ELEVATOR_MOTOR_KV = 0, | ||
| ELEVATOR_MOTOR_KA = 0, | ||
| ELEVATOR_MOTOR_KG = 0; | ||
| static final ArmFeedforward ANGLE_MOTOR_FEEDFORWARD = new ArmFeedforward(ANGLE_MOTOR_KS, ANGLE_MOTOR_KG, ANGLE_MOTOR_KV, ANGLE_MOTOR_KA); | ||
| static final ElevatorFeedforward ELEVATOR_MOTOR_FEEDFORWARD = new ElevatorFeedforward(ELEVATOR_MOTOR_KS, ELEVATOR_MOTOR_KG, ELEVATOR_MOTOR_KV, ELEVATOR_MOTOR_KA); | ||
|
|
||
| private static final double | ||
| MAX_ANGLE_VELOCITY = 100, | ||
| MAX_ANGLE_ACCELERATION = 100, | ||
| MAX_ELEVATOR_VELOCITY = 100, | ||
| MAX_ELEVATOR_ACCELERATION = 100; | ||
| static final TrapezoidProfile.Constraints | ||
| ANGLE_CONSTRAINS = new TrapezoidProfile.Constraints(MAX_ANGLE_VELOCITY, MAX_ANGLE_ACCELERATION), | ||
| ELEVATOR_CONSTRAINS = new TrapezoidProfile.Constraints(MAX_ELEVATOR_VELOCITY, MAX_ELEVATOR_ACCELERATION); | ||
|
|
||
| static { | ||
| configureAngleMotors(); | ||
| configureElevatorMotors(); | ||
| configureElevatorEncoder(); | ||
| configureAngleEncoder(); | ||
| } | ||
|
|
||
| private static void configureElevatorMotors() { | ||
| MASTER_ELEVATOR_MOTOR.restoreFactoryDefaults(); | ||
| FOLLOWER_ELEVATOR_MOTOR.restoreFactoryDefaults(); | ||
|
|
||
| MASTER_ELEVATOR_MOTOR.enableVoltageCompensation(VOLTAGE_COMPENSATION_SATURATION); | ||
| FOLLOWER_ELEVATOR_MOTOR.enableVoltageCompensation(VOLTAGE_COMPENSATION_SATURATION); | ||
|
|
||
| MASTER_ELEVATOR_MOTOR.setInverted(MASTER_ELEVATOR_INVERTED); | ||
| FOLLOWER_ELEVATOR_MOTOR.setInverted(FOLLOWER_ELEVATOR_INVERTED); | ||
|
|
||
| MASTER_ELEVATOR_MOTOR.setIdleMode(ELEVATOR_IDLE_MODE); | ||
| FOLLOWER_ELEVATOR_MOTOR.setIdleMode(ELEVATOR_IDLE_MODE); | ||
| } | ||
|
|
||
| private static void configureElevatorEncoder() { | ||
| ELEVATOR_ENCODER.configFactoryDefault(); | ||
| ELEVATOR_ENCODER.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Absolute, 0, 10); | ||
| ELEVATOR_ENCODER.setSelectedSensorPosition(ELEVATOR_ENCODER.getSelectedSensorPosition() - ELEVATOR_ENCODER_OFFSET); | ||
ofirKAMInetsky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ELEVATOR_ENCODER.setSensorPhase(ELEVATOR_ENCODER_PHASE); | ||
| } | ||
|
|
||
| private static void configureAngleMotors() { | ||
| MASTER_ANGLE_MOTOR.restoreFactoryDefaults(); | ||
| FOLLOWER_ANGLE_MOTOR.restoreFactoryDefaults(); | ||
|
|
||
| MASTER_ANGLE_MOTOR.enableVoltageCompensation(VOLTAGE_COMPENSATION_SATURATION); | ||
| FOLLOWER_ANGLE_MOTOR.enableVoltageCompensation(VOLTAGE_COMPENSATION_SATURATION); | ||
|
|
||
| MASTER_ANGLE_MOTOR.setInverted(MASTER_ANGLE_INVERTED); | ||
| FOLLOWER_ANGLE_MOTOR.setInverted(FOLLOWER_ANGLE_INVERTED); | ||
|
|
||
| MASTER_ANGLE_MOTOR.setIdleMode(ANGLE_IDLE_MODE); | ||
| FOLLOWER_ANGLE_MOTOR.setIdleMode(ANGLE_IDLE_MODE); | ||
| } | ||
|
|
||
| private static void configureAngleEncoder() { | ||
| CANcoderConfiguration configureAngleEncoder = new CANcoderConfiguration(); | ||
| configureAngleEncoder.MagnetSensor.MagnetOffset = ANGLE_ENCODER_OFFSET; | ||
| configureAngleEncoder.MagnetSensor.AbsoluteSensorRange = ANGLE_ENCODER_SENSOR_RANGE; | ||
| configureAngleEncoder.MagnetSensor.SensorDirection = ANGLE_ENCODER_SENSOR_DIRECTION; | ||
| ANGLE_ENCODER.getConfigurator().apply(configureAngleEncoder); | ||
| } | ||
|
|
||
| public enum ArmStates { | ||
ofirKAMInetsky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| FIRST_STATE(Rotation2d.fromDegrees(30), 1), | ||
| SECOND_STATE(Rotation2d.fromDegrees(50), 2), | ||
| THIRD_STATE(Rotation2d.fromDegrees(100), 3); | ||
|
|
||
| final Rotation2d angle; | ||
| final double elevatorPosition; | ||
|
|
||
| ArmStates(Rotation2d angle, double elevatorPosition) { | ||
| this.elevatorPosition = elevatorPosition; | ||
| this.angle = angle; | ||
| } | ||
|
|
||
ofirKAMInetsky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
ofirKAMInetsky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
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.