<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=US-ASCII">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR></HEAD>
<BODY id=role_body style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Arial"
bottomMargin=7 leftMargin=7 topMargin=7 rightMargin=7><FONT id=role_document
face=Arial color=#000000 size=2>
<DIV>Dean and Jon,</DIV>
<DIV> </DIV>
<DIV>this is a little delayed</DIV>
<DIV> </DIV>
<DIV>Re: Odometry Heading Calculation </DIV>
<DIV> </DIV>
<DIV>thanks for replies regarding use of atan2.</DIV>
<DIV>Yes, I have implemented same code (ages ago 1980) and now recently using
atan2 when using C. Problem I have with trig is probably due to the way my brain
is /is not organized.</DIV>
<DIV> </DIV>
<DIV>Even with atan2 I found myself making mistakes... </DIV>
<DIV>Anyway, the code that David A. illustrated eliminates some of the potential
traps.</DIV>
<DIV> </DIV>
<DIV>I see now looking at the arctangent function -- it is super linear
for small angular values.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>My original code as you can see is much more complex. Looking at it now not
sure what my thinking was.</DIV>
<DIV>I would think using the difference in motor encoder counts would be the way
to go in calculating delta</DIV>
<DIV>heading. </DIV>
<DIV> </DIV>
<DIV>// Pascal Code</DIV>
<DIV> </DIV>
<DIV>// dL = change in LEFT motor encoder count between previous and
current motor controller update</DIV>
<DIV>// dR = change in RIGHT ....</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> Lt := 1.0 * dL / Robot.CountsPerInch; // travel in inches
for this increment<BR> Rt := 1.0 * dR / Robot.CountsPerInch;</DIV>
<DIV> </DIV>
<DIV> // choose largest delta<BR> // for heading change
calc what was I thinking???</DIV>
<DIV> </DIV>
<DIV> if abs(Lt)>abs(Rt) then Dy := Lt<BR> else Dy := - Rt;</DIV>
<DIV> </DIV>
<DIV><BR> // Left wheel travel + causes robot to turn right
Heading+<BR> // Right wheel travel + causes robot to turn left
Heading-</DIV>
<DIV> </DIV>
<DIV> dh := ArcTan(Lt/(Robot.WheelSepInches)) -
ArcTan(Rt/(Robot.WheelSepInches));<BR></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Ron</DIV></FONT><BR><BR><BR><DIV><FONT style="color: black; font: normal 10pt ARIAL, SAN-SERIF;"><HR style="MARGIN-TOP: 10px">It's Tax Time! <A title="http://money.aol.com/tax?NCID=aolprf00030000000001" href="http://money.aol.com/tax?NCID=aolprf00030000000001" target="_blank">Get tips, forms and advice on AOL Money & Finance.</A></FONT></DIV></BODY></HTML>