예제 #1
0
def setupSocketIO(robot_config):
    global controlHostPort
    global chatHostPort
    global infoServer
    global robot_id
    global no_chat_server
    global secure_cert
    global debug_messages

    debug_messages = robot_config.getboolean('misc', 'debug_messages')
    robot_id = robot_config.getint('robot', 'robot_id')
    infoServer = robot_config.get('misc', 'info_server')
    no_chat_server = robot_config.getboolean('misc', 'no_chat_server')
    secure_cert = robot_config.getboolean('misc', 'secure_cert')

    controlHostPort = getControlHostPort()
    chatHostPort = getChatHostPort()
    schedule.repeat_task(60, identifyRobot_task)

    if debug_messages:
        print("using socket io to connect to control", controlHostPort)
        print("using socket io to connect to chat", chatHostPort)

    if robot_config.getboolean('misc', 'check_internet'):
        #schedule a task to check internet status
        schedule.task(robot_config.getint('misc', 'check_freq'),
                      internetStatus_task)
예제 #2
0
def setupSocketIO(robot_config):
    global infoServer
    global apiServer

    global controlHostPort
    global chatHostPort
    global videoPort
    global audioPort

    global robot_id
    global camera_id

    global no_chat_server
    global secure_cert

    global messengerEnable
    global messengerHost
    global messengerPort
    global messengerName
    global messengerUsername
    global messengerPassword
    global bootMessage

    robot_id = robot_config.get('robot', 'robot_id')
    camera_id = robot_config.getint('robot', 'camera_id')
    infoServer = robot_config.get('misc', 'info_server')
    apiServer = robot_config.get('misc', 'api_server')
    no_chat_server = robot_config.getboolean('misc', 'no_chat_server')
    secure_cert = robot_config.getboolean('misc', 'secure_cert')

    messengerEnable = robot_config.get('messenger', 'enable')
    messengerHost = robot_config.get('messenger', 'host')
    messengerPort = robot_config.getint('messenger', 'port')
    messengerUsername = robot_config.get('messenger', 'username')
    messengerPassword = robot_config.get('messenger', 'password')
    messengerName = robot_config.get('messenger', 'robot_name')

    bootMessages = robot_config.get('tts', 'boot_message')
    bootMessageList = bootMessages.split(',')
    bootMessage = random.choice(bootMessageList)

    controlHostPort = getControlHostPort()
    chatHostPort = getChatHostPort()
    videoPort = getVideoPort()
    audioPort = getAudioPort()

    schedule.repeat_task(60, identifyRobot_task)

    log.info("using socket io to connect to control %s", controlHostPort)
    log.info("using socket io to connect to chat %s", chatHostPort)
    log.info("using video port %d" % videoPort)
    log.info("using audio port %d" % audioPort)

    if robot_config.getboolean('misc', 'check_internet'):
        #schedule a task to check internet status
        schedule.task(robot_config.getint('misc', 'check_freq'),
                      internetStatus_task)
예제 #3
0
def setup(robot_config):
    global camera_id
    global infoServer
    global video_port
    global annotated
    global colour

    camera_id = robot_config.get('robot', 'camera_id')
    infoServer = robot_config.get('misc', 'info_server')
    video_port = getVideoPort()
    cozmo.setup_basic_logging()
    cozmo.robot.Robot.drive_off_charger_on_connect = False

    extended_command.add_command('.annotate', set_annotated)
    extended_command.add_command('.autodock', autodock)
    extended_command.add_command('.color', set_colour)
    extended_command.add_command('.colour', set_colour)

    try:
        thread.start_new_thread(cozmo.run_program, (run, ))


#        thread.start_new_thread(cozmo.run_program, (run,), {'use_3d_viewer':True})
    except KeyboardInterrupt as e:
        pass
    except cozmo.ConnectionError as e:
        sys.exit("A connection error occurred: %s" % e)

    while not coz:
        try:
            time.sleep(0.5)
            print("not coz")
        except (KeyboardInterrupt, SystemExit):
            sys.exit()

    if robot_config.has_section('cozmo'):
        send_online_status = robot_config.getboolean('cozmo',
                                                     'send_online_status')
        annotated = robot_config.getboolean('cozmo', 'annotated')
        colour = robot_config.getboolean('cozmo', 'colour')
    else:
        send_online_status = True

    if send_online_status:
        print("Enabling online status")
        schedule.repeat_task(10, updateServer)
예제 #4
0
def setup(robot_config):
    global serialDevice
    global serialBaud

    serialDevice = robot_config.get('serial', 'serial_device')
    serialBaud = robot_config.getint('serial', 'baud_rate')

    if robot_config.has_option('serial', 'serial_name'):
        deviceName = robot_config.get('serial', 'serial_name')
        device = searchSerial(deviceName)
        if device != None:
            serialDevice = device
            log.info("Serial port named {} found at {}".format(
                deviceName, device))
        else:
            log.info("Serial port named {} NOT FOUND".format(deviceName))

    connectSerial(serialDevice, serialBaud)

    if ser is None:
        log.critical("error: could not connect to any valid serial port")
        robot_util.terminate_controller()

    schedule.repeat_task(0.4, flushSerial)