asr_vosk: Allow to handle keyword and command in one sentence
[ros_wild_thumper.git] / scripts / christmas.py
1 #!/usr/bin/env python
2 # -*- coding: iso-8859-15 -*-
3
4 import rospy
5 from random import *
6 from datetime import datetime
7 from wild_thumper.msg import *
8
9 max_val = 10
10 light = 0
11 ldr_thres = 8
12
13 def sensorReceived(msg):
14         global light
15         light = msg.light
16
17 if __name__ == "__main__":
18         rospy.init_node('christmas')
19         pub = rospy.Publisher('led_stripe', LedStripe, queue_size=10)
20         rospy.Subscriber("/sensors", Sensor, sensorReceived)
21         rate = rospy.Rate(2)
22         val = max_val
23         while not rospy.is_shutdown():
24                 if light <= ldr_thres or val != 0:
25                         now = datetime.now()
26                         if light <= ldr_thres and now.hour >= 18 and now.hour < 22:
27                                 val = max_val
28                         else:
29                                 val = 0
30                         msg = LedStripe()
31                         msg.leds = [
32                                         Led(4, randint(0, val), randint(0, val), randint(0, val)),
33                                         Led(5, randint(0, val), randint(0, val), randint(0, val)),
34                                         Led(6, randint(0, val), randint(0, val), randint(0, val)),
35                                         Led(7, randint(0, val), randint(0, val), randint(0, val))
36                                         ]
37                         pub.publish(msg)
38                 rate.sleep()