def process_lidar(lidar_data): """ process the lidar image """ if not SCHEDULER.is_lidar_enable(): return if SCHEDULER.is_lidar_occupied() or TURTLE.is_occupied(): return state = SCHEDULER.get_state() if SCHEDULER.debug_option["show_timer"] and (state != "construction"): SCHEDULER.check_time("lidar", min=0.4, stop_when_delay=False) set_lidar_values(lidar_data) state = SCHEDULER.get_state() front = get_object_distance("front") if (front < 0.15) and (front > 0): TURTLE.stop() return if state is "default": leftside = get_object_distance("leftside") print(leftside) if (leftside < 0.35) and (leftside > 0): rospy.Timer(rospy.Duration(5), SCHEDULER.release_lidar_occupied, oneshot=True) SCHEDULER.set_state("to_construction") return elif state is "to_construction": leftside = get_object_distance("leftside") print("to_construction: " + str(leftside)) if (leftside < 0.35) and (leftside > 0): SCHEDULER.set_state("construction") return # rospy.Timer( # rospy.Duration(0.15), SCHEDULER.release_lidar_occupied, oneshot=True # ) # process_construction() elif state is "construction": process_construction() elif state is "parking": process_parking()
def process_lidar(lidar_data): """ process the lidar image """ if not SCHEDULER.is_lidar_enable(): return if SCHEDULER.is_lidar_occupied() or TURTLE.is_occupied(): return state = SCHEDULER.get_state() if SCHEDULER.debug_option["show_timer"] and (state != "construction"): SCHEDULER.check_time("lidar", min=0.4, stop_when_delay=False) set_lidar_values(lidar_data) state = SCHEDULER.get_state() front = get_object_distance("front") if (front < 0.15) and (front > 0): TURTLE.stop() return # if STEP >= 10: # process_parking() # else: # process_construction() # return if state is "intersection_left": left = get_object_distance("left") if (left > 0) and (left < 0.50): TURTLE.set_speed("slow") SCHEDULER.set_state("to_construction") elif state is "to_construction": rospy.Timer(rospy.Duration(0.15), SCHEDULER.release_lidar_occupied, oneshot=True) process_construction_new() elif state is "construction": process_construction_new() elif state is "parking": process_parking() elif state is "tunnel": process_tunnel()