A sonar sensor is used to define two states, one where there is an object present, and one where there is not. The servo will change its tick type and rate based on the state.