Search code examples
pepperchoregraphe

How can I save out pre-installed behavior file (.xar) inside Pepper robot to my PC?


I'm building a project which I wish to trigger some pre-installed behaviors inside my robot (which I downloaded from a developer). Understand that I can import content in behaviors (.xar) format into my current project. Any idea how can I extracting the installed behaviors from the robot to my PC?


Solution

  • It depends what you want to do with the apps, just to run them as part of your app or whether you want to edit or integrate the behaviours into your app somehow.

    App switching

    If you downloaded the apps as .pkg files or Choregraphe projects that you installed to the robot (ie. you can see them installed in the "Robot applications" view in Chorgraphe), you can use Pepper's Autonomous Life API to switch to the app, run it until it finishes, then switch back to your app. The activity name is the app ID (right click the app in Robot applications -> copy Application ID) and the name of the behaviour (defaults to behavior_1). Example 'danceApp/behavior_1'

    # in a python box
    def __init__(self):
        # ...
        self.life = ALProxy("ALAutonomousLife")
    
    def onInput_onStart(self):
        # 1 means return to this app when the new app is closed
        self.life.switchFocus('activityName', 1)  
    

    Extracting the behaviours

    If you don't just want to switch to the app, for example if you want to edit it, or run it while doing something else, you can copy for .xar files from the robot to Choregraphe like so.

    1. Copy the robot's app to your PC using SSH in terminal (again, get the app id by right clicking the app in the Robot applications view in Choregraphe)
    scp -r nao@<nao-ip>:/home/nao/.local/PackageManager/apps/app-id <path-to-copy-to>
    
    1. Make a new blank Choregraphe app and save it
    2. Copy the contents of the app folder you got from the robot into the blank Choregraphe app
    3. Open the Choregraphe app and click the behavior.xar under Project files. You should see the behavior and be able to copy or edit it as you need.