So now we have a nice heading value coming back from the compass. Next I need to calculate a bearing to know what to match my heading to. I Frankensteined my San Jose GPS module off of the old truck onto the dev shield that had the compass already running.http://www.blogger.com/img/blank.gif. With a few code tweaks to combine code from the compass example and last year's banana I was able to get a heading along with a latitude and longitude.
Ok so I know where I am and where I'm facing.... I need somewhere to go....
What I did to get crackin' at some testing was to pick several points (8 to be precise). The first four were directly north, south, east, and west of my current position on my desk.
This is fairly simple to fake, in North America we live in the 4th quadrant, latitude to the north will increase - latitudes south will have a smaller decreased value. For longitude we will have increasing numerical values to the east (although they will still be negative) and even smaller negative values numbers ("more negativer") numbers to the west.
For points north east, south east, south west, and north west I had to do some thinking but I already had values to combine from the first set of spoofed points.
Now the hard part: trigonometry. For me the classes that introduced me to the theories of Pythagoras were of a bygone era. Quite literally the last time I used trigonometry to do much of anything I was a decade ago. This was going to be fun I thought I'd just work out the 8 examples and with an arcosine or two I'd have the bearing in radians er or degrees ... or was that supposed to be arctangent?
I will admit that I eventually caved and got the calculation for bearing by googling. This proves that anyone regardless of how they did in math in highschool may be able to program a robot to drive itself around. More on test results later.
No comments:
Post a Comment