-
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
Added Implementation of SparkMaxUtils.initWithRetry() #33
Conversation
- added errors += SparkMaxUtils.check() stuff to the initSparks() method in Arm, Grabber, SwerveModule - added SparkMaxUtils.initWithRetry() line to each constructor in Arm, Grabber, SwerveModule
fe3103b
to
f53c30b
Compare
@@ -57,7 +60,7 @@ public enum ArmPosition { | |||
ArmCal.ARM_MAX_ACCELERATION_DEG_PER_SECOND_SQUARED)); | |||
|
|||
public Arm(ScoringLocationUtil scoreLoc) { | |||
|
|||
SparkMaxUtils.initWithRetry(this::initSparks, Calibrations.SPARK_INIT_RETRY_ATTEMPTS); |
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.
Call in initialize
@@ -45,6 +46,8 @@ public SwerveModule(int drivingCanId, int turningCanId, double chassisAngularOff | |||
turningSparkMax = new CANSparkMax(turningCanId, MotorType.kBrushless); | |||
chassisAngularOffsetRadians = chassisAngularOffset; | |||
|
|||
SparkMaxUtils.initWithRetry(this::initDriveSpark, Calibrations.SPARK_INIT_RETRY_ATTEMPTS); |
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.
Make an initialize function and call in there. Also call for the turnspark
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.
Also add a swerve system initialize function that call the initialize for all our modules
@@ -57,7 +60,7 @@ public enum ArmPosition { | |||
ArmCal.ARM_MAX_ACCELERATION_DEG_PER_SECOND_SQUARED)); | |||
|
|||
public Arm(ScoringLocationUtil scoreLoc) { | |||
|
|||
SparkMaxUtils.initWithRetry(this::initSparks, Calibrations.SPARK_INIT_RETRY_ATTEMPTS); |
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.
Can you set SPARK_INIT_RETRY_ATTEMPTS
to like 5 or something
@@ -57,7 +60,7 @@ public enum ArmPosition { | |||
ArmCal.ARM_MAX_ACCELERATION_DEG_PER_SECOND_SQUARED)); | |||
|
|||
public Arm(ScoringLocationUtil scoreLoc) { | |||
|
|||
this.initialize(); |
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.
These should not be called yet until a later point, called in robot container
|
||
// inverting stuff | ||
armAbsoluteEncoder.setInverted(true); | ||
errors += SparkMaxUtils.check(armEncoder.setInverted(true)); | ||
armMotor.setInverted(false); | ||
|
||
// Get positions and degrees of elevator through encoder in inches | ||
setDegreesFromGearRatioRelativeEncoder(armEncoder, ArmConstants.ARM_MOTOR_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.
Do these return errors internally? Should be checked too
@@ -87,13 +87,21 @@ public class DriveSubsystem extends SubsystemBase { | |||
|
|||
/** Creates a new DriveSubsystem. */ | |||
public DriveSubsystem(Lights lightsSubsystem, BooleanSupplier isTimedMatchFunc) { | |||
this.initialize(); |
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.
As before call in robot container
@@ -45,6 +46,8 @@ public SwerveModule(int drivingCanId, int turningCanId, double chassisAngularOff | |||
turningSparkMax = new CANSparkMax(turningCanId, MotorType.kBrushless); | |||
chassisAngularOffsetRadians = chassisAngularOffset; | |||
|
|||
this.initialize(); |
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.
This gets called by swerve subsystem
/** Does all the initialization for the spark */ | ||
void initTurnSpark() { | ||
boolean initTurnSpark() { | ||
int errors = 0; | ||
|
||
turningSparkMax.restoreFactoryDefaults(); |
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.
check?
@@ -29,6 +31,11 @@ public class Grabber extends SubsystemBase { | |||
|
|||
public Grabber(Command rumbleBrieflyCmd) { | |||
this.rumbleBriefly = rumbleBrieflyCmd; | |||
this.initialize(); |
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.
Call in robot containe
int errors = 0; | ||
errors += SparkMaxUtils.check(frontMotor.restoreFactoryDefaults()); | ||
errors += SparkMaxUtils.check(backMotor.restoreFactoryDefaults()); | ||
// backMotor.follow(frontMotor); |
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.
Is this needed, why is it commented out
} | ||
|
||
public static void setDegreesFromGearRatioRelativeEncoder( | ||
RelativeEncoder sparkMaxEncoder, double ratio) { | ||
public static int setDegreesFromGearRatioRelativeEncoder( |
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.
Add comment what the return values are that you changed?
/format |
No description provided.