Esempio n. 1
0
 def notifyOperator(self, message, use_uplink=True, use_speak=True):
   """Helper to communicate with the operator by uplink and/or
   synthesized voice"""
   if use_uplink:
     utils.outputToOperator(message, self.uplink)
   if use_speak:
     self.cellbot.speak(message)
Esempio n. 2
0
 def notifyOperator(self, message, use_uplink=True, use_speak=True):
     """Helper to communicate with the operator by uplink and/or
 synthesized voice"""
     if use_uplink:
         utils.outputToOperator(message, self.uplink)
     if use_speak:
         self.cellbot.speak(message)
Esempio n. 3
0
def robotProtoFactory(config, downlink):
  """Consult the configuration to determine which robot protocol to
  instantiate, and return it"""
  if config.microcontroller == "arduino":
    robotProto = avrRobotProtocol.AVRAsciiRobotProtocol(downlink)
  elif config.microcontroller == "icreate":
    robotProto = icreaterobotprotocol.ICreateRobotProtocol(downlink)
  else:
    utils.outputToOperator("ERROR: No robot protocol for microcontroller %s" %
                           config.microcontroller)
    sys.exit()
  return robotProto
Esempio n. 4
0
def cellbotFactory(config, robotProto):
  """Consult the configuration to determine which cellbot to
  instantiate, and return it"""
  if config.microcontroller == "arduino":
    cellbot = avrCellBot.AVRCellBot(config, robotProto)
  elif config.microcontroller == "icreate":
    cellbot = icreatecellbot.ICreateBot(config, robotProto)
  else:
    utils.outputToOperator("ERROR: No cellbot for microcontroller %s" %
                           config.microcontroller)
    sys.exit()
  return cellbot
Esempio n. 5
0
def cellbotFactory(config, robotProto):
    """Consult the configuration to determine which cellbot to
  instantiate, and return it"""
    if config.microcontroller == "arduino":
        cellbot = avrCellBot.AVRCellBot(config, robotProto)
    elif config.microcontroller == "icreate":
        cellbot = icreatecellbot.ICreateBot(config, robotProto)
    else:
        utils.outputToOperator("ERROR: No cellbot for microcontroller %s" %
                               config.microcontroller)
        sys.exit()
    return cellbot
Esempio n. 6
0
def selectConfigFile(configDir):
  iniFiles = glob.glob(os.path.join(configDir, "*.ini"))
  if len(iniFiles) < 1:
    utils.outputToOperator("ERROR: No config files found in %s!\n" % configDir)
    sys.exit()
  if len(iniFiles) == 1:
    return iniFiles[0]
  else:
    configFile = utils.pickFromList(droid, "Choose a config file to use",
        [os.path.basename(file) for file in iniFiles])
    configFile = os.path.join(configDir, configFile)
    utils.outputToOperator("Using config file %s.\n" % configFile)
    return configFile
Esempio n. 7
0
def robotProtoFactory(config, downlink):
    """Consult the configuration to determine which robot protocol to
  instantiate, and return it"""
    if config.microcontroller == "arduino":
        robotProto = avrRobotProtocol.AVRAsciiRobotProtocol(downlink)
    elif config.microcontroller == "icreate":
        robotProto = icreaterobotprotocol.ICreateRobotProtocol(downlink)
    else:
        utils.outputToOperator(
            "ERROR: No robot protocol for microcontroller %s" %
            config.microcontroller)
        sys.exit()
    return robotProto
Esempio n. 8
0
def startRobot(config, uplink):
  utils.outputToOperator("Send the letter 'q' or say 'quit' to exit the " +
                         "program.\n")

  # Call factories to instantiate instances for each layer based on
  # the config, and wire them together.
  downlink = downlinks.downlinkFactory(config)
  robotProto = robotProtoFactory(config, downlink)
  cellbot = cellbotFactory(config, robotProto)
  dispatch = commandTranslator.commandTranslator(config, uplink, cellbot)

  # Register an operator command callback with the uplink and start it
  uplink.SetCommandParser(dispatch.Parse)
  uplink.start()
Esempio n. 9
0
def startRobot(config, uplink):
    utils.outputToOperator("Send the letter 'q' or say 'quit' to exit the " +
                           "program.\n")

    # Call factories to instantiate instances for each layer based on
    # the config, and wire them together.
    downlink = downlinks.downlinkFactory(config)
    robotProto = robotProtoFactory(config, downlink)
    cellbot = cellbotFactory(config, robotProto)
    dispatch = commandTranslator.commandTranslator(config, uplink, cellbot)

    # Register an operator command callback with the uplink and start it
    uplink.SetCommandParser(dispatch.Parse)
    uplink.start()
Esempio n. 10
0
def selectConfigFile(configDir):
    iniFiles = glob.glob(os.path.join(configDir, "*.ini"))
    if len(iniFiles) < 1:
        utils.outputToOperator("ERROR: No config files found in %s!\n" %
                               configDir)
        sys.exit()
    if len(iniFiles) == 1:
        return iniFiles[0]
    else:
        configFile = utils.pickFromList(
            droid, "Choose a config file to use",
            [os.path.basename(file) for file in iniFiles])
        configFile = os.path.join(configDir, configFile)
        utils.outputToOperator("Using config file %s.\n" % configFile)
        return configFile