def show_bike_1(): time.sleep(17.0) color = Color_Bike #(0, 0, 255) location = ObjectLocation(5, 25) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 3), 8.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(8.0) get_led_controller().add_animation(spot, 'location', ObjectLocation(135, 10), 3.0) time.sleep(3.0) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(90, 2), 3.333) time.sleep(3.333) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(0, 10), 4.0) time.sleep(4.0 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(35.5) color = Color_People #(237, 183, 21) location = ObjectLocation(80, 10) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(30, 5), 2.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(2.0) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 2), 1.333) time.sleep(1.333) get_led_controller().add_animation(spot, 'location', ObjectLocation(170, 20), 9.666) time.sleep(9.666 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_1(): color = Color_People #(237, 183, 21) location = ObjectLocation(155, 2) spot = LEDSpot((0, 0, 0,), location, 0.75) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(0, 2.0), 8.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(8.0-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_car_1(): time.sleep(40.666) color = Color_Car #(255, 255, 255) location = ObjectLocation(-45, 3) spot = LEDSpot((0, 0, 0,), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(0, 3.0), 3.333) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(3.333-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(8.433) color = Color_People #(237, 183, 21) location = ObjectLocation(45, 10) spot = LEDSpot((0, 0, 0,), location, 2.0) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 5.0), 4.5) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(4.5-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(1.5) color = Color_People #(237, 183, 21) location = ObjectLocation(-10, 3.0) spot = LEDSpot((0, 0, 0,), location, 0.75) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(180, 2.0), 9.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(9.0-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_1(): time.sleep(5.0) color = Color_People #(237, 183, 21) location = ObjectLocation(355, 25) spot = LEDSpot((0, 0, 0,), location, 2.25) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 2.0), 11.666) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(11.666) get_led_controller().add_animation(spot, 'location', ObjectLocation(160, 5.0), 2.333) time.sleep(2.333-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(26.0) color = Color_People #(237, 183, 21) location = ObjectLocation(-45, 8.0) spot = LEDSpot((0, 0, 0,), location, 2.25) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 2.0), 5.5) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(5.5) get_led_controller().add_animation(spot, 'location', ObjectLocation(160, 8), 2.0) time.sleep(2.0-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_bike_1(): time.sleep(33.0) color = Color_Bike #(255, 0, 0) location = ObjectLocation(-30, 15) spot = LEDSpot((0, 0, 0,), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 2.0), 4.666) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(4.666) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-160, 10), 1.333-0.5) time.sleep(1.333-0.5-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_car_1(): time.sleep(34.166) color = Color_Car #(255, 0, 0) location = ObjectLocation(10, 10) spot = LEDSpot((0, 0, 0,), location, 2.0) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 2.0), 6.166) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(6.166) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-160, 10.0), 2.333) time.sleep(2.333-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_1(): time.sleep(1.0) color = Color_People #(237, 183, 21) location = ObjectLocation(-30, 15) spot = LEDSpot((0, 0, 0,), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 5), 5.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(5.0) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-190, 15), 5.0) time.sleep(5.0-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_car_1(): time.sleep(15.0) color = Color_Car #(255, 0, 0) location = ObjectLocation(-30, 25) spot = LEDSpot((0, 0, 0,), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 3), 2.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(2.0) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-150, 25), 2.0) time.sleep(2.0-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_bike_2(): time.sleep(35.5) color = Color_Bike #(0, 0, 255) location = ObjectLocation(45, 10) spot = LEDSpot((0, 0, 0,), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 2), 2.333) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(2.333) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-170, 25), 10.666) time.sleep(10.666-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(35.5) color = Color_People #(237, 183, 21) location = ObjectLocation(80, 10) spot = LEDSpot((0, 0, 0,), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(30, 5), 2.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(2.0) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 2), 1.333) time.sleep(1.333) get_led_controller().add_animation(spot, 'location', ObjectLocation(170, 20), 9.666) time.sleep(9.666-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_bike_1(): time.sleep(17.0) color = Color_Bike #(0, 0, 255) location = ObjectLocation(5, 25) spot = LEDSpot((0, 0, 0,), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 3), 8.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(8.0) get_led_controller().add_animation(spot, 'location', ObjectLocation(135, 10), 3.0) time.sleep(3.0) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(90, 2), 3.333) time.sleep(3.333) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(0, 10), 4.0) time.sleep(4.0-0.5) get_led_controller().add_animation(spot, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_1(): color = Color_People #(237, 183, 21) location = ObjectLocation(15, 20) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-45, 10.0), 10.166) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(10.166 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(1.5) color = Color_People #(237, 183, 21) location = ObjectLocation(-10, 3.0) spot = LEDSpot(( 0, 0, 0, ), location, 0.75) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(180, 2.0), 9.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(9.0 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_car_1(): time.sleep(40.666) color = Color_Car #(255, 255, 255) location = ObjectLocation(-45, 3) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(0, 3.0), 3.333) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(3.333 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(8.433) color = Color_People #(237, 183, 21) location = ObjectLocation(45, 10) spot = LEDSpot(( 0, 0, 0, ), location, 2.0) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 5.0), 4.5) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(4.5 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def toggle_working_light_back_right(activate): global working_light_led_back_right if activate: if working_light_led_back_right is None: color = (237, 183, 21) location = ObjectLocation(135, 90) working_light_led_back_right = LEDSpot(color, location, 120) print "show working light br" get_led_controller().add_symbol(working_light_led_back_right) else: if working_light_led_back_right is not None: get_led_controller().remove_symbol(working_light_led_back_right) working_light_led_back_right = None
def show_ped_1(): time.sleep(1.0) color = Color_People #(237, 183, 21) location = ObjectLocation(-30, 15) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 5), 5.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(5.0) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-190, 15), 5.0) time.sleep(5.0 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_car_1(): time.sleep(15.0) color = Color_Car #(255, 0, 0) location = ObjectLocation(-30, 25) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 3), 2.0) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(2.0) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-150, 25), 2.0) time.sleep(2.0 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_bike_1(): time.sleep(33.0) color = Color_Bike #(255, 0, 0) location = ObjectLocation(-30, 15) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 2.0), 4.666) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(4.666) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-160, 10), 1.333 - 0.5) time.sleep(1.333 - 0.5 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_2(): time.sleep(26.0) color = Color_People #(237, 183, 21) location = ObjectLocation(-45, 8.0) spot = LEDSpot(( 0, 0, 0, ), location, 2.25) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 2.0), 5.5) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(5.5) get_led_controller().add_animation(spot, 'location', ObjectLocation(160, 8), 2.0) time.sleep(2.0 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_ped_1(): time.sleep(5.0) color = Color_People #(237, 183, 21) location = ObjectLocation(355, 25) spot = LEDSpot(( 0, 0, 0, ), location, 2.25) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location', ObjectLocation(90, 2.0), 11.666) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(11.666) get_led_controller().add_animation(spot, 'location', ObjectLocation(160, 5.0), 2.333) time.sleep(2.333 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_car_1(): time.sleep(34.166) color = Color_Car #(255, 0, 0) location = ObjectLocation(10, 10) spot = LEDSpot(( 0, 0, 0, ), location, 2.0) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 2.0), 6.166) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(6.166) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-160, 10.0), 2.333) time.sleep(2.333 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def show_bike_2(): time.sleep(35.5) color = Color_Bike #(0, 0, 255) location = ObjectLocation(45, 10) spot = LEDSpot(( 0, 0, 0, ), location, 2) get_led_controller().add_symbol(spot) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-90, 2), 2.333) get_led_controller().add_animation(spot, 'color', color, 0.5) time.sleep(2.333) get_led_controller().add_animation(spot, 'location_r', ObjectLocation(-170, 25), 10.666) time.sleep(10.666 - 0.5) get_led_controller().add_animation(spot, 'color', ( 0, 0, 0, ), 0.5) time.sleep(0.5) spot.dead = True
def play_start_sequence(): color = (255, 226, 64) location_1 = ObjectLocation(-179, 15) spot_1 = LEDSpot((0, 0, 0,), location_1, 2) location_2 = ObjectLocation(179, 15) spot_2 = LEDSpot((0, 0, 0,), location_2, 2) final_radius = 75 get_led_controller().add_symbol(spot_1) get_led_controller().add_symbol(spot_2) get_led_controller().add_animation(spot_1, 'color', color, 0.5) get_led_controller().add_animation(spot_2, 'color', color, 0.5) get_led_controller().add_animation(spot_1, 'location', ObjectLocation(-45, 15), 2.5) get_led_controller().add_animation(spot_2, 'location_r', ObjectLocation(45, 15), 2.5) time.sleep(0.5) get_led_controller().add_animation(spot_1, 'radius', final_radius, 2.0) get_led_controller().add_animation(spot_2, 'radius', final_radius, 2.0) time.sleep(2.0) get_led_controller().add_animation(spot_1, 'color', (0, 0, 0,), 0.5) get_led_controller().add_animation(spot_2, 'color', (0, 0, 0,), 0.5) time.sleep(0.5) spot_1.dead = True spot_2.dead = True
def run(self): NUMBER_OF_VALUES = 99 NUMBER_OF_MINIMUM_VALUES_PER_AREA = 10 lidar = lidarModule.Lidar() # values = [] spots = [] for i in range(NUMBER_OF_VALUES): # values.append([]) spots.append({ 'active': False, 'spot': LEDSpot(Color_Bike, ObjectLocation(i * 1.8 - 10.0, 2), 0.3) }) # stepNumber, distance = lidar.getData() # while stepNumber <> 0: # stepNumber, distance = lidar.getData() # print '### Step is at 0 now ###' minStepDist = [ 290, 290, 290, 290, 290, 290, 290, 290, 291, 291, 292, 294, 295, 297, 300, 271, 241, 217, 197, 180, 166, 154, 144, 135, 128, 121, 115, 109, 104, 100, 96, 92, 89, 86, 83, 81, 79, 77, 75, 73, 71, 70, 69, 67, 66, 65, 64, 64, 63, 62, 62, 61, 61, 61, 60, 60, 60, 60, 60, 60, 60, 61, 61, 61, 62, 62, 63, 64, 64, 65, 66, 67, 69, 70, 71, 73, 75, 77, 79, 81, 83, 86, 89, 92, 96, 100, 104, 109, 115, 121, 128, 135, 144, 154, 166, 180, 224, 224, 224 ] maxStepDist = [ 450, 450, 470, 500, 600, 600, 610, 620, 610, 610, 600, 590, 590, 570, 560, 560, 560, 560, 560, 560, 560, 560, 550, 540, 540, 540, 540, 540, 550, 550, 570, 560, 560, 560, 550, 550, 550, 540, 550, 540, 550, 560, 540, 530, 530, 530, 520, 500, 490, 500, 510, 500, 490, 490, 500, 500, 500, 500, 490, 480, 480, 480, 470, 470, 460, 460, 430, 420, 420, 400, 400, 400, 400, 390, 390, 390, 390, 390, 390, 400, 410, 420, 430, 450, 440, 440, 440, 450, 460, 470, 510, 520, 520, 530, 530, 530, 530, 530, 530 ] lidar.resetDataCount() # values = pickle.load(open("/home/pi/me310-audi-enlight/lidar/scan6MinimumValues", "rb" )) # print '### MIN ###' # print map(np.min, values) # print '### MAX ###' # print map(np.max, values) # print '### STD ###' # print map(np.std, values) # print '###########' # stdValues = map(np.std, values) # minValues = map(np.min, values) while not self.stopped: stepNumber, distance = lidar.getData() if stepNumber == -1: continue if distance >= maxStepDist[stepNumber] or distance <= minStepDist[ stepNumber]: if (spots[stepNumber]['active']): get_led_controller().remove_symbol( spots[stepNumber]['spot']) spots[stepNumber]['active'] = False else: if maxStepDist[stepNumber] - distance > 50: if (not spots[stepNumber]['active']): get_led_controller().add_symbol( spots[stepNumber]['spot']) spots[stepNumber]['active'] = True else: if (spots[stepNumber]['active']): get_led_controller().remove_symbol( spots[stepNumber]['spot']) spots[stepNumber]['active'] = False for spot in spots: get_led_controller().remove_symbol(spot['spot'])