def put_pixels(self, pixels): """ set the LEDs to the values in pixels. :param pixels: an array of 3-ary tuples """ self._last_pixels = pixels chest_msg = ChestLeds() for i in range(min(len(pixels), ChestLightClient.NUM_LEDS)): chest_msg.leds[i] = Led(pixels[i][0], pixels[i][1], pixels[i][2]) self._light_pub.publish(msg)
def run(): pub = rospy.Publisher('/mobile_base/commands/chest_leds', ChestLeds, queue_size=10) rospy.init_node('kuri_light') rate = rospy.Rate(100) l = ChestLeds() print("Light Program Started") for i in range(len(l.leds)): l.leds[i].red = 255 l.leds[i].green = 255 l.leds[i].blue = 255 button_delay = 0.2 while not rospy.is_shutdown(): try: letter = getch() if (letter == "r"): print("___you pressed red") for i in range(len(l.leds)): l.leds[i].red = 255 l.leds[i].green = 0 l.leds[i].blue = 0 #print( l.leds[i]) time.sleep(button_delay) if (letter == "g"): print("___you pressed green___") for i in range(len(l.leds)): l.leds[i].red = 0 l.leds[i].green = 255 l.leds[i].blue = 0 #print( l.leds[i]) time.sleep(button_delay) if (letter == "b"): print("___you pressed blue___") for i in range(len(l.leds)): l.leds[i].red = 0 l.leds[i].green = 0 l.leds[i].blue = 255 #print( l.leds[i]) time.sleep(button_delay) if (letter == "q"): rainbow(.3, .3, .3, 0, 2, 4) if (letter == "c"): print("Teleop ended.") exit(0) pub.publish(l) rate.sleep() except: pass
def light_up(r, g, b): pub = rospy.Publisher('/mobile_base/commands/chest_leds', ChestLeds, queue_size=10) l = ChestLeds() for i in range(len(l.leds)): l.leds[i].red = r l.leds[i].green = g l.leds[i].blue = b pub.publish(l)
def white(): pub = rospy.Publisher('/mobile_base/commands/chest_leds', ChestLeds, queue_size=10) l = ChestLeds() for i in range(len(l.leds)): l.leds[i].red = 255 l.leds[i].green = 255 l.leds[i].blue = 255 pub.publish(l)
def put_pixels(self, pixels): """ set the LEDs to the values in pixels. :param pixels: an array of 3-ary tuples """ self._last_pixels = pixels msg = ChestLeds() for i in range(15): msg.leds[i].red = pixels[i][0] msg.leds[i].green = pixels[i][1] msg.leds[i].blue = pixels[i][2] seconds = rospy.get_time() while rospy.get_time() - seconds < 1: self._light_pub.publish(msg)
def lights(): pub = rospy.Publisher('/denise/mobile_base/commands/chest_leds', ChestLeds, queue_size=10) rospy.init_node('lights', anonymous=False) light = ChestLeds() rate = rospy.Rate(10) while not rospy.is_shutdown(): for i in range(len(light.leds)): light.leds[i].red = 255 light.leds[i].green = 0 light.leds[i].blue = 0 rospy.loginfo(light) pub.publish(light) rate.sleep()
def all_leds(self, color): # TODO: Turn all LEDS to `color` msg = ChestLeds() for i in range(15): msg.leds[i].red = color[0] msg.leds[i].green = color[1] msg.leds[i].blue = color[2] pub = rospy.Publisher('/mobile_base/commands/chest_leds', ChestLeds, queue_size=10) seconds = rospy.get_time() while rospy.get_time() - seconds < 0.1: pub.publish(msg) pass
def put_pixels(self, pixels): """ set the LEDs to the values in pixels. :param pixels: an array of 3-ary tuples """ self._last_pixels = list(pixels) msg = ChestLeds() for x in range(15): msg.leds[x].red = int(self._last_pixels[x][0]) msg.leds[x].green = int(self._last_pixels[x][1]) msg.leds[x].blue = int(self._last_pixels[x][2]) start_time = rospy.Time.now() while rospy.Time.now() - start_time < rospy.Duration(0.25): self._light_pub.publish(msg)
def rainbow(frequency1, frequency2, frequency3, phase1, phase2, phase3): pub = rospy.Publisher('/mobile_base/commands/chest_leds', ChestLeds, queue_size=10) rospy.init_node('kuri_light') rate = rospy.Rate(100) l = ChestLeds() print("kuri rainbow working") center = 128 width = 127 length = 50 for i in range(length): for p in range(len(l.leds)): l.leds[p].red = math.sin(frequency1 * i + phase1) * width + center l.leds[p].green = math.sin(frequency2 * i + phase2) * width + center l.leds[p].blue = math.sin(frequency3 * i + phase3) * width + center pub.publish(l) time.sleep(0.1)
def rainbow(frequency1, frequency2, frequency3, phase1, phase2, phase3): pub = rospy.Publisher('/mobile_base/commands/chest_leds', ChestLeds, queue_size=10) l = ChestLeds() global rainbowShouldBeRunning center = 128 width = 127 length = 50 print("potato3") for i in range(length): if (not rainbowShouldBeRunning): print("Stopping rainbow") break for p in range(len(l.leds)): l.leds[p].red = math.sin(frequency1 * i + phase1) * width + center l.leds[p].green = math.sin(frequency2 * i + phase2) * width + center l.leds[p].blue = math.sin(frequency3 * i + phase3) * width + center pub.publish(l) time.sleep(0.1) rainbowShouldBeRunning = False