Sample 1: a first dance application¶
Here is a typical, well designed, simple dance application.
Content outline: Pepper dances Date by “I’m fresh! You’re pretty!”.
Let’s discover how it works.
Init & Reset¶
Ensure that Pepper:
- is in the right state before starting the dance,
- is set back to its initial state after the dance is finished.
How it works
This is the first box being triggered, because it is directly linked to the to the onStart input of the Application.
Double-click the Init & Reset box to open it.
Let’s read the 2 main methods.
The onInput_onStart method is executed when the application is started, to:
Deactivate ALAutonomousMoves and ALBasicAwareness.
Go to the Stand posture.
Depending on the success or the failure of the goToPosture function call, it will be the success or the failure output.
If successful, the Dance Timeline box is started, otherwise the application quits.
def onInput_onStart(self): try: self.amoves.setBackgroundStrategy("none") except Exception as exc: self.log("Unable to disable autonomous moves: %s" % str(exc)) try: self.ba.stopAwareness() except Exception as exc: self.log("Unable to stop awareness: %s" % str(exc)) self.postureProxy.setMaxTryNumber(3) result = self.postureProxy.goToPosture("Stand", 0.8) if(result): self.success() else: self.failure()
The onUnload method of the box is executed when the application quits, to:
Reactivate ALAutonomousMoves and ALBasicAwareness.
def onUnload(self): try: self.amoves.setBackgroundStrategy("backToNeutral") except Exception as exc: self.log("Unable to enable breathing: %s" % str(exc)) try: self.ba.startAwareness() except Exception as exc: self.log("Unable to start awareness: %s" % str(exc)) self.postureProxy.stopMove()
Dance Timeline box mixes:
- body movements,
- music from a sound file,
- an image displayed on Pepper’s tablet.
How it works
This box is triggered when the Init & Reset box ends successfully, thanks to its onStart input linked to the success output of the Init & Reset box.
Double-click the Dance Timeline box to open it.
Let’s read the 3 main layers.
- Motion: The motion keyframes of the dance animation, which represent the position of the robot and its body parts at a certain time.
- music behavior layer: A Play Sound box. It plays an attached sound file.
- tablet behavior layer: A Show Image box. It displays an image on the tablet.
Try the application.
|In the Robot applications panel panel, click the Package and install the current project on the robot button.|
Make sure autonomous life is on.
If not, click the Turn autonomous life on button.
Launch the application.
Through the tablet
You may also try the behavior only, by clicking on the Play button.
Note that this example only works correctly on a real Pepper, since ALTabletService is not present on a virtual robot.
Make it yours!¶
Edit the part of the content you want to customize: let’s say the music.
Want to package it?¶
Customize its properties.
You can keep most of the properties as they are, but the following ones must be adapted: