Version 7 (modified by Ales Horak, 4 months ago) (diff)


PV277 Programming Applications for Social Robots (autumn 2019)

Pepper API

programming in Choregraphe via Python

  • enter only one box Python Script
  • edit its contents via double click:
    • to __init__ add:
      self.tts = ALProxy('ALTextToSpeech')
    • to onInput_onStart add:
      self.tts.say("Ahoj, jak se máš?")
  • add Czech into Project Properties
  • save the project and run in on a virtual robot

speech input via Python

  • in __init__ add:
            self.speech = ALProxy("ALSpeechRecognition")
  'Running on virtual robot')
            self.speech = None
  • process speech accordingly
    def get_answer(self, reactions):
        if self.speech is None:
            return (random.choice(reactions.keys()))
            self.speech.setVocabulary(reactions.keys(), False)
  'Speech recognition engine started')
    def onInput_onStart(self):
        self.tts.say("Ahoj, jak se máš?")
        reactions = {
            'dobře':  'to je super!',
            'špatně': 'doufám, že to brzo bude lepší',
            'nevím': 'tak to určitě nebude tak zlé',
        answer = self.get_answer(reactions)
        react = reactions.get(answer)'answer={}, react={}'.format(answer, react))
  • see ALSpeechRecognition documentation


  • add boxes Set Language with Czech and add Czech to project properties
  • right click the free area -> Create a new box -> Dialog...
  • in the Dialog -> Add Topic - choose Czech and Add to the package content as collaborative dialog (allows to start the dialog just by talking to the robot)
  • connect onStart -> Set Language -> Dialog
  • in Project files double click on and enter
    topic: ~dialog()
    language: czc
    concept:(ahoj) "ahoj robote"
    concept:(dobrý_den) ["dobrý den" "krásný den" "krásný den přeju"]
    u:(~ahoj) ahoj člověče
      to máme dnes hezký den
    u:(~dobrý_den) ~dobrý_den
  • see QiChat - Introduction and QiChat - Syntax for details

adding animations

  • single animation - via Animation box
  • connect to dialog:
    • add rule to topic:
      u:(["můžeš zamávat" zamávej] {prosím}) ahojky $zamavej=1
    • add output to the dialog box (right click -> Edit box) named zamavej (Bang, punctual)
    • add Kisses animation box, connect it to the zamavej output
  • within the dialog:
    u:(~ahoj) ^start(animations/Stand/Gestures/Hey_1) ahoj člověče
      to máme dnes hezký den 

shows only on real robot, see default list of animations

Attachments (1)

Download all attachments as: .zip