Thanks to Evil Genius, I have waypoint recognition sorted.
Now I have a GPS guided test vehicle (RC car) that is steering to a waypoint, but it wanders around far too much.
Is there any way I can smooth out the steering signal. I thought about a system that reads the steering value (d) and puts that into an array each time around the steering loop. This should allow an average of d to be produced, which would then be provided to the steering routine.
Has anyone any idea if this is the best way to smooth out the steering?
Any ideas or code is much appreciated.
Thanks.
Here is the code that produces the steering signal:
[do
{if (nss.available() > 0 ) {
// read incoming character from GPS
char c = nss.read();
// check if the character completes a valid GPS sentence
if (gps.decode(c)) {
// check if GPS positioning was active
if (gps.gprmc_status() == ‘A’) {
{d = gps.gprmc_course_to(hlat,hlon) - gps.gprmc_course();} // steer for home
if (d < 0) { d += 360; }
if (d > 180) { d -= 360; }
if (d>=2){
steerservo.write(88);} // steer 2 degrees
if (d>=5){
steerservo.write(85);} // steer 5 degrees
if (d>=10){
steerservo.write(80);} // steer 10 degrees
if (d>=15){
steerservo.write(75);} // steer 15 degrees
if (d>=20){
steerservo.write(70);} // steer 20 degrees
Serial.println("steer to home loop ");
if (d<-2) {
steerservo.write(92);} // steer -2 degrees
if (d<-5) {
steerservo.write(95);} // steer -5 degrees
if (d<-10) {
steerservo.write(100);} // steer -10 degrees
if (d<-15) {
steerservo.write(105);} // steer -15 degrees
if (d<-20) {
steerservo.write(110);} // steer -20 degrees
if (gps.gprmc_distance_to(hlat, hlon,MTR) < wptRange) // See If thge distance from current point is less than then the defined Radius
{digitalWrite(13,LOW);}
}}}}
while (z==2);}}]