test_sprofi_circle.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 from cob_light.srv import *
23 from cob_light.msg import *
24 
26  rospy.wait_for_service('/light_controller/mode')
27  control_lights = rospy.ServiceProxy('/light_controller/mode', SetLightMode)
28 
29  light_mode = LightMode()
30  #color in rgb color space ranging from 0 to 1
31  red = ColorRGBA()
32  red.r = 1
33  red.g = 0
34  red.b = 0
35  red.a = 0.7
36 
37  light_red = ColorRGBA()
38  light_red.r = 1
39  light_red.g = 0
40  light_red.b = 0
41  light_red.a = 0.3
42 
43  off = ColorRGBA()
44  off.r = 1
45  off.g = 0
46  off.b = 0
47  off.a = 0.01
48 
49  dimm = ColorRGBA()
50  dimm.r = 1
51  dimm.g = 0
52  dimm.b = 0
53  dimm.a = 0.04
54 
55  yellow = ColorRGBA()
56  yellow.r = 1
57  yellow.g = 1
58  yellow.b = 0
59  yellow.a = 1
60 
61  green = ColorRGBA()
62  green.r = 0
63  green.g = 1.0
64  green.b = 0
65  green.a = 1.0
66 
67  blue = ColorRGBA()
68  blue.r = 0
69  blue.g = 1
70  blue.b = 0.7
71  blue.a = 0.4
72 
73  white = ColorRGBA()
74  white.r = 0.3
75  white.g = 1
76  white.b = 0.3
77  white.a = 1
78 
79  light_mode.mode = 7
80  light_mode.frequency=40
81  light_mode.colors.append(green);
82  light_mode.colors.append(green);
83  light_mode.colors.append(green);
84  light_mode.colors.append(green);
85  light_mode.colors.append(green);
86  light_mode.colors.append(green);
87  light_mode.colors.append(green);
88  light_mode.colors.append(green);
89  light_mode.colors.append(green);
90  light_mode.colors.append(green);
91  light_mode.colors.append(green);
92  light_mode.colors.append(green);
93  light_mode.colors.append(green);
94  light_mode.colors.append(green);
95  light_mode.colors.append(green);
96  light_mode.colors.append(blue);
97  light_mode.colors.append(blue);
98  light_mode.colors.append(blue);
99  light_mode.colors.append(blue);
100  light_mode.colors.append(blue);
101  light_mode.colors.append(blue);
102  light_mode.colors.append(blue);
103  light_mode.colors.append(blue);
104  light_mode.colors.append(blue);
105  light_mode.colors.append(blue);
106  light_mode.colors.append(blue);
107  light_mode.colors.append(blue);
108  light_mode.colors.append(blue);
109  light_mode.colors.append(blue);
110  light_mode.colors.append(blue);
111 
112  light_mode.colors.append(green);
113  light_mode.colors.append(green);
114  light_mode.colors.append(green);
115  light_mode.colors.append(green);
116  light_mode.colors.append(green);
117  light_mode.colors.append(green);
118  light_mode.colors.append(green);
119  light_mode.colors.append(green);
120  light_mode.colors.append(green);
121  light_mode.colors.append(green);
122  light_mode.colors.append(green);
123  light_mode.colors.append(green);
124  light_mode.colors.append(green);
125  light_mode.colors.append(green);
126  light_mode.colors.append(green);
127  light_mode.colors.append(blue);
128  light_mode.colors.append(blue);
129  light_mode.colors.append(blue);
130  light_mode.colors.append(blue);
131  light_mode.colors.append(blue);
132  light_mode.colors.append(blue);
133  light_mode.colors.append(blue);
134  light_mode.colors.append(blue);
135  light_mode.colors.append(blue);
136  light_mode.colors.append(blue);
137  light_mode.colors.append(blue);
138  light_mode.colors.append(blue);
139  light_mode.colors.append(blue);
140  light_mode.colors.append(blue);
141  light_mode.colors.append(blue);
142  try:
143  resp1 = control_lights(light_mode)
144  print(resp1)
145  except rospy.ServiceException as e:
146  print("Service call failed: %s"%e)
147 
148  time.sleep(6)
149 
150 if __name__ == '__main__':
151  try:
152  rospy.init_node('light_test')
153  changeColor()
154  except rospy.ROSInterruptException:
155  pass
156 


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