Here is our execute method in our sensor-reading command:
Code:
protected void execute() {
SmartDashboard.putNumber("Encoder Raw", Robot.sensors.getRaw());
SmartDashboard.putNumber("Encoder Rate", Robot.sensors.getRate());
SmartDashboard.putNumber("Encoder Distance" ,Robot.sensors.getDistance());
}
Here are the definitions for those methods in our sensor subclass:
Code:
public double getRate() {
return canEncoder.getRate();
}
public double getDistance() {
return canEncoder.getDistance();
}
public double getRaw() {
return canEncoder.getRaw();
}
And here is where we define our Talon and Encoder:
Code:
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
motorsCANTalon = new CANTalon(0);
LiveWindow.addActuator("Motors", "CAN Talon", motorsCANTalon);
sensorscanEncoder = new Encoder(0, 1, false, EncodingType.k4X);
LiveWindow.addSensor("Sensors", "canEncoder", sensorscanEncoder);
sensorscanEncoder.setDistancePerPulse(1.0);
sensorscanEncoder.setPIDSourceType(PIDSourceType.kRate);
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
motorsCANTalon.reverseSensor(true);
motorsCANTalon.setFeedbackDevice(FeedbackDevice.QuadEncoder);
motorsCANTalon.configEncoderCodesPerRev(360);
motorsCANTalon.setPosition(0);
motorsCANTalon.setForwardSoftLimit(15.0);
motorsCANTalon.setReverseSoftLimit(-15);
Is there something we are doing wrong? Anything we need to initialize so that we'll get values off the breakout?