error: 'ping' was not declared in this scope

Ok...been fooling with this a while and need some more assistance. I don't know if it is better to place the movements (forward, back, right, left, stop) in functions or code them all in the void Loop() using 'if' and 'if else' statements. Which is better? The goal is to have continuous motion and continuous course and speed corrections as the robot looks for and moves towards the target. Once it detects it is within the correct distance from the target, it should shut down. Thanks.