-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanimate.py
52 lines (42 loc) · 1.33 KB
/
animate.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
from time import sleep
import rospy
from rospy import Publisher
from std_msgs.msg import String, Float32, Bool
from anki_vector_ros.msg import RobotStatus, Color
"""
Sample program to make Vector animate off the base
"""
def main():
print("Setting up publishers")
speech_pub = Publisher("/behavior/say_text", String, queue_size=1)
lift_pub = Publisher("/motors/lift", Float32, queue_size=5)
base_pub = Publisher("/behavior/drive_charger", Bool, queue_size=1)
spin_pub = Publisher("/behavior/turn_in_place", Float32, queue_size=1)
eye_color_pub = Publisher("/behavior/eye_color", Color, queue_size=1)
# Need small delay to setup publishers
sleep(1.0)
lift_pub.publish(-2.0)
sleep(0.08)
for _ in range(10):
lift_pub.publish(2.0)
sleep(0.08)
lift_pub.publish(0.0)
sleep(0.08)
lift_pub.publish(-2.0)
sleep(0.08)
lift_pub.publish(0.0)
sleep(0.08)
base_pub.publish(False)
sleep(5.0)
speech_pub.publish("Hi, my name is Vector!")
sleep(1.8)
eye_color_pub.publish(Color(255, 0, 0))
sleep(1.5)
spin_pub.publish(3.14)
sleep(2.0)
eye_color_pub.publish(Color(128, 128, 0))
if __name__ == "__main__":
rospy.init_node("vector_animate")
rospy.wait_for_message("/status", RobotStatus)
main()