test_sprofi_circle.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
00016 
00017 
00018 import time
00019 
00020 import rospy
00021 from std_msgs.msg import ColorRGBA
00022 from cob_light.srv import *
00023 from cob_light.msg import *
00024 
00025 def changeColor():
00026   rospy.wait_for_service('/light_controller/mode')
00027   control_lights = rospy.ServiceProxy('/light_controller/mode', SetLightMode)
00028 
00029   light_mode = LightMode()
00030   #color in rgb color space ranging from 0 to 1
00031   red = ColorRGBA()
00032   red.r = 1
00033   red.g = 0
00034   red.b = 0
00035   red.a = 0.7
00036 
00037   light_red = ColorRGBA()
00038   light_red.r = 1
00039   light_red.g = 0
00040   light_red.b = 0
00041   light_red.a = 0.3
00042 
00043   off = ColorRGBA()
00044   off.r = 1
00045   off.g = 0
00046   off.b = 0
00047   off.a = 0.01
00048 
00049   dimm = ColorRGBA()
00050   dimm.r = 1
00051   dimm.g = 0
00052   dimm.b = 0
00053   dimm.a = 0.04
00054 
00055   yellow = ColorRGBA()
00056   yellow.r = 1
00057   yellow.g = 1
00058   yellow.b = 0
00059   yellow.a = 1
00060 
00061   green = ColorRGBA()
00062   green.r = 0
00063   green.g = 1.0
00064   green.b = 0
00065   green.a = 1.0
00066 
00067   blue = ColorRGBA()
00068   blue.r = 0
00069   blue.g = 1
00070   blue.b = 0.7
00071   blue.a = 0.4
00072 
00073   white = ColorRGBA()
00074   white.r = 0.3
00075   white.g = 1
00076   white.b = 0.3
00077   white.a = 1
00078 
00079   light_mode.mode = 7
00080   light_mode.frequency=40
00081   light_mode.colors.append(green);
00082   light_mode.colors.append(green);
00083   light_mode.colors.append(green);
00084   light_mode.colors.append(green);
00085   light_mode.colors.append(green);
00086   light_mode.colors.append(green);
00087   light_mode.colors.append(green);
00088   light_mode.colors.append(green);
00089   light_mode.colors.append(green);
00090   light_mode.colors.append(green);
00091   light_mode.colors.append(green);
00092   light_mode.colors.append(green);
00093   light_mode.colors.append(green);
00094   light_mode.colors.append(green);
00095   light_mode.colors.append(green);
00096   light_mode.colors.append(blue);
00097   light_mode.colors.append(blue);
00098   light_mode.colors.append(blue);
00099   light_mode.colors.append(blue);
00100   light_mode.colors.append(blue);
00101   light_mode.colors.append(blue);
00102   light_mode.colors.append(blue);
00103   light_mode.colors.append(blue);
00104   light_mode.colors.append(blue);
00105   light_mode.colors.append(blue);
00106   light_mode.colors.append(blue);
00107   light_mode.colors.append(blue);
00108   light_mode.colors.append(blue);
00109   light_mode.colors.append(blue);
00110   light_mode.colors.append(blue);
00111 
00112   light_mode.colors.append(green);
00113   light_mode.colors.append(green);
00114   light_mode.colors.append(green);
00115   light_mode.colors.append(green);
00116   light_mode.colors.append(green);
00117   light_mode.colors.append(green);
00118   light_mode.colors.append(green);
00119   light_mode.colors.append(green);
00120   light_mode.colors.append(green);
00121   light_mode.colors.append(green);
00122   light_mode.colors.append(green);
00123   light_mode.colors.append(green);
00124   light_mode.colors.append(green);
00125   light_mode.colors.append(green);
00126   light_mode.colors.append(green);
00127   light_mode.colors.append(blue);
00128   light_mode.colors.append(blue);
00129   light_mode.colors.append(blue);
00130   light_mode.colors.append(blue);
00131   light_mode.colors.append(blue);
00132   light_mode.colors.append(blue);
00133   light_mode.colors.append(blue);
00134   light_mode.colors.append(blue);
00135   light_mode.colors.append(blue);
00136   light_mode.colors.append(blue);
00137   light_mode.colors.append(blue);
00138   light_mode.colors.append(blue);
00139   light_mode.colors.append(blue);
00140   light_mode.colors.append(blue);
00141   light_mode.colors.append(blue);
00142   try:
00143     resp1 = control_lights(light_mode)
00144     print resp1
00145   except rospy.ServiceException, e:
00146     print "Service call failed: %s"%e
00147 
00148   time.sleep(6)
00149 
00150 if __name__ == '__main__':
00151     try:
00152         rospy.init_node('light_test')
00153         changeColor()
00154     except rospy.ROSInterruptException:
00155         pass
00156 


cob_light
Author(s): Benjamin Maidel
autogenerated on Sat Jun 8 2019 21:02:07