View Single Post
  #4   Spotlight this post!  
Unread 17-01-2016, 19:30
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Using Encoder to Drive a Certain Distance

Quote:
Originally Posted by curtis0gj View Post
Just curious about the set distance per pulse function. Is this function the ratio between how far each pulse will take the robot?

For example if I were to calculate the circumference of the wheel (in inches). Then divide the circumference of the wheel by the number of pulses in a full revolution (which is 1440 I think if I am using x4 encoding). Then set the distance per pulse to the circumference/number of pulses in one revolution would it make one full revolution move the robot one inch?

Sorry if this is not clear enough I can try to clarify if it makes zero sense.
That's the right process. However, wpilib normalizes pulses, so it won't change by decoding type. You should use 360 pulses in a full revolution, but it will increment in 1/4 increments in 4x mode. In addition, you'll want to take into account any gearing between the encoder and the wheel.

Code:
	//Encoder Distance Constants
    public static final double wheelDiameter = 6;
    public static final double pulsePerRevolution = 360;
    public static final double encoderGearRatio = 3;
    public static final double gearRatio = 64.0/20.0;
    public static final double Fudgefactor = 1.0;


final double distanceperpulse = Math.PI*wheelDiameter/pulsePerRevolution /
        		encoderGearRatio/gearRatio * Fudgefactor;
driveTrainEncoderL.setDistancePerPulse(distanceperpulse);
Reply With Quote