My version of this assignment is meant to simulate the actions of a cat. The process follows the cat walking normally when not alert, seeing a mouse scurry by, then getting ready to pounce on it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#initial pause
time.sleep(2.0)
 
# cat walking (not alert)
print("walking while not alert")
ringing_move(servo, 45.0, duration = 4)
time.sleep(1.5)
ringing_move(servo, 45.0, duration = 2)
# cat takes a pause to stare at something
time.sleep(2.0)
 
# cat's eyes follow mouse running by
print("Target found")
linear_move(servo, 180.0, 25.0, speed=45)
 
# brief pause; stillness is the counterpoint
time.sleep(1.0)
 
# start bouncy oscillation movements
print("Wiggling to adjust pounce direction")
ringing_move(servo, 25.0, duration=1.5)
ringing_move(servo, 35.0, duration=1.5)
ringing_move(servo, 40.0, duration=1.5)
 
time.sleep(5.0)