Skip to content
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

Nahum #5

Open
wants to merge 212 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
63b0ccb
InitiatedCanSparkMotors
Nummun14 Nov 8, 2023
36c5c3c
added PIDControler
Nummun14 Nov 8, 2023
a833f5c
added TalonSRX
Nummun14 Nov 8, 2023
e74b59c
attempted to add cancoder
Nummun14 Nov 8, 2023
050897d
Made Can_Spark_Config
Nummun14 Nov 9, 2023
5826d79
removed ExtraNewLine
Nummun14 Nov 9, 2023
6546c54
fixed angle encoder config
Nummun14 Nov 9, 2023
d499b63
fixed enum
Nummun14 Nov 9, 2023
03a04c8
removed extra new lines
Nummun14 Nov 9, 2023
d3126b5
corrected type of canCOder
Nummun14 Nov 9, 2023
51ecd48
added follower motors
Nummun14 Nov 9, 2023
a5194f2
Made TalonSRX configuration
Nummun14 Nov 9, 2023
d0ab93e
made elevator encoder
Nummun14 Nov 9, 2023
77e39a0
removed redundent code
Nummun14 Nov 9, 2023
af0ec9c
corrected enum
Nummun14 Nov 9, 2023
d56fa7a
added canCoder config
Nummun14 Nov 9, 2023
9315c1d
corrected names
Nummun14 Nov 9, 2023
6d51eb6
corrected enum made code cleaner
Nummun14 Nov 9, 2023
8bffce3
added inverted to encoders
Nummun14 Nov 9, 2023
94c9ade
ctrl alt l
Nummun14 Nov 9, 2023
b132590
added offset to elevatorencoder
Nummun14 Nov 9, 2023
a86c2c3
fixed code acording to review
Nummun14 Nov 9, 2023
4d0c790
fixed coder acording to review
Nummun14 Nov 10, 2023
931356a
Updated acording to review
Nummun14 Nov 11, 2023
4e21034
fixed code acording to review
Nummun14 Nov 12, 2023
9d361c0
fixed code acording to review
Nummun14 Nov 12, 2023
e42415a
added motion profiles
Nummun14 Nov 12, 2023
6bd97e8
Update ArmConstants.java
Nummun14 Nov 13, 2023
9a83496
fixed Vcomp variable
Nummun14 Nov 13, 2023
8848dcd
removed extra import
Nummun14 Nov 13, 2023
b869fe6
fixed code acording to review
Nummun14 Nov 13, 2023
8f1ce72
removed extranewline
Nummun14 Nov 13, 2023
4930fce
removed extranewline
Nummun14 Nov 13, 2023
08ffebc
made arm a subsystem
Nummun14 Nov 13, 2023
4230bb5
made Angle motion profile
Nummun14 Nov 13, 2023
03d947d
added elevator motion profiles
Nummun14 Nov 13, 2023
62a2d12
added setTargetElevatorFromProfile
Nummun14 Nov 13, 2023
6886357
added getSetTargetCommand
Nummun14 Nov 13, 2023
1eb2d00
fixed coder acroding to review
Nummun14 Nov 13, 2023
17440b3
corrected angleVelocity method
Nummun14 Nov 13, 2023
40de5fb
changed elevator functions from Rotation2d to double
Nummun14 Nov 13, 2023
327af2a
fixed generateAngleMotorProfile
Nummun14 Nov 13, 2023
e55d720
fixed getAngleMotorVelocity
Nummun14 Nov 13, 2023
50918f4
fixed getVelocity functions
Nummun14 Nov 13, 2023
d14442b
fixed getElevatorMotorPositionRevolutions
Nummun14 Nov 14, 2023
39de4e7
changed generateElevatorMotorProfile param name
Nummun14 Nov 14, 2023
a011e7e
reformatted class
Nummun14 Nov 14, 2023
221bcc0
corrected generateElevatorMotorProfile
Nummun14 Nov 14, 2023
10e669c
corrected getSetElevatorTargetCommand
Nummun14 Nov 14, 2023
e033ede
corrected getSetTargetAngleCommand
Nummun14 Nov 14, 2023
2eeebdf
corrected getSetElevatorTargetCommand
Nummun14 Nov 14, 2023
6a75329
fixed name of getSetTargetElevatorPositionCommand
Nummun14 Nov 14, 2023
ab517b7
removed final from setTargetAngleFromProfile
Nummun14 Nov 14, 2023
48fb2b6
corrected name of param in generateElevatorMotorProfile
Nummun14 Nov 14, 2023
3cc49ad
changed name of setTargetElevatorPositionFromProfile
Nummun14 Nov 14, 2023
3592990
corrected getElevatorVelocityRevolutionsPerSecond
Nummun14 Nov 14, 2023
8aa85d2
changed name to getAngleMotorVelocityDegrees
Nummun14 Nov 14, 2023
bc258c3
fixed getElevatorVelocityRevolutionsPerSecond
Nummun14 Nov 14, 2023
61ea993
added feedforward to constants
Nummun14 Nov 14, 2023
6649fdc
added feedforward
Nummun14 Nov 14, 2023
f0dce60
added setMotorVoltage functions and removed whitespace
Nummun14 Nov 14, 2023
af21637
fixed calculateElevatorMotorOutput
Nummun14 Nov 14, 2023
9b307eb
removed redundent TrapezoidProfile.Constraints
Nummun14 Nov 14, 2023
7e37b95
added angle status signals to constants
Nummun14 Nov 14, 2023
c6b5259
corrected setMotorVoltage
Nummun14 Nov 14, 2023
6eb1d24
added getAngleEncoderPosition
Nummun14 Nov 14, 2023
0371855
added status signals
Nummun14 Nov 15, 2023
4fc05e8
corrected getAngleMotorVelocityDegreesPerSecond
Nummun14 Nov 15, 2023
ebf16c5
corrected calculateElevatorMotorOutput
Nummun14 Nov 15, 2023
68bbc14
Merge branch 'main' into arm-Nahum
Nummun14 Nov 15, 2023
bac71a7
cleaned up constants
Nummun14 Nov 15, 2023
026c66b
fixed calculateElevatorMotorOutput
Nummun14 Nov 15, 2023
4d80cbb
added setArmTarget
Nummun14 Nov 15, 2023
3bdded3
fixed setArmTarget
Nummun14 Nov 16, 2023
2f85546
corrected names, made unnecery methods private and remived else
Nummun14 Nov 16, 2023
f79e185
corrected names
Nummun14 Nov 16, 2023
c76ccba
corredted configureAngleEncoder
Nummun14 Nov 16, 2023
cc1efea
corrected getSetArmTarget
Nummun14 Nov 16, 2023
a38a846
corrected getSetArmTarget and updated names
Nummun14 Nov 16, 2023
15b2c85
corrected calculateElevatorMotorOutput
Nummun14 Nov 16, 2023
6b1d2a1
removed extra new line
Nummun14 Nov 16, 2023
1bac018
corrected names and logic
Nummun14 Nov 16, 2023
db6b373
corrected getSetArmTarget
Nummun14 Nov 16, 2023
e7e4c8c
removed andThen
Nummun14 Nov 16, 2023
9abeec7
reformatted and changed names
Nummun14 Nov 16, 2023
1c5db4e
recloned repository
Nummun14 Nov 16, 2023
bd23984
atempted to make DefferedCommand, but I'm defenetly wrong
Nummun14 Nov 17, 2023
efa9808
added DeferedCommands
Nummun14 Nov 17, 2023
6a4a3bb
added new line
Nummun14 Nov 18, 2023
36fcff8
reordered code
Nummun14 Nov 18, 2023
5f7ff70
corrected DefferedCommandLogic
Nummun14 Nov 18, 2023
bccb7da
renamed and reformatted
Nummun14 Nov 19, 2023
7cd766a
renamed and removed redundent code
Nummun14 Nov 19, 2023
890035b
added first command
Nummun14 Nov 19, 2023
5cd1987
fixed getCurrentSetTargetArmStateCommand
Nummun14 Nov 19, 2023
f0045be
reformatted
Nummun14 Nov 19, 2023
6d4be9d
atemted to add other commands
Nummun14 Nov 19, 2023
e105509
fixed names and reformated
Nummun14 Nov 19, 2023
6384a1c
fixed constraints logic
Nummun14 Nov 19, 2023
d9395e3
made speedPercentage simpler
Nummun14 Nov 19, 2023
987cbc9
reorgenized code
Nummun14 Nov 19, 2023
0e79dc2
updated names
Nummun14 Nov 19, 2023
5cbe2a3
added javadocs
Nummun14 Nov 19, 2023
cbd4daf
fixed javadocs
Nummun14 Nov 19, 2023
4fa9c89
fixed javadocs
Nummun14 Nov 19, 2023
07fa3d2
!!++==__ERROR--FIX--ERROR__==++!!
Nummun14 Nov 19, 2023
f907794
updated javadocs
Nummun14 Nov 19, 2023
fa3789f
removed extra new line
Nummun14 Nov 19, 2023
e029a41
added new line
Nummun14 Nov 19, 2023
5ac4606
fixed code
Nummun14 Nov 19, 2023
11c5d30
fixed====+-*$#*&%!
Nummun14 Nov 19, 2023
16e284b
added GETTTTTTTTTTTTTTTTTTTTTTTTTTT
Nummun14 Nov 19, 2023
7e732ad
תיקנתני (קיבלתי השראה מאזולאי
Nummun14 Nov 19, 2023
18b9313
תוקן *&%$#@!
Nummun14 Nov 19, 2023
592353a
Merge branch 'main' into arm-Nahum
Nummun14 Nov 21, 2023
1188b07
added Akit
Nummun14 Nov 21, 2023
cbd408c
added updateInputs
Nummun14 Nov 21, 2023
2d91362
made code cleaner
Nummun14 Nov 22, 2023
198462c
started arm Akit
Nummun14 Nov 22, 2023
62fbe0d
removed redundent config
Nummun14 Nov 22, 2023
7a4c316
removed getters
Nummun14 Nov 22, 2023
d47d24e
added pid and ff to IOconstants
Nummun14 Nov 22, 2023
8401451
moved PID and ff to kablamaArmConstants
Nummun14 Nov 23, 2023
97354e7
added setTargetAngle and setTargetElevatorPosition
Nummun14 Nov 23, 2023
e7ef4b6
cleaned up code
Nummun14 Nov 23, 2023
4561f53
corrected names
Nummun14 Nov 23, 2023
ac72e38
__==Cleaned up code==__
Nummun14 Nov 23, 2023
0c81176
extracted code into functions
Nummun14 Nov 24, 2023
583a8f5
reordered code
Nummun14 Nov 24, 2023
3ec284c
optimized imports
Nummun14 Nov 24, 2023
7b35232
attempted to add simulation
Nummun14 Nov 26, 2023
b51537d
attempted to add ElevatorSim and SingleJointedArmSim
Nummun14 Nov 26, 2023
607ecaf
made dcMotorSim
Nummun14 Nov 26, 2023
4e40e1d
implemented DCMotorSim
Nummun14 Nov 27, 2023
a2d9475
fixed code acording to review
Nummun14 Nov 27, 2023
fdbc558
updated names
Nummun14 Nov 27, 2023
cfd1b39
added arm simulation constants
Nummun14 Nov 27, 2023
c054fdd
made SimulationArmIOMotors
Nummun14 Nov 27, 2023
ae088e1
added set voltage functions
Nummun14 Nov 28, 2023
411f606
fixed most of review
Nummun14 Nov 28, 2023
106b4dc
added calulate functions
Nummun14 Nov 28, 2023
a8edef9
added inputs
Nummun14 Nov 28, 2023
5f4dd56
reformatted
Nummun14 Nov 29, 2023
def5f73
finished inputs
Nummun14 Nov 29, 2023
9a09dd0
corrected angle_radians
Nummun14 Nov 29, 2023
7f5d318
fixed inputs
Nummun14 Nov 29, 2023
fbba8f4
updated names and elevatorPosition logic
Nummun14 Nov 30, 2023
c469f96
removed extra new lines
Nummun14 Nov 30, 2023
30a569e
removed extra new line
Nummun14 Nov 30, 2023
5ae7575
corrected variable names
Nummun14 Nov 30, 2023
29efec5
corrected variable name
Nummun14 Nov 30, 2023
13daf8a
attempted to add Mechanism2d
Nummun14 Nov 30, 2023
62cea69
added mechanism2d and ran
Nummun14 Dec 2, 2023
57afd92
logged mechanism
Nummun14 Dec 2, 2023
4607436
moved commands to ArmCommands
Nummun14 Dec 2, 2023
f45789b
corrected requierments
Nummun14 Dec 2, 2023
8f63234
made commands static
Nummun14 Dec 2, 2023
65fda23
added mechanism2d to collector
Nummun14 Dec 2, 2023
c23f627
Delete networktables.json
levyishai Dec 3, 2023
2c7e36f
removed mechanism from collector
Nummun14 Dec 3, 2023
1e4596e
Merge branch 'arm-Nahum' of https://github.com/Programming-TRIGON/Rob…
Nummun14 Dec 3, 2023
eefc55c
removed extra files
Nummun14 Dec 3, 2023
1beae0a
corrected startAdvantageKitLogging
Nummun14 Dec 3, 2023
9d6b464
changed TalonSRX to WPI_TalonSRX
Nummun14 Dec 3, 2023
5964480
corrected addition of mech2d
Nummun14 Dec 3, 2023
b4302dd
corrected names
Nummun14 Dec 3, 2023
c12dde8
fixed naming and reorginized
Nummun14 Dec 4, 2023
e8d8f43
fixed commandgroup logic
Nummun14 Dec 4, 2023
543c987
added values
Nummun14 Dec 4, 2023
189d1d1
attempted to add target position mechanism
Nummun14 Dec 4, 2023
dacece0
fixed target position ligment
Nummun14 Dec 5, 2023
f8e9004
corrected elevatorEncoder config
Nummun14 Dec 5, 2023
717c828
fixed tolerance
Nummun14 Dec 5, 2023
a1c327d
minor fixes
Nummun14 Dec 5, 2023
4d7c698
תוקן
Nummun14 Dec 5, 2023
992b0e4
fixed names and reorgenized
Nummun14 Dec 5, 2023
65eaeea
Merge branch 'main' into arm-Nahum
levyishai Dec 5, 2023
eb6491b
restored robot container and fixed pid
Nummun14 Dec 5, 2023
a5424f1
Merge branch 'arm-Nahum' of https://github.com/Programming-TRIGON/Rob…
Nummun14 Dec 5, 2023
e9b3b83
changed names
Nummun14 Dec 5, 2023
894124c
finished tweeking sim
Nummun14 Dec 6, 2023
e80a87e
optimized names and imports
Nummun14 Dec 6, 2023
1073dca
fninished armSim
Nummun14 Dec 6, 2023
02f9742
made turret constants
Nummun14 Dec 6, 2023
4d4ef64
added translation2d
Nummun14 Dec 7, 2023
0fb2d99
attempted to make Turret
Nummun14 Dec 7, 2023
b44a710
attempted calulation
Nummun14 Dec 7, 2023
ec1ae5a
corrected output calulation
Nummun14 Dec 7, 2023
12076c1
fixed names
Nummun14 Dec 7, 2023
eec4a60
corrected units
Nummun14 Dec 8, 2023
0556a93
added most of turretAkit
Nummun14 Dec 10, 2023
1cacd17
finished adding akit
Nummun14 Dec 10, 2023
2f3d308
corrected turret code logic
Nummun14 Dec 11, 2023
6414044
added pid usage
Nummun14 Dec 13, 2023
71edd73
fixed zArmRoot
Nummun14 Dec 13, 2023
c657737
fixed angle logic
Nummun14 Dec 13, 2023
a029de6
corrected mechanism, and turret names
Nummun14 Dec 17, 2023
b3d2c41
added simulation
Nummun14 Dec 17, 2023
4a04d4c
removed redundent constants
Nummun14 Dec 18, 2023
3c63367
corrected logic of calculateTargetAngle
Nummun14 Dec 18, 2023
6c62c82
corrected mechaism
Nummun14 Dec 18, 2023
12c6e1a
corrected names and tested
Nummun14 Dec 18, 2023
96cac05
minor fixes
Nummun14 Dec 19, 2023
a66c1a3
minor fixes
Nummun14 Dec 20, 2023
ec46d1c
added motion magic
Nummun14 Dec 20, 2023
e8c1573
added mech2d
Nummun14 Dec 21, 2023
318a7ea
added mechanism
Nummun14 Dec 21, 2023
c2612fe
attempted to fix mechanism
Nummun14 Dec 21, 2023
2f06d9f
fixed status signals
Nummun14 Dec 21, 2023
156f017
fixed robotContainer
Nummun14 Dec 21, 2023
1401436
minor fixes
Nummun14 Dec 21, 2023
5950370
tuned PID, and added runCommand
Nummun14 Dec 24, 2023
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
4 changes: 4 additions & 0 deletions src/main/java/frc/trigon/robot/subsystems/arm/Arm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package frc.trigon.robot.subsystems.arm;

public class Arm {
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
}
95 changes: 95 additions & 0 deletions src/main/java/frc/trigon/robot/subsystems/arm/ArmConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package frc.trigon.robot.subsystems.arm;

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.PIDController;
import edu.wpi.first.math.geometry.Rotation2d;
import static frc.trigon.robot.utilities.Conversions.offsetRead;
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved

public class ArmConstants {
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
private static final int
MASTER_ANGLE_MOTOR_ID = 1,
MASTER_ELEVATOR_MOTOR_ID = 2,
FOLLOWER_ANGLE_MOTOR_ID = 3,
FOLLOWER_ELEVATOR_MOTOR_ID = 4,
ANGLE_ENCODER_ID = 5,
ELEVATOR_ENCODER_ID = 6;
private static final CANSparkMax.IdleMode
ELEVATOR_IDLE_MODE = CANSparkMax.IdleMode.kBrake,
ANGLE_IDLE_MODE = CANSparkMax.IdleMode.kBrake;
private static final int VOLTAGE_COMPANSATION_SATURATION = 12;
private static final boolean INVERTED_VALUE = false;
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
private static final SensorDirectionValue ANGLE_ENCODER_DIRECTION = SensorDirectionValue.CounterClockwise_Positive;
private static final boolean ELEVATOR_ENCODER_PHASE = false;
private static final int
ELEVATOR_ENCODER_OFFSET = 5,
ANGLE_ENCODER_OFFSET = 5;
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
private static final AbsoluteSensorRangeValue ANGLE_ENCODER_RANGE = AbsoluteSensorRangeValue.Signed_PlusMinusHalf;
private static final CANSparkMax
MASTER_ANGLE_MOTOR = new CANSparkMax(MASTER_ANGLE_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless),
MASTER_ELEVATOR_MOTOR = new CANSparkMax(MASTER_ELEVATOR_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless),
FOLLOWER_ANGLE_MOTOR = new CANSparkMax(FOLLOWER_ANGLE_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless),
FOLLOWER_ELEVATOR_MOTOR = new CANSparkMax(FOLLOWER_ELEVATOR_MOTOR_ID, CANSparkMaxLowLevel.MotorType.kBrushless);
private static final CANcoder ANGLE_ENCODER = new CANcoder(ANGLE_ENCODER_ID);
private static final TalonSRX ELEVATOR_ENCODER = new TalonSRX(ELEVATOR_ENCODER_ID);
static final double
P = 1,
I = 0,
D = 0;
static final PIDController PID_CONTROLLER = new PIDController(P, I, D);
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved

static {
configureAngleEncoder();
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
configureElevatorEncoder();
configureAngleMotor(MASTER_ANGLE_MOTOR);
configureAngleMotor(FOLLOWER_ANGLE_MOTOR);
configureElevatorMotor(MASTER_ELEVATOR_MOTOR);
configureElevatorMotor(FOLLOWER_ELEVATOR_MOTOR);
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
}

public enum ArmState {
ANGLE(new Rotation2d(5), 7),
ELEVATOR_POSITION(new Rotation2d(7), 5);
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved

final Rotation2d angle;
final double elevatorPosition;

ArmState(Rotation2d angle, double elevatorPosition) {
this.angle = angle;
this.elevatorPosition = elevatorPosition;
}
}

private static void configureElevatorMotor(CANSparkMax motor) {
motor.restoreFactoryDefaults();
motor.setIdleMode(ELEVATOR_IDLE_MODE);
motor.setInverted(INVERTED_VALUE);
motor.enableVoltageCompensation(VOLTAGE_COMPANSATION_SATURATION);
}

private static void configureAngleMotor(CANSparkMax motor) {
motor.restoreFactoryDefaults();
motor.setIdleMode(ANGLE_IDLE_MODE);
motor.setInverted(INVERTED_VALUE);
motor.enableVoltageCompensation(VOLTAGE_COMPANSATION_SATURATION);
}

private static void configureAngleEncoder() {
CANcoderConfiguration angleEncoderConfig = new CANcoderConfiguration();
angleEncoderConfig.MagnetSensor.MagnetOffset = ANGLE_ENCODER_OFFSET;
angleEncoderConfig.MagnetSensor.AbsoluteSensorRange = ANGLE_ENCODER_RANGE;
angleEncoderConfig.MagnetSensor.SensorDirection = ANGLE_ENCODER_DIRECTION;
ANGLE_ENCODER.getConfigurator().apply(angleEncoderConfig);
}
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved

private static void configureElevatorEncoder() {
ELEVATOR_ENCODER.configFactoryDefault();
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
ELEVATOR_ENCODER.setSensorPhase(ELEVATOR_ENCODER_PHASE);
Nummun14 marked this conversation as resolved.
Show resolved Hide resolved
ELEVATOR_ENCODER.setSelectedSensorPosition(offsetRead(ELEVATOR_ENCODER.getSelectedSensorPosition(), ELEVATOR_ENCODER_OFFSET));
}
}