added new code for compass and sonar