Hi everyone!I need to write the code for navigation calculations(distance and bearing) for my UAV project. I went through some of the methods like pythagorus & haversine but I am really confused. Can somebody share the code/method which has been succesfully tested. I am working on PIC18 microcontroller.RegardsAchal
You need to be a member of diydrones to add comments!
Replies
http://williams.best.vwh.net/avform.htm
The PIC18 will definitely limit you to the flat-earth approximations.
Here's an example (from my NXT AutoPilot):
float tempHeading=0;
float dX=(gpsLon-gpsLon_old);
float dY=(gpsLat-gpsLat_old);
if(dX!=0)
{
tempHeading=radiansToDegrees(atan(dY/dX));
if(dX<0)
{
if(dY<=0)tempHeading+=180;
else if(tempHeading>270)tempHeading-=180;
}
}
else if(dY!=0)
{
if(dY<0)tempHeading=270;
else tempHeading=90;
}