because your while loop's condition is k > 10.
You never set k to anything. Therefore, it will just runaway with the thread printing the same numbers to the dashboard (which will be 0 since the encoder was just reset)
you should move everything inside the "while" (plus the "double k = ...") to autonomousPeriodic. (don't use the person above mine's code, as it still suffers from the lack of setting 'k')
Code:
Encoder sampleEncoder = new Encoder(8, 9, false, Encoder.EncodingType.k2X);
public void autonomousInit() {
autoLoopCounter = 0;
sampleEncoder.setMaxPeriod(0.1);
sampleEncoder.setMinRate(10);
sampleEncoder.setDistancePerPulse(5);
sampleEncoder.setSamplesToAverage(7);
sampleEncoder.reset();
SmartDashboard.putNumber("hmm", 2);
}
public void autonomousPeriodic(){
double k = sampleEncoder.getRate();
boolean what = sampleEncoder.getStopped();
String huh = sampleEncoder.getSmartDashboardType();
String k2 = Double.toString(k);
double distance = sampleEncoder.getDistance();
String distance1 = Double.toString(distance);
SmartDashboard.putNumber(k2, k);
SmartDashboard.putNumber(distance1, distance);
SmartDashboard.putBoolean(huh, what);
}
also
1) use more descriptive variable names (huh, what, k2, k are all very, very bad names) (I understand you used these to test, but these for testing isn't even acceptable. You're going to try to fix ur broken test code and u'll end up spending more time re-learning what the variables do than actually fixing the code)
2) don't instantiate ANYTHING (encoder... hint hint) in a function that can be run more than once as your code will error out