[PYTHON] Points to note when switching from NAOqi OS 2.4.3 to 2.5.5

Introduction

An update for NAOqi OS 2.5.5 will be available for Pepper for Biz on April 4, 2017.

[Pepper for Biz] Software "NAOqi OS 2.5.5" Release Notice

This update includes some changes that are incompatible with previous operating systems. Apps that were running on NAOqi OS 2.4.3 may stop working. This article lists some of the caveats I've found when migrating apps that are already running NAOqi OS 2.4.3 to 2.5.5.

In addition, I have not touched on the parts that have already been officially announced and need to be changed. See below for more information. [Notice of NAOqi version upgrade (v2.5.5).pdf](https://developer.softbankrobotics.com/Software/documentation/NAOqi%E3%83%8F%E3%82%99%E3%83%BC%E3 % 82% B7% E3% 82% 99% E3% 83% A7% E3% 83% B3% E3% 82% A2% E3% 83% 83% E3% 83% 95% E3% 82% 9A (v2.5.5) )% E3% 81% AE% E3% 81% 8A% E7% 9F% A5% E3% 82% 89% E3% 81% 9B.pdf)

Prerequisites

All of the following descriptions have been confirmed to work with Pepper for Biz.

OnStopped output timing of Speech Reco and Dialog when the Internet is not connected

First you need to replace

The Speech Reco box and Dialog box that are often used in Pepper apps, but the [PDF document](https://developer.softbankrobotics.com/Software/documentation/NAOqi%E3%83%8F] described in "Introduction" % E3% 82% 99% E3% 83% BC% E3% 82% B7% E3% 82% 99% E3% 83% A7% E3% 83% B3% E3% 82% A2% E3% 83% 83% E3 % 83% 95% E3% 82% 9A (v2.5.5)% E3% 81% AE% E3% 81% 8A% E7% 9F% A5% E3% 82% 89% E3% 81% 9B.pdf) , It is described as "Incompatible BOX replacement", so if you want to run an existing app on NAOqi OS 2.5.5, you need to replace the box with Choregraphe 2.5.5.

What's wrong

"When the Internet is not connected" means that you are only connected to the LAN, and the network status on the Pepper settings screen is orange.

screen.png

Basically, Pepper is recommended to be used in an environment with an internet connection, but it may be surprising that it may operate in an environment such as an event venue or basement floor where you can connect to a LAN but not the internet. The following events occur when running the app in such an environment.

The following is a common use case for Speech Reco. After recognizing the voice, the Speech Reco box itself is stopped and the next process is started. This will prevent Pepper from listening to its own lines and entering an infinite loop, or you can switch the Word List it recognizes when using multiple Speech Reco boxes to another Speech Reco box. ..

スクリーンショット 2017-03-29 13.09.55.png

If you are not connected to the internet and have NAOqi OS 2.4.3, using the Speech Reco or Dilalog box, the onStopped output will take ** seconds to fire. ** ** However, when running on NAOqi OS 2.5.5, the onStopped output fires when it enters the onStop input.

If you implement it in anticipation that it will take several seconds when the Internet is not connected, onStopped may fire at an unexpected timing and behave unexpectedly when operating with 2.5.5.

Solution

To solve (or rather deal with) this event, fully understand that the onStopped output is fired at different times when using the Speech Reco, Dialog box with NAOqi OS 2.5.5 when the Internet is not connected. You need to implement it.

How to write parameters for Expression Watcher box

What is Expression Watcher Box?

The Expression Watcher box is a box that monitors the data of ALMemory, various events that fire while Pepper is running. It is a box that outputs true and false by specifying conditions for data values, not just "fired".

スクリーンショット 2017-03-29 10.52.57.png

Let's look at an example. First, enter the following conditions in the parameter "Condition" of the Expression Watcher box.

('MyData' == 1) ~2

This is if the data in the key "MyData" is 1 for 2 seconds.

Try typing "MyData" for the parameter "key" in the Insert Data box. The arrangement of the boxes looks like this.

スクリーンショット 2017-03-29 11.02.47.png

If you start the app in this state, false will be output suddenly from the Expression Watcher box. It will be false because the specified conditions have not been met yet. Now let's double-click the onStart input in the Insert Data box.

スクリーンショット_2017-03-29_11_02_47_のコピー.png

Then the input screen will be displayed, so enter "1" and click "OK". And wait for 2 seconds ...

スクリーンショット 2017-03-29 11.09.04.png

true is output. In this way, you can specify temporal conditions for the value. Besides, it is a very convenient box because you can combine multiple conditions.

Please refer to the Choregraphe document for details on the conditional format. Launch trigger conditions — Aldebaran 2.4.3.28 documentation

What's wrong

The introduction has become long, but it is the main subject.

When I tried to run an app that was running on NAOqi OS 2.4.3 on 2.5.5, I got the following error in the Expression Watcher box.

RuntimeError: Invalid expression syntax: "bang(myEvent) && 'myEvent' == 1"  

Apparently it's a syntax error. The conditions in the actual app were not as simple as the above example, so it took some time to find out exactly what was the cause of the conditional statement.

Solution

As a test, if you look at the description in the "Condition" parameter of the default Expression Watcher box in Choregraphe 2.4.3 and 2.5.5, it is as follows.

For 2.4.3

bang(myEvent) && 'myEvent' == 1

For 2.5.5

bang('myEvent') && 'myEvent' == 1

In 2.5.5, it seems that it is strictly checked to enclose the key name of ALMemory specified in the condition in single quotation marks.

If the same event occurs, please check the character string specified in the condition.

Requests library version down

Pepper and requests

requests is an HTTP library commonly used in Python. (I will omit the explanation of how to use it) Requests: HTTP for Humans

Since this library is installed in Pepper itself, ** if it is connected to the actual Pepper machine **, by ʻimport` in the app, especially keep the requests library in the app. Can be used without. (If you want to use the requests library with a virtual robot, you need to pass the path to the requests library kept in the app)

With this NAOqi OS 2.5.5 update, the version of this library has been reduced as follows:

NAOqi OS ver requests ver
2.4.3 2.5.1
2.5.5 2.3.0

What's wrong

In requests, write the following when POSTing parameters.

url = 'https://api.github.com/some/endpoint'
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.post(url, data=payload)

At this time, when sending the POST parameter in JSON format, the following writing method is possible. (** requests 2.4.2 or later **)

url = 'https://api.github.com/some/endpoint'
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.post(url, json=payload)

As written in bold, JSON-formatted POST requests in the above format are available in requests version 2.4.2 and above. I was able to run it on NAOqi OS 2.4.3 Pepper, but I get an error on 2.5.5 Pepper.

Solution

The simple solution is to stop using the automatic conversion feature with the json keyword argument. The following is an example.

import json
url = 'https://api.github.com/some/endpoint'
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.post(url, data=json.dumps(payload))

This only affected our app, but when using requests on NAOqi OS 2.5.5, There may be issues that can be resolved by keeping in mind that the version of requests has been reduced.

Summary

In this article, we have described the points that we noticed when migrating our application from NAOqi OS 2.4.3 to 2.5.5. I think that the behavior is different for other boxes, and it may be necessary to deal with the original implementation part, but I hope it helps.

Recommended Posts

Points to note when switching from NAOqi OS 2.4.3 to 2.5.5
Points to note when updating to WSL2
Points to note when deleting multiple elements from the List
Points to note when performing logistic regression with Statsmodels
(Note) Points to be addicted to when installing Scilab on ArchLinux
Points to note when making pandas read csv of excel output
Things to note when running Python on EC2 from AWS Lambda
Summary of advantages (disadvantages) when switching from CUnit to Google Test
[Note] [PyTorch] From installation to easy usage
Points to consider when hitting SoftLayer API from an app on Bluemix
[Amazon Linux] Switching from Python 2 series to Python 3 series
A story that suffered from OS differences when trying to implement a dissertation
Python Note: When assigning a value to a string
What I did when updating from Python 2.6 to 2.7
What failed when going from Javaer to Pythonista
Sum from 1 to 10
Trajectory when ssh connecting to guest OS on VirtualBox
RaspberryPi3 (STRETCH) setup from OS installation to Hello World
Python --Notes when converting from str type to int type
Things to note when initializing a list in Python
Speeding up when connecting from cx_Oracle to Autonomous Database
Mercurial stopped working after migrating from Python 2 to Python 3 (Note)
Coloring points according to the distance from the regression curve