Poniżej znajdują się algorytmy sterowania wykorzystujące echosondę. Aby sprawdzić działanie algorytmów należy przygotować tor przeszkód.
Rule: 1 if ultrasonic_Value > 50 and go ≠ 0 then go := 100 and go_cm := 0 and turn := 0 Rule: 2 if ultrasonic_Value > 50 and go = 0 and turn = 0 then go := 100 and go_cm := 0 and turn := 0 Rule: 3 if ultrasonic_Value > 50 and go = 0 and turn < 0 then go := 100 and go_cm := 0 and turn := 0 Rule: 4 if ultrasonic_Value > 50 and go = 0 and turn > 0 then go_cm := 10 and go := 0 and turn := 0 Rule: 5 if ultrasonic_Value ≤ 50 and go ≠ 0 then turn := 90 and go := 0 and go_cm := 0 Rule: 6 if ultrasonic_Value ≤ 50 and go = 0 and turn ≠ 0 then turn := 0 and go := 0 and go_cm := 10 Rule: 7 if ultrasonic_Value ≤ 50 and go = 0 and turn = 0 and go_cm = 0 then turn := 90 and go := 0 and go_cm := 0 Rule: 8 if ultrasonic_Value ≤ 50 and go = 0 and turn = 0 and go_cm ≠ 0 then turn := -90 and go := 0 and go_cm := 0
state(go). // Knowladge Base => previous state updated in fly.. initial state would also be state(go) start :- nxt_ultrasonic_sensor(port,Value) Value > 50, start_go. start :- nxt_ultrasonic_sensor(port,Value) Value =< 50, start_turn. start :- nxt_go(0). start_go :- state(go), nxt_go(0). start_go :- state(go_cm), nxt_go_cm(distance,speed). start_turn :- state(go), nxt_turn_degrees(speed,90). start_turn :- state(go_cm), nxt_turn_degrees(speed,-90).