GPS guided obstacle avoider seems indecisive

You could reinvent that wheel, or you could use a more accurate library: NeoGPS. Like jremington suggested, it uses integer representations internally, to avoid the loss of precision caused by using the Arduino float type. It maintains the full accuracy provided by your device for distance and bearing calculations, whatever that is... :wink:

NeoGPS is also smaller, faster and more reliable than all other libraries. It has many configuration options that can make it even smaller and faster.

I've attached a NeoGPS version of your sketch, but I can't compile it without having the same set of your libraries. The only changes are that the waypoint should be a Location_t type, and you don't need the coord array:

double currHeading, Kgas;  // PID Setpoint, input and output vars 
//const double waypoint[] = {29.540158, -95.110300};
NeoGPS::Location_t waypoint( 295401580L, -951103000 ); // one more significant digit, if you want
//double coord[2];
double currDist;

Notice how the waypoint can be more accurate. And the getGPSinfo subroutine is simpler:

void getGPSinfo()
{
  while (gps.available( Serial1 )) {
    gps_fix fix = gps.read();
    if (fix.valid.location) {
      currDist    = fix.location.DistanceKm( waypoint ) * 1000.0; // meters
      currBearing = fix.location.BearingToDegrees( waypoint );
    }
  }
}

The distance and bearing routines are not needed.

There are many tips on the Troubleshooting page, especially regarding the overall loop structure. The example programs from all other libraries are not structured in a way that lets you modify them without breaking them. NeoGPS is available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

Cheers,
/dev

BryanTmann.ino (11.9 KB)