Bifalgorithm post · Robotics and AI · A Simple Obstacle-Avoidance Algorithm

Decision Rule

Decision Rule (Robotics and AI · A Simple Obstacle-Avoidance Algorithm) — "The following Python example illustrates a basic decision rule. The distance value i…

Ideas in this flowchart

  • A Python example implementing a basic distance-based decision rule
  • The rule is implemented by the choose_action function
  • The distance value is assumed to come from a working sensor driver
  • The function evaluates the distance and selects an action
  • Is distance_cm less than 20?
  • If the condition is true, return STOP
  • If the condition is false, return MOVE_FORWARD
  • The example assigns distance the value 15
  • The selected action is stored by calling choose_action(distance)
  • The program prints the selected action
  • Because 15 is less than 20, the expected output is STOP
Feed/

Decision Rule

Channel

Robotics and AI

1 page

"The following Python example illustrates a basic decision rule. The distance value is assumed to come from a working sensor driver.\n\ndef choose_action(distance_cm):\n\nif distance_cm < 20:\n\nreturn \"STOP\"\n\nelse:\n\nreturn \"MOVE_FORWARD\"\n\ndistance = 15\n\naction = choose_action(distance)\n\nprint(action)\n\nExpected output: STOP"

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.