error: 'ping' was not declared in this scope

  if ((chkDistanceFwd>dangerThresh) && (rightDistance=leftDistance)) //if target distance is greater than programmed default, go straight

Still don't know the difference between = and ==, I see.

I really recommend that you stop duplicating code. In the ping() function, you have three identical blocks of code.

Make the ping() function do NOTHING BUT the pinging. Make another function ping in three places by calling the ping() function three times, after positioning the servo.