Create an application with pal_app#

pal_app is an utility that quickly creates an application template, ready for deployment on the robot.

Important

As of pal-sdk-23.1, you must run pal_app from inside an SDK Docker image to be able to develop an app.

See Developing with docker and ROS if you do not yet have your SDK Docker image set up.

Create an app skeleton#

  1. Create on your computer a development workspace (that we will mount in the SDK Docker image):

> mkdir ~/ws
  1. Start the SDK Docker image (replacing customer_id by your own PAL-provided customer ID):

> docker run -it $HOME/ws:/home/pal/ws registry.gitlab.com/pal-robotics/customer_id/dockers:latest bash
  1. Create a new app skeleton:

> cd ws
> mkdir src && cd src
> pal_app create

You can for instance use first_app as app ID, and My First App as app name.

Note

Since we are creating files in a mounted directory, the files are accessible (and can be freely edited/modified) from the host machine, and will not be lost when you close the Docker session.

The script generates the following file structure:

 1first_app
 2 3├── chatbot
 4│   └── en_US
 5│       ├── domain.yml
 6│       ├── __init__.py
 7│       ├── nlu.yml
 8│       └── rules.yml
 9├── pages
10│   ├── en_US
11│   │   ├── content_page
12│   │   │   ├── js
13│   │   │   │   ├── main.js
14│   │   │   │   ├── pallib.js
15│   │   │   │   ├── rrlib.js
16│   │   │   │   └── util.js
17│   │   │   ├── style
18│   │   │   │   └── style.css
19│   │   │   └── index.html
20│   │   └── landing_page
21│   │       └── ...
22│   ├── README.md
23│   └── zip_pages.sh
24├── res
25│   └── data.yaml
26├── scripts
27│   └── run_app
28├── src
29│   └── first_app
30│       ├── application_controller.py
31│       └── __init__.py
32├── CMakeLists.txt
33├── package.xml
34├── README.md
35└── setup.py

This is already a complete, working app. You can deploy it and try it right away.

Implement your application logic#

By default, the template does not do anything very useful. However, it demonstrates how to use intents to trigger behaviours or react to events.

Intents are usually generated by your robot’s users. For instance, an intent might be generated:

  • through automatic perception (eg, someone approaches and seems to interact),

  • through verbal interaction (eg, someone tells the robot to go somewhere)

  • through interactions with the touchscreen (eg, someone presses a button to trigger a behaviour).

Your application template already contains examples of each of these possible interactions.

Open first_app/src/first_app/application_controller.py and start customizing your robot behaviour.

Deploy the app on the robot#

To install you app on the robot, you need to follow the 3 following steps:

  1. pal_deploy your code to the robot

  2. enable the chatbot (if you are using one)

  3. install the webpages (if you are using any)

Deploy the application controller to the robot#

  • from inside your SDK Docker image, go to your development workspace:

> cd ~/ws
  • then run:

> rosrun pal_deploy deploy.py --package first_app ari-XXc

(replace ari-XXc by your actual robot)

With the code deployed, you can now ssh onto the robot (ssh pal@ari-XXc, password pal), and go to your project: cd ~/deployed_ws/share/first_app.

Enable the chatbot#

To enable your chatbot, follow the following steps on the robot:

> cd ~/.pal/chatbots-enabled

Then, for each language you support (here, for instance en_US):

> ln -s ~/deployed_ws/share/first_app/chatbot/en_US en_US/first_app

Finally, you must re-train the chatbot engine for each new language:

> rostopic pub /train_chatbot/goal chatbot_msgs/ChatbotTrainActionGoal "header:
  seq: 0
  stamp:
    secs: 0
    nsecs: 0
  frame_id: ''
goal_id:
  stamp:
    secs: 0
    nsecs: 0
  id: ''
goal:
  lang: 'en_US'"

Note

You need to re-train the chatbot engine after every modification to the chatbot definition.

Install the touchscreen web content#

The pages/ subfolder contains the web content meant to be displayed on the robot’s touchscreen. You will find one pages/xx_XX/ subfolder per language, and further subfolders for each touchscreen page.

Your application controller can easily change the active (displayed) page via the ROS action /web/go_to.

However, the pages must first be published on the robot, via the robot’s ARI’s Touchscreen manager.

Installing the pages on the robot#

You first need to create a zip archive for each of your pages. You can either manually zip the content of each subfolders, or use the provided zip_pages.sh script:

> cd pages
> sh zip_pages.sh

Each of the created zip file must then be uploaded to the robot’s Touchscreen manager following the instructions to upload Custom HTML.

Updating web content#

If you modify one of the pages, you must re-zip the corresponding folder, and re-upload it to the Touchscreen manager.

Run your application#

ssh onto the robot (ssh pal@ari-XXc, password pal), and start your application: rosrun first_app run_app

Configure for automatic launch at start-up#

You can also configure your app to automatically start when the robot is turned on. See Configure an application to launch at start-up.