[ALMemory](http://qiita.com/Atelier-Akihabara/items/4162192129f366da1240#almemory%E3%82%92%E4%BB%8B%] when saving or retrieving any information in Pepper E3% 81% 97% E3% 81% 9F% E3% 82% A4% E3% 83% 99% E3% 83% B3% E3% 83% 88% E5% 80% A4% E3% 81% AE% E5% 8F% 96% E5% BE% 97) is the royal road, but when you think about saving a slightly larger text with an application and extracting it with a development PC, the file is more convenient. There is also.
As a process in such a case, I made a box to write out a text file and tried to extract the file from Pepper to the local environment, so I made a note.
The box is located in the web-boxes
directory at https://github.com/yacchin1205/pepper-web-boxes.
Clone or Download ZIP, Load Box Library [http://qiita.com/Atelier-Akihabara/items/db907ed319b8af0984db#%E3%83%9C%E3%83%83%E3%82% AF% E3% 82% B9% E3% 83% A9% E3% 82% A4% E3% 83% 96% E3% 83% A9% E3% 83% AA% E3% 81% AE% E8% AA% AD% You can use it by loading the box library according to the procedure of E3% 81% BF% E8% BE% BC% E3% 81% BF).
The created box is in the ʻIO` folder of the box library and looks like the following. Is there something like a box document generation tool somewhere ...
Write the text to a file.
Enter the text you want to export. When this input fires, it writes the string entered in the file specified by the File path parameter described below.
Output when the export is successful.
When writing fails, a character string indicating the content of the error is output.
Specify the path of the text file to read. It is created based on the current directory where the behavior is running.
Specifies the character encoding of the text file to read. The default is ʻutf8`. Please refer to http://docs.python.jp/2.7/library/codecs.html for what kind of value can be specified.
It's not this Write Text box, but I fell in love with the Unicode trap with the code below in the Read Text box I made with it.
with codecs.open(self.getParameter("File path"), "r", self.getParameter("Encoding")) as f:
text = f.read()
self.onStopped(text.encode("utf8"))
I have specified character string
as the type of onStopped, but if I give the unicode type character string obtained byread ()
as an argument, None
is passed to the next input. It seems to end up.
I wrote some test code, but when I say String in Choregraphe's documentation, it seems that only Python's str type is considered and unicode type cannot be processed. For the time being, I avoided it by giving it as a byte array with ʻencode ("utf8") `, but this Choregraphe behavior does not match the idea of Python strings, and it is very cool in that it may cause confusion. I feel like I'm not.
For Japanese people, it's better to clarify this, so I asked in the Aldebaran Community (String in Choregraphe's python box. -choregraphes-python-box-2651)) However, the answer is that unicode type is not supported now ... Um.
For the time being, a simple test is written in the repository tests / test-io-text /
. For example, test at the level of whether the content obtained in the Read Text box is as expected as shown below. For example, the Read Text test looks like this.
For the idea, refer to Pepper Box Library Test Consideration for reference.
Some about how to retrieve files saved in these boxes.
For Pepper's file system, you can upload and download files with Choregraphe. [Transfer files to advanced menu](http://qiita.com/tonosamart/items/fe3948a45ccc97ddbbab#choregraphe%E3%81%A7%E3%81%A4%E3%81%AA%E3%81%84% E3% 81% A7% E3% 81% BF% E3% 82% 8B% EF% BC% 92), so it is the royal road to use it.
When thinking about automation, I sometimes want to retrieve files even in an environment without Choregraphe. Looking at the documentation NAOqi Developer guide> Programming> Connecting Choregraphe / your robot> Connection Management, it seems that you can assume that FTP is working, but I dared to try using HTTP.
[If you create a directory called html in the project, you can see it from the tablet](http://qiita.com/Atelier-Akihabara/items/716e88b306db12751c9b#%E7%B0%A1%E5%8D%98%E3%81%AAhtml% E3% 82% 92% E3% 82% BF% E3% 83% 96% E3% 83% AC% E3% 83% 83% E3% 83% 88% E3% 81% AB% E8% A1% A8% E7% A4% BA), but in this state you can see the contents of this html directory by doing http: // (Pepper's name.local. Or IP address) /apps/.lastUploadedChoregrapheBehavior/
. Maybe it's the same idea as putting the public_html
directory in your home directory on your web server.
So why not generate the files you want to make available for download in the html
directory? I created the samples / dump-info
project in the repository. Here, all the contents of ALMemory and all the contents of Preferences are dumped, saved in a text file, and downloaded from an external PC.
The points are the following two points.
web-boxes
). In the Get HTML File box, the output file path is generated based on the absolute path of the html directory in your application.After running this application, open a URL like http: // Pepper's IP / apps / .lastUploadedChoregrapheBehavior /
on a PC connected to the same LAN as Pepper. Then you can check the index.html of the project from your PC. Here, you can download the file (1.) exported in the Write Text box by clicking the link to the file (2.).
Like this, if you want to create some file in the project and pull it out from the PC, you should create the file in the html directory of the project. Let's use this for a while ...
Recommended Posts