So with code for the compass, gps, and servo all bootloaded up on the arduino I ran my first test of the navigation software. And it seemed to kinda work?
With the compass and bearing calculations establishing that I turn to the right or more lefter on a consistent basis the servo writes should be no problem right?
Wrong...the servo write statement did turn the wheels of the car when I pointed the arduino in a particular direction relative to a point, but the servo has got some wacky jitters as I continue to move things around.
At first I thought that I must be near a degree value where the bearing that was being calculated was bouncing to the left and right of the heading reading or vice versa.
Creating an error correction value that would allow for readings to bounce + or - 5 degrees still didn't fix the issue. Don't know what I will do to fix it but for now I can get things to turn in the right direction even if they are a bit twitchy.
Wednesday, June 22, 2011
Monday, June 13, 2011
Don't void the warranty!
With my code coming together for navigation I need to get back to the platform itself. I have decided that I finally need to put down the RC controller and see if I can actually control the RC car with the arduino.
Taking the top off the receiver wasn't too hard. Just had to remove some screws with the hex wrench that came with the car. After that I unplugged the servo and speed control. With some okie ingenuity I was able to rig up a connection to the servo with a servo extension from SparkFun even though the plugs didn't completely mate.
Once I got the whole thing wired up I began with some simple code from the arduino sketches to "write" the servo positions to the servo. I had to swap some wires to establish what was power, ground, and data but once that was established I was able to point wheels left, right, and center on command. I did notice that although the servo was equipped to run from 0 to 180 degrees the linkages under the car only allowed for a min of 45 and a max of 135 with 90 being dead center.
Soon I hope to combine the waypoint bearing calculations and compass readings from the navigation testing with the servo controller code!
Taking the top off the receiver wasn't too hard. Just had to remove some screws with the hex wrench that came with the car. After that I unplugged the servo and speed control. With some okie ingenuity I was able to rig up a connection to the servo with a servo extension from SparkFun even though the plugs didn't completely mate.
Once I got the whole thing wired up I began with some simple code from the arduino sketches to "write" the servo positions to the servo. I had to swap some wires to establish what was power, ground, and data but once that was established I was able to point wheels left, right, and center on command. I did notice that although the servo was equipped to run from 0 to 180 degrees the linkages under the car only allowed for a min of 45 and a max of 135 with 90 being dead center.
Soon I hope to combine the waypoint bearing calculations and compass readings from the navigation testing with the servo controller code!
Saturday, June 4, 2011
Fun with Trigonometry!
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.
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.
Subscribe to:
Posts (Atom)