Initial commit of development

Signed-off-by: merspieler <merspieler@users.noreply.github.com>
This commit is contained in:
merspieler 2018-01-31 09:46:55 +01:00
parent 7f9996743d
commit 3dff580039
9 changed files with 128 additions and 0 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
# vims swap files
*.swp
*.swo
# .pyc
*.pyc

14
README.md Normal file
View file

@ -0,0 +1,14 @@
# FlightGear Copilot
This skill acts as an copilot for flight gear that assists you by following your voice commands.
## Current state
UNUSABLE
Working features:
- Crashing
Known issues:
- ...
TODO:
- ...

98
__init__.py Normal file
View file

@ -0,0 +1,98 @@
import sys
import re
import json
from adapt.intent import IntentBuilder
from mycroft import MycroftSkill, intent_handler
from mycroft.skills.core import MycroftSkill
from mycroft.util.log import getLogger
LOGGER = getLogger(__name__)
class FlightGearCopilotSkill(MycroftSkill):
def __init__(self):
super(FlightGearCopilotSkill, self).__init__()
# setting defaults, if not set
self.settings['profiles'] = ({"name": "IDG Airbus", "acid": ("a320-200-cfm", "a320-200-iae"), "flaps": ({"id": "up", "min-spd": 210, "max-spd": 350}, {"id": 1, "min-spd": 190, "max-spd": 230}), "gear-retractable": "true"},{})
# DEFINITION of the settings['profiles'] structure
# (
# {
# "name": "<profile-name>",
# "acid":
# (
# "<Aircraft-id> can be found in /???",
# ...
# ),
# flaps:
# (
# {
# "id": "<flaps-name> can be up|down|full|number",
# "min-spd": "<minimum speed for save retraction>",
# "max-spd": "<maximum speed for save extention>"
# },
# ...
# )
# "flaps-path": "<path to current flaps-position>"
# "gear-retractable": "<true|false>"
# }
# )
# might be useful
# make_active()
@intent_handler(IntentBuilder('FlapsIntent').require('flaps'))
def handle_flaps_intent(self, message):
flaps_request = message.data['utterance']
if flaps_request == "flaps":
self.speak_dialog("no.setting")
sys.exit(0)
# extracting the flaps setting from the utterance
match = re.match(r'.*flaps.* (up|full|down|\d{1,2}).*', flaps_request, re.I)
flaps_request = match.group(1)
# TODO add connection to fg
# DEMO DATA
kias = 140
flaps = 2
acid = "a320-200-cfm"
# END DEMO DATA
profile = ''
# TODO read acid to know which profile to use
for i_profiles in self.settings['profiles']:
for i_acid in i_profiles:
if i_acid == acid:
break
if profile != '':
break
# TODO read flaps and kias
# check if extend or retract flaps
# TODO add seperate handling of the up|down|full value
if str(flaps_request) == "up" or str(flaps_request) == "down" or str(flaps_request) == "full":
pass
else:
if int(flaps_request) > flaps:
flaps_mov = "extend"
elif int(flaps_request) < flaps:
flaps_mov = "retract"
else:
self.speak_dialog("keep.flaps")
sys.exit(0)
# TODO set flaps in fg
self.speak("Speed checked. Flaps " + str(flaps_request))
def stop(self):
pass
def create_skill():
return FlightGearCopilotSkill()

View file

@ -0,0 +1 @@
Already set.

View file

@ -0,0 +1,2 @@
Please give me a flaps setting.
I don't know the . . . Flaps setting.

View file

@ -0,0 +1,3 @@
Speed is too high, I can't extend flaps.
I can't extend the flaps, please reduce speed first.
Do you want the flaps blow away?

View file

@ -0,0 +1,3 @@
Speed is too low, I can't retract flaps.
I can't retract the flaps, please reduce speed first.
Do you want us to stall?

1
settings.json Normal file
View file

@ -0,0 +1 @@
{"__mycroft_skill_firstrun": false, "host": "localhost", "port": 8081, "profiles": {"gear-retractable": "true", "acid": ["a320-200-cfm", "a320-200-iae"], "name": "A32X", "flaps": [{"max-spd": 350, "min-spd": 210, "id": "up"}, {"max-spd": 230, "min-spd": 190, "id": 1}]}}

1
vocab/en-us/flaps.voc Normal file
View file

@ -0,0 +1 @@
flaps