def micHandler(command, args): global old_mic_vol global mic_vol if extended_command.is_authed(args['sender']) == 2: # Owner if len(command) > 1: if command[1] == 'mute': networking.sendChatMessage(".Warning: Mute may not actually mute mic, use .audio stop to ensure mute") # Mic Mute old_mic_vol = mic_vol mic_vol = 0 elif command[1] == 'unmute': # Mic Unmute mic_vol = old_mic_vol elif command[1] == 'vol': try: new_vol = int(command[2]) except ValueError: log.debug("Not a valid volume level %s" % command[2]) mic_vol = new_vol % 101 log.info("Setting volume to %d" % mic_vol) os.system("amixer -c {} sset 'Mic' '{}%'".format(audio_hw_num, mic_vol)) networking.sendChatMessage(".mic volume is %s" % mic_vol)
def update_handler(command, args): global update_available if extended_command.is_authed(args['sender']) == 2: if len(command) == 1: # just .update if not update_available: if checkForUpdates(): robot_util.sendChatMessage( "{} updates available. Send '.update yes' to apply updates." .format(update_available)) else: robot_util.sendChatMessage( "Robot is already up to date. Nothing to do!") else: robot_util.sendChatMessage( "{} updates available. Send '.update yes' to apply updates." .format(update_available)) else: if command[1] == "yes": if checkLocalChanges(): if doUpdate(): update_fetched = False robot_util.sendChatMessage( 'Update completed. Restart for changes to take effect.' ) else: robot_util.sendChatMessage( 'Update Failed. run "git pull" locally to determine error.' ) else: robot_util.sendChatMessage( 'Automatic Update aborted, you have modified core files.' )
def audioChatHandler(command, args): global audio_process global audio_bitrate global mic_off if len(command) > 1: if extended_command.is_authed(args['sender']) == 2: # Owner if command[1] == 'start': # mic_off = False if audio_process.returncode != None: watchdog.start("FFmpegAudioProcess", startAudioCapture) elif command[1] == 'stop': stopAudioCapture() elif command[1] == 'restart': # mic_off = False stopAudioCapture() watchdog.start("FFmpegAudioProcess", startAudioCapture) elif command[1] == 'bitrate': if len(command) > 1: if len(command) == 3: try: int(command[2]) audio_bitrate = command[2] restartAudioCapture() except ValueError: # Catch someone passing not a number pass networking.sendChatMessage(".Audio bitrate is %s" % audio_bitrate)
def videoChatHandler(command, args): global video_process global video_bitrate if len(command) > 1: if extended_command.is_authed(args['sender']) == 2: # Owner if command[1] == 'start': if not video_process.returncode == None: watchdog.start("FFmpegCameraProcess", startVideoCapture) elif command[1] == 'stop': stopVideoCapture() elif command[1] == 'restart': restartVideoCapture() elif command[1] == 'bitrate': if len(command) > 1: if len(command) == 3: try: int(command[2]) video_bitrate = command[2] restartVideoCapture() except ValueError: # Catch someone passing not a number pass networking.sendChatMessage(".Video bitrate is %s" % video_bitrate) else: networking.sendChatMessge("command only available to owner")
def set_forward_speed(command, args): global forward_speed if extended_command.is_authed(args['sender']) == 2: # Owner if len(command) > 1: try: forward_speed = int(command[1]) print("forward_speed set to : %d" % forward_speed) except ValueError: pass
def set_turn_speed(command, args): global turn_speed if extended_command.is_authed(args['name']) == 2: # Owner if len(command) > 1: try: turn_speed = int(command[1]) print("turn_speed set to : %d" % turn_speed) except ValueError: pass
def saturationChatHandler(command, args): if len(command) > 2: if extended_command.is_authed(args['sender']): # Moderator try: new_saturation = int(command[1]) except ValueError: exit() #not a number if new_saturation <= 255 and new_saturation >= 0: saturation = new_saturation v4l2SetCtrl("saturation", saturation)
def set_volume(command, args): global volume if extended_command.is_authed(args['name']) == 2: # Owner if len(command) > 1: try: tmp = int(command[1]) volume = (tmp % 101) coz.set_robot_volume(volume / 100) print("volume set to : %d" % volume) except ValueError: pass
def brightnessChatHandler(command, args): global brightness if len(command) > 1: if extended_command.is_authed(args['sender']): # Moderator try: new_brightness = int(command[1]) except ValueError: exit() #Not a number if new_brightness <= 255 and new_brightness >= 0: brightness = new_brightness v4l2SetCtrl("brightness", brightness)
def saturationChatHandler(command, args): if len(command) > 2: if extended_command.is_authed(args['sender']): # Moderator try: new_saturation = int(command[1]) except ValueError: exit() #not a number if new_saturation <= 255 and new_saturation >= 0: saturation = new_saturation os.system(v4l2_ctl_location + " --set-ctrl saturation=" + str(saturation)) log.info("saturation set to %.2f" % saturation)
def contrastChatHandler(command, args): global contrast if len(command) > 1: if extended_command.is_authed(args['sender']): # Moderator try: new_contrast = int(command[1]) except ValueError: exit() #not a number if new_contrast <= 255 and new_contrast >= 0: contrast = new_contrast v4l2SetCtrl("contrast", contrast)
def contrastChatHandler(command, args): global contrast if len(command) > 1: if extended_command.is_authed(args['sender']): # Moderator try: new_contrast = int(command[1]) except ValueError: exit() #not a number if new_contrast <= 255 and new_contrast >= 0: contrast = new_contrast os.system(v4l2_ctl_location + " --set-ctrl contrast=" + str(contrast)) log.info("contrast set to %.2f" % contrast)
def brightnessChatHandler(command, args): global brightness if len(command) > 1: if extended_command.is_authed(args['sender']): # Moderator try: new_brightness = int(command[1]) except ValueError: exit() #Not a number if new_brightness <= 255 and new_brightness >= 0: brightness = new_brightness os.system(v4l2_ctl_location + " --set-ctrl brightness=" + str(brightness)) log.info("brightness set to %.2f" % brightness)
def set_stay_on_dock(command, args): global stay_on_dock if extended_command.is_authed(args['name']) == 2: # Owner if len(command) > 1: try: if command[1] == "on": stay_on_dock = 1 elif command[1] == "off": stay_on_dock = 0 print("stay_on_dock set to : %d" % stay_on_dock) except ValueError: pass
def set_charging(command, args): global charging global low_battery if extended_command.is_authed(args['name']) == 2: # Owner if len(command) > 1: try: if command[1] == "on": low_battery = 1 if coz.is_on_charger: charging = 1 elif command[1] == "off": low_battery = 0 charging = 0 print("charging set to : %d" % charging) networking.sendChargeState(charging) except ValueError: pass
def HUDChatHandler(command, args): global hud_correct global hud_correct_x global hud_correct_y if len(command) > 3: if extended_command.is_authed(args['name']): # Moderator if command[1] == 'correct': try: new_x_res = int(command[2]) new_y_res = int(command[3]) except ValueError: return #Not a number log.info("correcting HUD resolution to %dx%d", new_x_res, new_y_res) hud_correct_x = new_x_res hud_correct_y = new_y_res hud_correct = True
def autodock(command, args): if extended_command.is_authed(args['name']) == 2: autodocking.drive_to_charger(coz, 5)
def set_colour(command, args): global colour if extended_command.is_authed(args['name']) == 2: colour = not colour coz.camera.color_image_enabled = colour
def restart_controller(command, args): if extended_command.is_authed(args['name']) == 2: # Owner terminate.acquire()
def set_sleep_time(command, args): global sleeptime if extended_command.is_authed(args['name']) == 2: # Owner if len(command) > 1: sleeptime = float(command[1]) log.info("sleep time set to : %d", float(command[2]))
def set_rotate_time(command, args): global rotatetimes if extended_command.is_authed(args['name']) == 2: # Owner if len(command) > 1: rotatetimes = float(command[1]) log.info("rotate time multiplier set to : %d", float(command[1]))
def gohome(command, args): if extended_command.is_authed(args['name']) == 2: autodocking.return_to_charger(coz)
def set_flipped(command, args): global flipped if extended_command.is_authed(args['name']) == 2: flipped = not flipped
def set_annotated(command, args): global annotated if extended_command.is_authed(args['name']) == 2: annotated = not annotated