def internetStatus_task(): global lastInternetStatus internetStatus = isInternetConnected() if internetStatus != lastInternetStatus: if internetStatus: tts.say("ok") else: tts.say("missing internet connection") lastInternetStatus = internetStatus
def internetStatus_task(): global bootMessage global lastInternetStatus internetStatus = isInternetConnected() if internetStatus != lastInternetStatus: if internetStatus: tts.say(bootMessage) log.info("internet connected") else: log.info("missing internet connection") tts.say("missing internet connection") lastInternetStatus = internetStatus
def move(args): global charging global coz global is_headlight_on global low_battery command = args['command'] try: if coz.is_on_charger and not charging: if low_battery: print("Started Charging") charging = 1 else: if not stay_on_dock: coz.drive_off_charger_contacts().wait_for_completed() if command == 'F': #causes delays #coz.drive_straight(distance_mm(10), speed_mmps(50), False, True).wait_for_completed() coz.drive_wheels(forward_speed, forward_speed, forward_speed * 4, forward_speed * 4) time.sleep(0.7) coz.drive_wheels(0, 0, 0, 0) elif command == 'B': #causes delays #coz.drive_straight(distance_mm(-10), speed_mmps(50), False, True).wait_for_completed() coz.drive_wheels(-forward_speed, -forward_speed, -forward_speed * 4, -forward_speed * 4) time.sleep(0.7) coz.drive_wheels(0, 0, 0, 0) elif command == 'L': #causes delays #coz.turn_in_place(degrees(15), False).wait_for_completed() coz.drive_wheels(-turn_speed, turn_speed, -turn_speed * 4, turn_speed * 4) time.sleep(0.5) coz.drive_wheels(0, 0, 0, 0) elif command == 'R': #causes delays #coz.turn_in_place(degrees(-15), False).wait_for_completed() coz.drive_wheels(turn_speed, -turn_speed, turn_speed * 4, -turn_speed * 4) time.sleep(0.5) coz.drive_wheels(0, 0, 0, 0) #move lift elif command == 'W': coz.set_lift_height(height=1).wait_for_completed() elif command == 'S': coz.set_lift_height(height=0).wait_for_completed() #look up down #-25 (down) to 44.5 degrees (up) elif command == 'A': #head_angle_action = coz.set_head_angle(degrees(0)) #clamped_head_angle = head_angle_action.angle.degrees #head_angle_action.wait_for_completed() coz.move_head(-1.0) time.sleep(0.35) coz.move_head(0) elif command == 'Q': #head_angle_action = coz.set_head_angle(degrees(44.5)) #clamped_head_angle = head_angle_action.angle.degrees #head_angle_action.wait_for_completed() coz.move_head(1.0) time.sleep(0.35) coz.move_head(0) #toggle light elif command == 'V': print("cozmo light was ", is_headlight_on) is_headlight_on = not is_headlight_on coz.set_head_light(enable=is_headlight_on) time.sleep(0.35) #animations from example elif command.isdigit(): coz.play_anim(name=default_anims_for_keys[int( command)]).wait_for_completed() #things to say with TTS disabled elif command == 'sayhi': tts.say("hi! I'm cozmo!") elif command == 'saywatch': tts.say("watch this") elif command == 'saylove': tts.say("i love you") elif command == 'saybye': tts.say("bye") elif command == 'sayhappy': tts.say("I'm happy") elif command == 'saysad': tts.say("I'm sad") elif command == 'sayhowru': tts.say("how are you?") #cube controls elif command == "lightcubes": print("lighting cubes") light_cubes(coz) elif command == "dimcubes": print("dimming cubes") dim_cubes(coz) #sing song example elif command == "singsong": print("singing song") sing_song(coz) except cozmo.exceptions.RobotBusy: return False
def reportNeedToCharge(): if not isCharging(): if chargeValue <= 25: tts.say("need to charge")
def reportBatteryStatus_task(): if chargeValue < 30: tts.say("battery low, %d percent" % int(chargeValue))