mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Small fixes
This commit is contained in:
parent
735418c026
commit
c7406164ed
@ -44,13 +44,14 @@ SPEECH_LANG_MAP = {
|
|||||||
"finished": "Thank you! Robot is now turning off"
|
"finished": "Thank you! Robot is now turning off"
|
||||||
},
|
},
|
||||||
"ru": {
|
"ru": {
|
||||||
"ready": "Робот Веернии 01 готов к работе",
|
"ready": "Робот Веернии готов к работе",
|
||||||
"type commands": "печатайте команды",
|
"type commands": "печатайте команды",
|
||||||
"ok": "хорошо",
|
"ok": "хорошо",
|
||||||
"commands help": "Доступные команды это: вперёд, назад, поворот влево, поворот вправо, "
|
"commands help": "Доступные команды это: вперёд, назад, влево, вправо, "
|
||||||
"голову влево, голову вправо, голову прямо, выстрел, скажи",
|
"голову влево, голову вправо, голову прямо, выстрел, скажи",
|
||||||
"Finished": "Робот завершает работу. Спасибо!",
|
"Finished": "Робот завершает работу. Спасибо!",
|
||||||
"commands from file": "Исполняю команды из файла",
|
"commands from file": "Исполняю команды из файла",
|
||||||
|
"fire": "Выстрел!",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,13 +115,13 @@ class Vernie(MoveHub):
|
|||||||
self.motor_AB.angled(distance * VERNIE_SINGLE_MOVE, speed * direction, speed * direction)
|
self.motor_AB.angled(distance * VERNIE_SINGLE_MOVE, speed * direction, speed * direction)
|
||||||
|
|
||||||
def shot(self):
|
def shot(self):
|
||||||
self.head(RIGHT, 60, speed=1)
|
self.motor_external.timed(0.5)
|
||||||
self.head(STRAIGHT)
|
self.head(STRAIGHT)
|
||||||
self.head(STRAIGHT)
|
self.head(STRAIGHT)
|
||||||
|
|
||||||
def interpret_command(self, cmd, confirm):
|
def interpret_command(self, cmd, confirm):
|
||||||
cmd = cmd.strip().lower().split(' ')
|
cmd = cmd.strip().lower().split(' ')
|
||||||
if cmd[0] in ("head", "голова", "голова"):
|
if cmd[0] in ("head", "голова", "голову"):
|
||||||
if cmd[-1] in ("right", "вправо", "направо"):
|
if cmd[-1] in ("right", "вправо", "направо"):
|
||||||
confirm(cmd)
|
confirm(cmd)
|
||||||
self.head(RIGHT)
|
self.head(RIGHT)
|
||||||
@ -133,7 +134,7 @@ class Vernie(MoveHub):
|
|||||||
elif cmd[0] in ("say", "скажи", "сказать"):
|
elif cmd[0] in ("say", "скажи", "сказать"):
|
||||||
say(' '.join(cmd[1:]))
|
say(' '.join(cmd[1:]))
|
||||||
elif cmd[0] in ("fire", "shot", "огонь", "выстрел"):
|
elif cmd[0] in ("fire", "shot", "огонь", "выстрел"):
|
||||||
say("fire!")
|
say("fire")
|
||||||
self.shot()
|
self.shot()
|
||||||
elif cmd[0] in ("end", "finish", "конец", "стоп"):
|
elif cmd[0] in ("end", "finish", "конец", "стоп"):
|
||||||
self.say("finished")
|
self.say("finished")
|
||||||
@ -162,6 +163,12 @@ class Vernie(MoveHub):
|
|||||||
else:
|
else:
|
||||||
confirm(cmd)
|
confirm(cmd)
|
||||||
self.turn(RIGHT, degrees=180)
|
self.turn(RIGHT, degrees=180)
|
||||||
else:
|
elif cmd[0] in ("right", "вправо", "направо"):
|
||||||
|
confirm(cmd)
|
||||||
|
self.turn(RIGHT)
|
||||||
|
elif cmd[0] in ("left", "влево", "налево"):
|
||||||
|
confirm(cmd)
|
||||||
|
self.turn(LEFT)
|
||||||
|
elif cmd[0]:
|
||||||
self.say("Unknown command")
|
self.say("Unknown command")
|
||||||
self.say("commands help")
|
self.say("commands help")
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from vernie import *
|
from vernie import *
|
||||||
|
import six
|
||||||
|
|
||||||
robot = Vernie()
|
robot = Vernie()
|
||||||
|
|
||||||
@ -11,5 +12,5 @@ def confirmation(_):
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
cmd = six.moves.input("COMMAND >")
|
cmd = six.moves.input("> ")
|
||||||
robot.interpret_command(cmd, confirmation)
|
robot.interpret_command(cmd, confirmation)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user