Skip to content
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

Chat: improve flight mode reliability #1291

Merged
merged 6 commits into from
Dec 27, 2023

Conversation

rmackay9
Copy link
Contributor

@rmackay9 rmackay9 commented Dec 27, 2023

This PR is built on #1290 and greatly improves the reliability of the chat modules ability to change modes by adding a get_mode_mapping() function that uses MAVProxy's existing list of flight mode names and numbers.

This has been tested in the simulator on Copters and Rovers and so far I have not seen it set the mode incorrectly.

BTW, the previous method relied on the Assistant referring to four text files (one for each vehicle) which included the mapping from flight mode name to number. Unfortunately OpenAI's assistant seems to have a bug which leads to it sometimes being unable to access the reference files (see this discussion). Without the correct mapping the results could be catastrophic (e.g. how do you feel about flying in Drift or AutoTune when you wanted RTL?)

{
"type": "function",
"function": {
"name": "get_mode_mapping",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't help but wonder if it would be nicer to generate all of this from comments in the Python code rather than explicit documentation like this.

Advantages to human programmers in that. Especially when your editor is smart enough to use those comments to prompt in the user interface. Additional advantage that this documentation won't get out-of-date with the code, then.

Still, carry on :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that would be cool. The json files are slightly difficult to get right the first time you make them but after that it gets easier. What's odd about them is that you only need to include the list of arguments that the assistant must fill in. The return values can be whatever you want.. somehow the assistant just deals with whatever it gets.

MAVProxy/modules/mavproxy_chat/chat_openai.py Show resolved Hide resolved
@@ -327,6 +379,49 @@ def get_vehicle_type(self):
"vehicle_type": vehicle_type_str
}

# get mode mapping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment could be better... I exepct the "as a json string" is implied in here somehow.

@peterbarker peterbarker merged commit 3df0992 into ArduPilot:master Dec 27, 2023
1 check passed
@rmackay9 rmackay9 deleted the chat-flight-mode-reliability branch December 28, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants