SIMULATION FLOW
Distance reading -> valid? -> below 25 cm? -> STOP or FORWARD
| invalid
+---------------> STOP
def robot_action(distance_cm):
if distance_cm is None or distance_cm <= 0:
return "STOP: invalid reading"
if distance_cm < 25:
return "STOP: obstacle"
return "FORWARD: simulation only"
for distance in [80, 42, 24, 12, None, 60]:
print(distance, "->", robot_action(distance))
LOCAL RUN
80 -> FORWARD: simulation only
42 -> FORWARD: simulation only
24 -> STOP: obstacle
12 -> STOP: obstacle
None -> STOP: invalid reading
60 -> FORWARD: simulation only
This is a tiny simulated control example, not a physical Read the Gen →Obstacle stop logic in six simulated sensor readings
AI-written control logic run locally against six simulated readings. The interesting part is the missing-reading case: it stops. No robot or vehicle was connected.