def query_parser(sid, data): logging.info("inside query parser.....") logging.info(data) x = self.get_logical_form(s=data["chat"], model=self.model) logging.info(x) payload = {"action_dict": x} sio.emit("renderActionDict", payload)
def save_command_to_db(sid, postData): print("in save_command_to_db, got postData: %r" % (postData)) # save the command and fetch all out = saveAndFetchCommands(self.conn, postData) if out == "DUPLICATE": print("Duplicate command not saved.") else: print("Saved successfully") payload = {"commandList": out} sio.emit("updateSearchList", payload)
def maybe_dump_memory_to_dashboard(self): if time.time() - self.dashboard_memory_dump_time > MEMORY_DUMP_KEYFRAME_TIME: self.dashboard_memory_dump_time = time.time() memories_main = self.memory._db_read("SELECT * FROM Memories") triples = self.memory._db_read("SELECT * FROM Triples") reference_objects = self.memory._db_read("SELECT * FROM ReferenceObjects") named_abstractions = self.memory._db_read("SELECT * FROM NamedAbstractions") self.dashboard_memory["db"] = { "memories": memories_main, "triples": triples, "reference_objects": reference_objects, "named_abstractions": named_abstractions, } sio.emit("memoryState", self.dashboard_memory["db"])
def log(self, rgb_depth, detections, humans, old_rgb_depth, old_xyz): """Log all relevant data from the perceptual models for the dashboard. All the data here is sent to the dashboard using a socketio emit event. This data is then used by the dashboard for different debugging visualizations. Add any data that you would want to fetch on the dashboard here. Args: rgb_depth (RGBDepth): the current RGBDepth frame. This frame might be different from old_rgb_depth, which is the RGBDepth frame for which SlowPerception has been run detections (list[Detections]): list of all detections humans (list[Human]): list of all humans detected old_rgb_depth (RGBDepth): RGBDepth frame for which detections and humans are being sent. This is the frame for which SlowPerception has been run. old_xyz (list[floats]): the (x,y,yaw) of the robot at the time of old_rgb_depth """ if hasattr(sio, "mock"): return sio.emit("image_settings", self.log_settings) if old_xyz is None: x, y, yaw = self.agent.mover.get_base_pos_in_canonical_coords() else: x, y, yaw = old_xyz resolution = self.log_settings["image_resolution"] quality = self.log_settings["image_quality"] payload = {} payload["time"] = time.time() payload["image"] = rgb_depth.to_struct(resolution, quality) payload["object_image"] = (old_rgb_depth.to_struct( resolution, quality) if old_rgb_depth is not None else -1) payload["objects"] = [x.to_struct() for x in detections ] if detections is not None else [] payload["humans"] = [x.to_struct() for x in humans] if humans is not None else [] payload["x"] = x payload["y"] = y payload["yaw"] = yaw payload["map"] = self.agent.mover.get_obstacles_in_canonical_coords() sio.emit("sensor_payload", payload)
def send_text_command_to_agent(sid, command): """Add the command to agent's incoming chats list and send back the parse. Args: command: The input text command from dashboard player Returns: return back a socket emit with parse of command and success status """ logging.debug( "in send_text_command_to_agent, got the command: %r" % (command)) agent_chat = ( "<dashboard> " + command ) # the chat is coming from a player called "dashboard" self.dashboard_chat = agent_chat dialogue_manager = self.dialogue_manager logical_form = {} status = "" try: logical_form = dialogue_manager.get_logical_form( s=command, model=dialogue_manager.model) logging.debug("logical form is : %r" % (logical_form)) status = "Sent successfully" except: logging.error("error in sending chat") status = "Error in sending chat" # update server memory self.dashboard_memory["chatResponse"][command] = logical_form self.dashboard_memory["chats"].pop(0) self.dashboard_memory["chats"].append({ "msg": command, "failed": False }) payload = { "status": status, "chat": command, "chatResponse": self.dashboard_memory["chatResponse"][command], "allChats": self.dashboard_memory["chats"], } sio.emit("setChatResponse", payload)
def send_chat(self, chat: str): logging.info("Sending chat: {}".format(chat)) # Send the socket event to show this reply on dashboard sio.emit("showAssistantReply", {'agent_reply' : "Agent: {}".format(chat)}) self.memory.add_chat(self.memory.self_memid, chat)
def update_log_settings(sid, new_values): self.log_settings["image_resolution"] = new_values["image_resolution"] self.log_settings["image_quality"] = new_values["image_quality"] sio.emit("image_settings", self.log_settings)
def objects_in_memory(sid): objects = loco_memory.DetectedObjectNode.get_all(self.agent.memory) for o in objects: del o["feature_repr"] self.agent.dashboard_memory["objects"] = objects sio.emit("updateState", {"memory": self.agent.dashboard_memory})
def get_cmds_from_db(sid, postData): print("in get_cmds_from_db, got postData: %r" % (postData)) out = onlyFetchCommands(self.conn, postData["query"]) payload = {"commandList": out} sio.emit("updateSearchList", payload)