SparkMax Soft Limits question

We are trying to add Soft Limits to an arm. We are following Rev’s SparkMax examples. The example uses SmartDashboard to set some parameters. This is our first week programming in Java and have little experience with SmartDashboard at this time. So, we want to program the Soft Limits without the SmartDashboard.
What does the programming look like to add the the Soft Limits into the SubSystem without using SmartDashBoard?

Below is what it looks like Rev’s Example and reads the SoftLimitDirection from the dashboard (I think)…

motorShooterRotate.enableSoftLimit(CANSparkMax.SoftLimitDirection.kForward,true);
motorShooterRotate.enableSoftLimit(CANSparkMax.SoftLimitDirection.kReverse,true);

motorShooterRotate.setSoftLimit(CANSparkMax.SoftLimitDirection.kForward, 15);
motorShooterRotate.setSoftLimit(CANSparkMax.SoftLimitDirection.kReverse, 0);

The code that you posted does not read anything from the smartdashboard. It sets the reverse limit to the constant of 0 and sets the forward limit to a constant of 15.

I guessed it was coming from SmartDashboard because the Rev Example later adds this code…

public void teleopPeriodic() {
m_motor.set(m_stick.getY());

m_motor.enableSoftLimit(CANSparkMax.SoftLimitDirection.kForward, 
                        SmartDashboard.getBoolean("Forward Soft Limit Enabled", true));
m_motor.enableSoftLimit(CANSparkMax.SoftLimitDirection.kReverse, 
                        SmartDashboard.getBoolean("Reverse Soft Limit Enabled", true));
m_motor.setSoftLimit(CANSparkMax.SoftLimitDirection.kForward, 
                     (float)SmartDashboard.getNumber("Forward Soft Limit", 15));
m_motor.setSoftLimit(CANSparkMax.SoftLimitDirection.kReverse,
                     (float)SmartDashboard.getNumber("Reverse Soft Limit", 0));

Help! We really need to get an arm motor to not go past 45 degrees or it will break.

We tried the following code, but the code doesn’t understand what SoftLimitDirection is.

motorShooterRotate.enableSoftLimit(CANSparkMax.SoftLimitDirection.kForward,true);
motorShooterRotate.enableSoftLimit(CANSparkMax.SoftLimitDirection.kReverse,true);

motorShooterRotate.setSoftLimit(CANSparkMax.SoftLimitDirection.kForward, 15);
motorShooterRotate.setSoftLimit(CANSparkMax.SoftLimitDirection.kReverse, 0);

1 Like

The soft limit feature appears to be in the 1.3.0 development release, what version are you using? https://trello.com/c/NNXD89Kg

1.1.9 is the the latest version on the Rev website.

I can confirm this. The soft limits example posted to Github was supposed to go into a separate branch and be merged in once we officially released this feature.

The link posted above is from our public roadmap. You can read more about our development releases on our trello here.