-
Notifications
You must be signed in to change notification settings - Fork 711
Fix chat module bugs #1561
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
base: master
Are you sure you want to change the base?
Fix chat module bugs #1561
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ def __init__(self, mpstate): | |
super(chat, self).__init__(mpstate, "chat", "OpenAI chat support") | ||
|
||
# register module and commands | ||
self.add_command('chat', self.cmd_chat, "chat module", ["show"]) | ||
self.add_command('chat', self.cmd_chat, "chat module", ["hide", "show"]) | ||
|
||
# keep reference to mpstate | ||
self.mpstate = mpstate | ||
|
@@ -42,29 +42,47 @@ def __init__(self, mpstate): | |
|
||
# create chat window (should be called from a new thread) | ||
def create_chat_window(self): | ||
print("Trying to create chat window") | ||
if mp_util.has_wxpython: | ||
# create chat window | ||
# create chat window, and return the chat_window object created | ||
self.chat_window = chat_window.chat_window(self.mpstate, self.wait_for_command_ack) | ||
# Call main loop of chat window | ||
self.chat_window.start() | ||
else: | ||
print("chat: wx support required") | ||
|
||
# show help on command line options | ||
def usage(self): | ||
return "Usage: chat <show>" | ||
return "Usage: chat <hide|show>" | ||
|
||
# control behaviour of the module | ||
def cmd_chat(self, args): | ||
if len(args) == 0: | ||
print(self.usage()) | ||
elif args[0] == "show": | ||
self.show() | ||
elif args[0] == "hide": | ||
self.hide() | ||
else: | ||
print(self.usage()) | ||
|
||
# show chat input window | ||
def show(self): | ||
self.chat_window.show() | ||
|
||
def hide(self): | ||
self.chat_window.hide() | ||
|
||
def close(self): | ||
self.chat_window.close() | ||
|
||
# unload function override for module interface | ||
def unload(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tested "module unload chat" and it doesn't seem to work I'm afraid. Please tell me if I'm doing something wrong. I get the message shown below. Perhaps it's because I'm using WSL2?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have only tested on Windows so far. I will look into it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into why it was not working in Linux (I tried in Ubuntu to recreate the error). It seems wxPython is built on top of GTK in Ubuntu, which is much stricter than the Windows version. It is not allowing reinitializing app or rerunning mainLoop in the same process. I tried different approaches to getting it working in the same process, but keep getting seg fault. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another approach would be to:
I think this might be better, since there is no need to rework the implementation for handling mavlink acknowledgement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @SriramS-77, Either way sounds good to me. By the way, do you have an OpenAPI key? I just checked the list of ArduPilot sponsored API keys and I don't see you there. If you'd like one, please just PM me on ArduPilot's discord server, I'm "rmackay9" over there too. |
||
# Close the chat window | ||
self.close() | ||
# Call the unload function of super class, to include its functionality | ||
super(chat, self).unload() | ||
|
||
# handle mavlink packet | ||
def mavlink_packet(self, m): | ||
if m.get_type() == 'COMMAND_ACK': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should remove this debug output