test.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import time
19 
20 import rospy
21 from std_msgs.msg import ColorRGBA
22 
24  pub = rospy.Publisher('light_controller/command', ColorRGBA, queue_size=1)
25  rospy.init_node('light_test')
26  #color in rgb color space ranging from 0 to 1
27  red = ColorRGBA()
28  red.r = 1
29  red.g = 0
30  red.b = 0
31  red.a = 1
32 
33  yellow = ColorRGBA()
34  yellow.r = 0.4
35  yellow.g = 1
36  yellow.b = 0
37  yellow.a = 1
38 
39  green = ColorRGBA()
40  green.r = 0
41  green.g = 1
42  green.b = 0
43  green.a = 1
44 
45  blue = ColorRGBA()
46  blue.r = 0
47  blue.g = 0
48  blue.b = 1
49  blue.a = 1
50 
51  white = ColorRGBA()
52  white.r = 0.3
53  white.g = 1
54  white.b = 0.3
55  white.a = 1
56 
57  for color in [red,yellow,green,white,blue,green]:
58  rospy.loginfo("Setting rgb to %s [%d, %d, %d]",color.r,color.g,color.b,color.a)
59  pub.publish(color)
60  time.sleep(3)
61 
62 if __name__ == '__main__':
63  try:
64  changeColor()
65  except rospy.ROSInterruptException: pass
66 
def changeColor()
Definition: test.py:23


cob_light
Author(s): Benjamin Maidel
autogenerated on Wed Apr 7 2021 02:11:39