Пример #1
0
def handle_goto_execute_command(req):
    global atom_list_memory
    log_to_terminal("Processing command frame: %s target: %s" %
                    (req.frame, req.target))

    if req.frame == "CLOSEST":
        target_atom_list = ground_request(req.frame, atom_list_memory)
    else:
        target_atom_list = ground_request(req.frame, req.target)

    log_to_terminal("retrieved target atom list: %s" % target_atom_list)

    # implementing the contextual memory in the robot.
    # Example: if I say "go to the socket near the closet" but the robot knows two sockets with that property,
    # the next specification should remember the previous commands
    # so if I now tell the robot to go to the socket near the window it should understand
    # that I am referring to one of the sockets that were near the closet
    if atom_list_memory != []:
        for i in xrange(len(target_atom_list)):
            if not target_atom_list[i] in atom_list_memory:
                target_atom_list.pop(i)

    log_to_terminal("filtered target atom list: %s" % target_atom_list)

    if (len(target_atom_list) == 0):
        event = "GoToGroundUnknown_I do not know any object of that kind"
        response = "None"
        atom_list_memory = []

    elif (len(target_atom_list) == 1):
        target_type, target_category = get_target_type(target_atom_list[0])
        if (target_category == "object"):
            target_pos = get_pos_in_front_of_target(target_atom_list[0])
        else:
            target_pos = get_nearest_cell_in_room(target_atom_list[0])

        if is_robot_already_there(target_pos, target_category,
                                  target_atom_list[0]):
            event = "GoToGroundAlreadyThere_I am already there"
            response = "None"
            atom_list_memory = []
        else:
            event = "GoToGroundSingle_%s_%s_%s_%s" % (
                target_type, target_pos[0], target_pos[1], target_pos[2])
            response = "Single" + "_" + target_type
            atom_list_memory = []

    else:
        target_type, target_category = get_target_type(target_atom_list[0])
        event = "GoToGroundMultiple_I know %s %ss in the environment. Which one do you mean?" % (
            len(target_atom_list), target_type)
        response = "Multiple" + "_" + target_type
        atom_list_memory = target_atom_list

    event_pub.publish(event)
    log_to_terminal("Sent event: " + event)
    return GroundCommandResponse(response)
def handle_goto_execute_command(req):   
    global atom_list_memory
    log_to_terminal("Processing command frame: %s target: %s"%(req.frame, req.target))
    
    if req.frame == "CLOSEST":
      target_atom_list = ground_request(req.frame, atom_list_memory)
    else:
      target_atom_list = ground_request(req.frame, req.target)
    
    log_to_terminal("retrieved target atom list: %s"%target_atom_list)
    
    # implementing the contextual memory in the robot.
    # Example: if I say "go to the socket near the closet" but the robot knows two sockets with that property,
    # the next specification should remember the previous commands
    # so if I now tell the robot to go to the socket near the window it should understand
    # that I am referring to one of the sockets that were near the closet
    if atom_list_memory != []:
      for i in xrange(len(target_atom_list)):
        if not target_atom_list[i] in atom_list_memory:
          target_atom_list.pop(i)
          
    log_to_terminal("filtered target atom list: %s"%target_atom_list)
    
    if (len(target_atom_list) == 0):
      event = "GoToGroundUnknown_I do not know any object of that kind"
      response = "None"
      atom_list_memory = []
    
    elif (len(target_atom_list) == 1):
      target_type, target_category = get_target_type(target_atom_list[0])
      if (target_category == "object"):
        target_pos = get_pos_in_front_of_target(target_atom_list[0])
      else:
        target_pos = get_nearest_cell_in_room(target_atom_list[0])
        
      if is_robot_already_there(target_pos, target_category, target_atom_list[0]):
        event = "GoToGroundAlreadyThere_I am already there"
        response = "None"
        atom_list_memory = []
      else:
        event = "GoToGroundSingle_%s_%s_%s_%s"%(target_type, target_pos[0], target_pos[1], target_pos[2])
        response = "Single"+"_"+target_type
        atom_list_memory = []
  
    else:
      target_type, target_category = get_target_type(target_atom_list[0])
      event = "GoToGroundMultiple_I know %s %ss in the environment. Which one do you mean?"%(len(target_atom_list),target_type)
      response = "Multiple"+"_"+target_type
      atom_list_memory = target_atom_list
      
    event_pub.publish(event)
    log_to_terminal("Sent event: " + event)
    return GroundCommandResponse(response)
Пример #3
0
def handle_forget_execute_command(req):
    log_to_terminal("Processing command frame: %s target: %s" %
                    (req.frame, req.target))

    target_atom_list = ground_request(req.frame, req.target)

    if (len(target_atom_list) == 0):
        event = "ForgetGroundUnknown_I do not know any object of that kind"
        response = "None"

    elif (len(target_atom_list) == 1):
        target_type = get_target_type(target_atom_list[0])
        event = "ForgetGroundSingle_%s_%s" % (target_atom_list[0].replace(
            "_", "#"), target_type)
        response = "Single" + "_" + target_type

    else:
        target_type = get_target_type(target_atom_list[0])
        event = "ForgetGroundMultiple_I know %s %ss in the environment. Which one do you mean?" % (
            len(target_atom_list), target_type)
        response = "Multiple" + "_" + target_type

    event_pub.publish(event)
    log_to_terminal("Sent event: " + event)
    return GroundCommandResponse(response)
