View Single Post
  #5   Spotlight this post!  
Unread 12-02-2013, 22:25
xraymypanda's Avatar
xraymypanda xraymypanda is offline
Cowboy programmer
AKA: Chris M
FRC #0599 (RoboDox)
Team Role: Programmer
 
Join Date: Dec 2011
Rookie Year: 2011
Location: Granada Hills,CA
Posts: 82
xraymypanda has a spectacular aura aboutxraymypanda has a spectacular aura about
Re: Getting final vector from left & right drive encoders

I hope you have some knowledge of Trigonometry, that will help a little in this explanation. I am going to walk you through the formation of forumlae which work individually to find your deltaΘ and deltaLinearPosition. You can log these changes to create an always up to date heading or just utilize them individually to set your targets. With a little bit of manipulation these will give you vectors given that we have our angle and magnitude.
For deltaLinearPositiononly along one axis, basically vector magnitude)
We know that the distance traveled by the robot is relative to the change in ticks from our initial position. We can create a formula to find the change in inches based on a single tick using some simple math.
currentTicks = (leftEncoderTicks + rightEncoderTicks())/2
deltaTicks = currentTicks - initTicks
inchesPerTick = wheelCircumference/encoderTicksPerRevolution
deltaLinearPosition = deltaTicks*inchesPerTick

For deltaΘ:
We can derive our change in angle using our previously calculated formula for inches traveled based on ticks.
Using the formula s= rΘ, where s is the inches traveled by our drive base, we can find our change in angle.
our radius is the width of our robot (the distance between the two sets of wheels)
We know then that our s can be calculated much the same as our delta Linear Position, so we will use deltaTicks*inchesPerTick in place of s
deltaΘ = s/r = deltaTicks*inchesPerTicks/r
deltaΘ is in radians, so we can convert to degrees by multiplying by 180/pi
We create a new constant, degreesPerTick
degreesPerTick = inchesPerTick/r *180/pi
thus,
deltaΘ = deltaTicks*degreesPerTick

I hope this helps you out in your quest.
__________________

2011: Head Scout
2012: (figure)Head Programmer
2013: Head Programmer, Chief Strategist, Outreach Executive, and Driver