Skip to content

Commit 7126cf0

Browse files
committed
example: pose_example.py
1 parent 9a1cf19 commit 7126cf0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

examples/pose_example.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from arduino_alvik import ArduinoAlvik
2+
from time import sleep_ms
3+
import sys
4+
5+
alvik = ArduinoAlvik()
6+
alvik.begin()
7+
8+
while True:
9+
try:
10+
11+
alvik.move(100.0)
12+
while (ack := alvik.get_ack()) != ord('M'):
13+
sleep_ms(200)
14+
print("on target after move")
15+
16+
alvik.rotate(90.0)
17+
while (ack := alvik.get_ack()) != ord('R'):
18+
sleep_ms(200)
19+
print("on target after rotation")
20+
21+
alvik.move(50.0)
22+
while (ack := alvik.get_ack()) != ord('M'):
23+
sleep_ms(200)
24+
print("on target after move")
25+
26+
alvik.rotate(-45.00)
27+
while (ack := alvik.get_ack()) != ord('R'):
28+
sleep_ms(200)
29+
print("on target after rotation")
30+
31+
x, y, theta = alvik.get_pose()
32+
print(f'Current pose is x={x}, y={y} ,theta={theta}')
33+
34+
alvik.reset_pose(0, 0, 0)
35+
36+
x, y, theta = alvik.get_pose()
37+
print(f'Updated pose is x={x}, y={y} ,theta={theta}')
38+
sleep_ms(500)
39+
40+
except KeyboardInterrupt as e:
41+
print('over')
42+
alvik.stop()
43+
sys.exit()

0 commit comments

Comments
 (0)