Пример #4
0
def handle_forget_execute_command(req):
    global atom_list_memory
    log_to_terminal("Processing command frame: %s target: %s" %
                    (req.frame, req.target))

    target_atom_list = ground_request(req.frame, req.target)

    log_to_terminal("retrieved target atom list: %s" % target_atom_list)

    # implementing the contextual memory in the robot.
    # Example: if I say "go to the socket near the closet" but the robot knows two sockets with that property,
    # the next specification should remember the previous commands
    # so if I now tell the robot to go to the socket near the window it should understand
    # that I am referring to one of the sockets that were near the closet
    if atom_list_memory != []:
        for i in xrange(len(target_atom_list)):
            if not target_atom_list[i] in atom_list_memory:
                target_atom_list.pop(i)

    log_to_terminal("filtered target atom list: %s" % target_atom_list)

    if (len(target_atom_list) == 0):
        event = "GroundAtom_None_None_None_I do not know any object of that kind"
        response = "None"
        atom_list_memory = []

    elif (len(target_atom_list) == 1):
        target_type = get_target_type(target_atom_list[0])
        event = "GroundAtom_Single_%s_%s_None" % (target_atom_list[0].replace(
            "_", "#"), target_type)
        response = "Single" + "_" + target_type
        atom_list_memory = []

    else:
        target_type = get_target_type(target_atom_list[0])
        event = "GroundAtom_Multiple_%s_%s_I know %s %ss in the environment. Which one do you mean?" % (
            target_atom_list[0].replace(
                "_", "#"), target_type, len(target_atom_list), target_type)
        response = "Multiple" + "_" + target_type
        atom_list_memory = target_atom_list

    event_pub.publish(event)
    log_to_terminal("Sent event: " + event)

    log_to_terminal("atom list: %s" % atom_list_memory)

    return GroundCommandResponse(response)
def handle_forget_execute_command(req):    
    global atom_list_memory
    log_to_terminal("Processing command frame: %s target: %s"%(req.frame, req.target))
    
    target_atom_list = ground_request(req.frame, req.target)
    
    log_to_terminal("retrieved target atom list: %s"%target_atom_list)
    
    # implementing the contextual memory in the robot.
    # Example: if I say "go to the socket near the closet" but the robot knows two sockets with that property,
    # the next specification should remember the previous commands
    # so if I now tell the robot to go to the socket near the window it should understand
    # that I am referring to one of the sockets that were near the closet
    if atom_list_memory != []:
      for i in xrange(len(target_atom_list)):
        if not target_atom_list[i] in atom_list_memory:
          target_atom_list.pop(i)
       
    log_to_terminal("filtered target atom list: %s"%target_atom_list)
    
    if (len(target_atom_list) == 0):
      event = "GroundAtom_None_None_None_I do not know any object of that kind"
      response = "None"
      atom_list_memory = []
      
    elif (len(target_atom_list) == 1):
      target_type = get_target_type(target_atom_list[0])    
      event = "GroundAtom_Single_%s_%s_None"%(target_atom_list[0].replace("_","#"), target_type)
      response = "Single"+"_"+target_type
      atom_list_memory = []
      
    else:
      target_type = get_target_type(target_atom_list[0])    
      event = "GroundAtom_Multiple_%s_%s_I know %s %ss in the environment. Which one do you mean?"%(target_atom_list[0].replace("_","#"), target_type, len(target_atom_list), target_type)
      response = "Multiple"+"_"+target_type
      atom_list_memory = target_atom_list
 
    event_pub.publish(event)
    log_to_terminal("Sent event: " + event)
    
    log_to_terminal("atom list: %s"%atom_list_memory)
    
    return GroundCommandResponse(response)
def handle_forget_execute_command(req):    
    log_to_terminal("Processing command frame: %s target: %s"%(req.frame, req.target))
    
    target_atom_list = ground_request(req.frame, req.target)
    
    if (len(target_atom_list) == 0):
      event = "ForgetGroundUnknown_I do not know any object of that kind"
      response = "None"
      
    elif (len(target_atom_list) == 1):
      target_type = get_target_type(target_atom_list[0])    
      event = "ForgetGroundSingle_%s_%s"%(target_atom_list[0].replace("_","#"), target_type)
      response = "Single"+"_"+target_type
      
    else:
      target_type = get_target_type(target_atom_list[0])    
      event = "ForgetGroundMultiple_I know %s %ss in the environment. Which one do you mean?"%(len(target_atom_list),target_type)
      response = "Multiple"+"_"+target_type
 
    event_pub.publish(event)
    log_to_terminal("Sent event: " + event)
    return GroundCommandResponse(response)