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

Set motion magic hard coded values to values in preferences #249

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/RobotPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public static final class prefPitch {
public static final SN_DoublePreference pitchP = new SN_DoublePreference("pitchP", 300); // 100
public static final SN_DoublePreference pitchI = new SN_DoublePreference("pitchI", 0);
public static final SN_DoublePreference pitchD = new SN_DoublePreference("pitchD", 0);
public static final SN_DoublePreference MotionMagicCruiseVelocity = new SN_DoublePreference(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// - Motion Magic -
/**
* Units: Rotations per second (rps)
*/
public static final SN_DoublePreference climberCruiseVelocity = new SN_DoublePreference(
"climberCruiseVelocity", 80);

/**
 * <b> Units: </b> Rotations per second per second (rps/s)
 */
public static final SN_DoublePreference climberAcceleration = new SN_DoublePreference(
    "climberAcceleration", 160);
/**
 * <b> Units: </b> Rotations per second per second per second (rps/s/s)
 */
public static final SN_DoublePreference climberJerk = new SN_DoublePreference("climberJerk", 1600);

"MotionMagicCruiseVelocity", 80);
public static final SN_DoublePreference MotionMagicAcceleration = new SN_DoublePreference("MotionMagicAcceleration",
160);
public static final SN_DoublePreference MotionMagicJerk = new SN_DoublePreference("MotionMagicJerk", 1600);

/**
* Takes a percentage of the controller joystick input to set as the manual
Expand Down Expand Up @@ -454,6 +459,12 @@ public static final class prefTurret {
public static final SN_DoublePreference turretCurrentTimeThreshold = new SN_DoublePreference(
"turretCurrentTimeThreshold", 0.1);

public static final SN_DoublePreference MotionMagicCruiseVelocity = new SN_DoublePreference(
"MotionMagicCruiseVelocity", 80);
public static final SN_DoublePreference MotionMagicAcceleration = new SN_DoublePreference("MotionMagicAcceleration",
160);
public static final SN_DoublePreference MotionMagicJerk = new SN_DoublePreference("MotionMagicJerk", 1600);

/**
* <b>Units:</b> Degrees
*/
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/frc/robot/subsystems/Pitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ public void configure() {
pitchConfig.Slot0.kI = prefPitch.pitchI.getValue();
pitchConfig.Slot0.kD = prefPitch.pitchD.getValue();

pitchConfig.MotionMagic.MotionMagicCruiseVelocity = 80; // Target cruise velocity of 80 rps
pitchConfig.MotionMagic.MotionMagicAcceleration = 160; // Target acceleration of 160 rps/s (0.5 seconds)
pitchConfig.MotionMagic.MotionMagicJerk = 1600; // Target jerk of 1600 rps/s/s (0.1 seconds)
pitchConfig.MotionMagic.MotionMagicCruiseVelocity = prefPitch.MotionMagicCruiseVelocity.getValue();
// Target cruise velocity of 80 rps
pitchConfig.MotionMagic.MotionMagicAcceleration = prefPitch.MotionMagicAcceleration.getValue();
// Target acceleration of 160 rps/s (0.5 seconds)
pitchConfig.MotionMagic.MotionMagicJerk = prefPitch.MotionMagicJerk.getValue();
// Target jerk of 1600 rps/s/s (0.1 seconds)

pitchConfig.SoftwareLimitSwitch.ForwardSoftLimitEnable = true;
pitchConfig.SoftwareLimitSwitch.ForwardSoftLimitThreshold = prefPitch.pitchForwardLimit.getValue();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/frc/robot/subsystems/Turret.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public void configure() {
turretConfig.Slot0.kI = prefTurret.turretI.getValue();
turretConfig.Slot0.kD = prefTurret.turretD.getValue();

turretConfig.MotionMagic.MotionMagicCruiseVelocity = 160; // rps
turretConfig.MotionMagic.MotionMagicAcceleration = 160; // rps/s
turretConfig.MotionMagic.MotionMagicJerk = 1600; // rps/s/s
turretConfig.MotionMagic.MotionMagicCruiseVelocity = prefTurret.MotionMagicCruiseVelocity.getValue(); // rps
turretConfig.MotionMagic.MotionMagicAcceleration = prefTurret.MotionMagicAcceleration.getValue(); // rps/s
turretConfig.MotionMagic.MotionMagicJerk = prefTurret.MotionMagicJerk.getValue(); // rps/s/s

turretConfig.SoftwareLimitSwitch.ForwardSoftLimitEnable = true;
turretConfig.SoftwareLimitSwitch.ForwardSoftLimitThreshold = prefTurret.turretForwardLimit.getValue();
Expand Down