Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 19 A bigger FSM example: Hungry Robot Ant in Maze.

Similar presentations


Presentation on theme: "Lecture 19 A bigger FSM example: Hungry Robot Ant in Maze."— Presentation transcript:

1 Lecture 19 A bigger FSM example: Hungry Robot Ant in Maze

2 Robotic ant in a maze Help the ant escape the maze to find food!
Maze has no islands Food! start

3 Robotic ant specifics Sensors Actuators What strategy should we use?
L and R antennae, 1 if touching wall Actuators F - forward step, TL/TR - turn left/right What strategy should we use? Right-hand rule! (It works in physics and pretty much everywhere else…)

4 Right-hand rule Keep the wall to the right of the ant

5 Special cases: What to do?
Left (L) antenna touching the wall

6 Special cases: What to do?
Ant lost (not adjacent to any wall)

7 Special cases: What to do?
Ant lost (not adjacent to any wall)

8 Robot ant behavior A: Following wall, touching Go forward, turning left slightly B: Following wall, not touching Go forward, turning right slightly D: Hit wall again Back to state A C: Break in wall Go forward, turning right slightly E: Wall in front Turn left until... F: ...we are here, same as state B G: Turn left until... LOST: Forward until we touch something

9 Notes and strategy Notes Strategy Maze has no islands
Corridors are wider than ant Don’t worry about startup Assume a Moore machine Assume D flip-flops Strategy Right-hand rule!

10 FSM design procedure 1. State diagram 2. State-transition table
3. State minimization 4. State encoding 5. Next-state logic minimization 6. Implement the design

11 Notations Sensors on L and R antennae Movement
Sensor = “1” if touching wall; “0” if not touching wall L'R'  no wall L'R  wall on right LR'  wall on left LR  wall in front Movement F  forward one step TL  turn left slightly TR  turn right slightly

12 1. State diagram Make certain that transitions
L’ R’ L’ R A/D [TL, F] B/C/F [TR, F] L’ R L’ R’ L’ R’ L’ R’ LR L R’ L R’ G [TL] LR R E [TL] L R’ R L R’ L R’ Make certain that transitions from all states are defined on all possible inputs LOST (F) L’ R’ R

13 2. State transition table
state L R next state outputs LOST 0 0 LOST F LOST X 1 E F LOST 1 0 G F E 0 0 B TL E X 1 E TL E G TL G 0 0 B TL G X 1 E TL G G TL A 0 0 B TL, F A 0 1 A TL, F A 1 0 G TL, F A E TL, F B 0 0 B TR, F B 0 1 A TR, F B G TR, F B E TR, F Same outputs and transitions  can merge states

14 3. State minimization Result of merging states E and G L’ R’ L’ R A/D
[TL, F] B/C/F [TR, F] L’ R L’ R’ L’ R’ L Result of merging states E and G L L+R E/G [TL] LOST (F) L’ R’ L+R

15 4. State encoding state L R next state outputs X Y X+ Y+ F TR TL
0 0 X X X X state L R next state outputs LOST 0 0 LOST F LOST X 1 E F LOST 1 0 E F E 0 0 B TL E X 1 E TL E E TL A 0 0 B TL, F A 0 1 A TL, F A 1 X E TL, F B 0 0 B TR, F B 0 1 A TR, F B 1 X E TR, F

16 5. Next-state logic minimization
X X+ Y R L X Y+ Y R L state L R next state outputs X Y X+ Y+ F TR TL 0 0 X X X X X F Y R L X TR Y R L X TL Y R L Why are the 1's in the last 3 K-maps in vertical columns?

17 6. Implement the design Outputs are a function of the current state only - Moore machine L R F TR TL Next State Current State output logic next state logic X+ Y+ X Y


Download ppt "Lecture 19 A bigger FSM example: Hungry Robot Ant in Maze."

Similar presentations


Ads by Google