-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New form of user input in the visualizer: context menus #154
Comments
A way in which this feature could be implemented: A new function is added to the AgentBrain class: The The function returns a list with menu items, with each menu item containing:
Where this action<->object mapping comes from might be similarly defined to the Furthermore, the The overal flow then could go something like this:
The case for tasking other agents is almost identical, except for that there are 3 variables passed from the visualizer to the API:
The API then calls the This approach has as advantages:
Disadvantages:
@jwaa , what do you think of the approach above? This week is the Co-active teaming sprint, so I want to have it done before the end of the week :) |
@thaije; I like the fact that the user's side is in the Though I also think this is only part of the solution. Things I still miss:
A suggestion: When a certain context menu item is clicked, the frontend returns the menu item's name and the context (who clicked, what was selected, what was clicked upon) and the API finds the appropriate function object based on the agent who clicked and the menu's item name. Next, that function is performed and given the location on which was clicked, the id of what was selected and what was clicked upon (location is given because we cannot garuantee that there is always an ID available, e.g. there might exist none there, or it is not within a agent's state). These functions should return None. This to force people making these functions not to actually return actions or behaviour, but to change the internals of the AgentBrain to do something next tick (e.g. move, pick up, send message, alter property, etc.). An example of this for a context menu containing a "Move to..." and "Pick up...". class MyHumanBrain(HumanAgentBrain):
def __init__():
self.pick_up_obj = None
self.move_to_loc = None
....
def fill_tasking_menu(self, selected_obj_id, target_obj_id)
requester_agent_ID = self.agent_id
context_menu = {
"Move to...": self.context_move_to
"Pick up...": self.context_pick_up
}
def context_move_to(self, clicked_location, target_agent_id, target_obj_id): # MATRX user method
if target_agent_id is None or target_agent_id == self.agent_id):
self.move_to_loc = clicked_location
else:
mssg = Message({"move_to": clicked_location})
self.send_message(to=target_agent_id, message=mssg)
def context_pick_up(self, clicked_location, target_agent_id, target_object_id): # MATRX user method
if target_agent_id is None or target_agent_id == self.agent_id):
self.move_to_loc = location
self.pick_up_obj = target_object_id
else:
mssg = Message({"pick_up": clicked_location, "location": clicked_location})
self.send_message(to=target_agent_id, message=mssg)
def decide_on_action(state):
...
self.parse_context_messages()
action, kwargs = self.handle_context_move_to()
if action is not None:
return action, kwargs
action, kwargs = self.handle_context_pick_up()
if action is not None:
return action, kwargs
def parse_context_messages(): # MATRX user method
# Parse received message on a 'pick up' and/or 'move_to' messages, and set the brain's variables
def handle_context_move_to(): # MATRX user method
if move_to_loc is not None:
# Apply the pathfinder to move to that location, set `move_to_loc` to None when done
def handle_context_pick_up(): # MATRX user method
if pick_up_obj is not None:
# Return the `grab_object` action with the `pick_up_obj` id. The API then only has to parse the incoming clicks and check the menu item's name in the human agent's brain and perform the function object. The actual logic part is dealt with in the A major disadvantage of this approach is that the MATRX user has to know about function objects and have the awareness how these are callbacked. Which might require a very clear tutorial with examples. Even then it might make debugging a bit more difficult, but I find this hard to estimate. However, it still has all the advantages you mentioned @thaije. In addition it relies even more on the way people work with MATRX (decide on stuff in one method) and its functions (messaging). In addition it has the added advantage that we can easily extend the existing |
Hey @jwaa, looks like a good starting point! I fully agree with most of your points. Also, the only which wasn't exactly clear yet was the connection between the human agent brain and how the context menu info propagates to the visualizer via the API and back. Starting with how the API calls the Secondly, how did you have in mind for the API<->frontend connection to work with passing the context menu functions? From what I understand this is what the API passes to the frontend to fill the context menu with:
Then what should the frontend send back to the API when a menu item is clicked? The function pointer? I don't think that will work, as the API converts any sent data to json/text, such that the |
|
Thanks for the elaborate description! Really helpful!
|
Hey Jasper, thanks for the feedback! Overall I agree with your points. To me it also sounds like a good idea to make all the context menu options work via messages. Same for seperating the two methods (targetting human agent, or another selected agent) for using the context menu in different 'overrideable' functions in an AgentBrain / HumanAgentBrain is also a good idea. Some other remarks to clarify your confusion. First confusion comes from what is going to be implemented. The functionality I named in (your) point 3, 4, and 5 were mostly meant as: our code for the context-menu's should not make these things impossible. Not meant as: our code facilitates all these things or is something we should implement. I was not planning on implementing any meta-actions or permissions logic whatsoever, but if a user wanted to do so, our code should not make it impossible to combine with the context menu code. As for point 6, 7 and 8, you are right. The passed parameters relate to the click event for opening the context menu. However, if we are going to split the functionality as you suggested, it could be come something like this:
Agents would then only have the bottom one. Human agents has the top one (or maybe both? They have both because of inheritence, but can a human agent task another human agent with the context menu?). So for the case where the human agent opens a context menu on an object, the API calls the top function above in that human agent's menu. If the human agent first selects another agent, and then opens the context menu somewhere, the API directly calls the However, I think you found a conceptual issue with this. Because this method above implies that the human agent asks the other agent: "Hey, What can I make you do? Can you give a list?". In our code this is done directly by the API without going through the human agent. The agent then passes this list via the API to the frontend. And then you can choose from those options. I don't know which one is better, or more realisting, but I do think the second option would make it harder to use, as you need to program some method of knowing what other agents can do in your human agent. As for your other points, if we switch to using messages for everything, most of the other points will be solved I think. In addition to using messages we can then implement some functions especially for actions, to make those easier to use. Such as the I'll make a start at this tomorrow, but I do need it for co-active teaming which uses custom message types. So I might need to add some (early version) code that makes that possible as well. |
Is your feature request related to a problem? Please describe.
Part of being a successful team depends on being able to effectively and efficiently communicate. As of now, communication between team members can only be done with the free-text chat. However, this makes it difficult for the human agent to task another agent in doing a specific action on a specific object: it is slow (have to write it all out), prone to error (have to type the agent ID, action name and object ID correct), and results in complicated agents (with natural language processing capabilities) or very brittle agents that fail with a single typo.
A second issue is that some of these difficulties are also encountered for a user when controlling their human agent. At the moment, actions are tied to specific keys. Issues with this are:
Describe the solution you would like
A context menu that pops up when right clicking on an object that can be filled with possible actions that the human agent can execute.
This menu can be used in various ways:
Describe alternatives you have considered
Using the keyboard which is currently implemented. However, as described above, this has some disadvantages.
Additional context
The front-end already has code implemented for opening a context menu. However, any filling of that menu or functionality on the side of MATRX has not yet been implemented.
Possible future extensions of this feature:
The text was updated successfully, but these errors were encountered: