Quote:
Originally Posted by Joe Ross
|
Okay perfect just one final question

. Our encoder is mounted onto the shaft from the KOP toughboxes. I don't think there is any gear ratio for the encoder however there is one for the motors (TB Mini Gearbox for AM14U, 10.71:1 Ratio ) so will I need to include a encoderGearRatio?
http://www.andymark.com/AM14U3-p/am-14u3.htm
Update:
Just tested the code and I the number I was getting from the encoder very off. I was trying to travel 36 inches but at the 36 inch mark the encoder is reading about 1.26.
This is the manual to the drive train we are using currently just to get things rolling. If you jump to page 4 it will tell you the gear ratio specifics. We are using the included 4 inch wheels.
http://files.andymark.com/AM14U_Asse...structions.pdf
I am having a hard time finding the exact model of encoder we are using. It is very similar to this:
http://www.andymark.com/product-p/am-3132.htm It's just an optical encoder that we got in 2014.
Here is snippets of the code everything that I am doing with the encoder is included below.
Code:
public class Robot extends IterativeRobot {
RobotDrive tankDrive = new RobotDrive(0, 1);
Encoder encoder = new Encoder(0, 1, true, EncodingType.k4X);
public static final double WHEEL_DIAMETER = 4;
public static final double PULSE_PER_REVOLUTION = 360;
public static final double ENCODER_GEAR_RATIO = 0;
public static final double GEAR_RATIO = 8.45 / 1;
public static final double FUDGE_FACTOR = 1.0;
public void autonomousInit() {
final double distancePerPulse = Math.PI * Defines.WHEEL_DIAMETER / Defines.PULSE_PER_REVOLUTION
/ Defines.ENCODER_GEAR_RATIO / Defines.GEAR_RATIO * Defines.FUDGE_FACTOR;
encoder.setDistancePerPulse(distancePerPulse);
}
public void autonomousPeriodic() {
double encoderDistanceReading = encoder.getDistance();
SmartDashboard.putNumber("encoder reading", encoderDistanceReading);
tankDrive.drive(-0.25, 0);
if (encoderDistanceReading > 36) {
tankDrive.drive(0, 0);
}
}
}