test.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 
00023 def changeColor():
00024         pub = rospy.Publisher('light_controller/command', ColorRGBA, queue_size=1)
00025         rospy.init_node('light_test')
00026         #color in rgb color space ranging from 0 to 1
00027         red = ColorRGBA()
00028         red.r = 1
00029         red.g = 0
00030         red.b = 0
00031         red.a = 1
00032 
00033         yellow = ColorRGBA()
00034         yellow.r = 0.4
00035         yellow.g = 1
00036         yellow.b = 0
00037         yellow.a = 1
00038 
00039         green = ColorRGBA()
00040         green.r = 0
00041         green.g = 1
00042         green.b = 0
00043         green.a = 1
00044 
00045         blue = ColorRGBA()
00046         blue.r = 0
00047         blue.g = 0
00048         blue.b = 1
00049         blue.a = 1
00050 
00051         white = ColorRGBA()
00052         white.r = 0.3
00053         white.g = 1
00054         white.b = 0.3
00055         white.a = 1
00056 
00057         for color in [red,yellow,green,white,blue,green]:
00058                 rospy.loginfo("Setting rgb to %s [%d, %d, %d]",color.r,color.g,color.b,color.a)
00059                 pub.publish(color)
00060                 time.sleep(3)
00061 
00062 if __name__ == '__main__':
00063     try:
00064         changeColor()
00065     except rospy.ROSInterruptException: pass
00066 


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