I read navigation.cpp from AP_Navigation library. I need to measure crosstrack of ArduRover measuring the current location (from GPS) with the desired point or path. Inside the code there is a crosstrack calculation. Somehow, I am not really understand what the code actually doing.
Can someone explain to me the basic theory behind the crosstrack code in AP_Navigation.h ? I still a beginner in this DIY drone.
Your explanation is much appreciated! Thanks...
Replies
You guys really directed me to the correct place which I haven't found before (maybe because of the wrong keyword). I need to absord these first. Thank a lot! Really appreciate that.
Awesome!
Here's another place to look:
http://www.movable-type.co.uk/scripts/latlong.html
DId you look at http://code.google.com/p/ardupilot-mega/wiki/CrossTrack and
http://diydrones.com/profiles/blogs/705844:BlogPost:43438 and
http://diydrones.com/profiles/blog/show?id=705844%3ABlogPost%3A108164 ?
See also:
http://www.rcgroups.com/forums/showpost.php?p=10263920&postcoun...
http://www.rcgroups.com/forums/showthread.php?t=899333
http://diydrones.com/forum/topics/crosstrack-error-navigation
A rover doesn't have crosstrack to deal with. Crosstrack is when your vehicle is also traveling perpendicular (or at some angle) to the direction it is heading. A plane or copter in a crosswind or a boat crossing a river would have to deal with crosstrack error.
Basic idea, draw a line from one way point to another.
Cross track error is how far to the right or left of this line are you?
My approach is to adjust the origin so the destination is at 0,0
Then draw a line from the start to this point.
Find the Normal to this line (IE rotate it 90 degrees is one simple way realize that sin/cos of 90 deg is 0,1 so your really just swaping x,y values)
Then given the slope of this line find the intersection of this line moved to the current position and the origional line.
The distance from here to that intersection is the cross track error.
I also compute the current heading to the destination and when that is more than 90 degrees from the origional heading I declare that waypoint passed and move on to the next.
This may not be what the APM code is doing, but it is what my personal AP code does.
Paul