<!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>&nbsp;</DIV>
<DIV>this is a little delayed</DIV>
<DIV>&nbsp;</DIV>
<DIV>Re: Odometry Heading Calculation </DIV>
<DIV>&nbsp;</DIV>
<DIV>thanks for&nbsp; 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&nbsp;organized.</DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV>I see now looking at the arctangent function --&nbsp; it is super linear 
for small angular values.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV>// Pascal Code</DIV>
<DIV>&nbsp;</DIV>
<DIV>// dL =&nbsp; change in LEFT &nbsp;motor encoder count between previous and 
current motor controller update</DIV>
<DIV>// dR =&nbsp; change in &nbsp;RIGHT&nbsp; ....</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;Lt := 1.0 * dL / Robot.CountsPerInch;&nbsp;&nbsp; // travel in inches 
for this increment<BR>&nbsp;Rt := 1.0 * dR / Robot.CountsPerInch;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // choose largest delta<BR>&nbsp; // for heading change 
calc&nbsp;&nbsp;&nbsp;&nbsp; what was I thinking???</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; if abs(Lt)&gt;abs(Rt) then Dy := Lt<BR>&nbsp; else Dy := - Rt;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;&nbsp; // Left wheel travel + causes robot to turn right&nbsp; 
Heading+<BR>&nbsp;&nbsp; // Right wheel travel + causes robot to turn left 
Heading-</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; dh :=&nbsp; ArcTan(Lt/(Robot.WheelSepInches)) - 
ArcTan(Rt/(Robot.WheelSepInches));<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</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>