[PYTHON] I tried to let Pepper talk about event information and member information

At the following event of Basecamp Nagoya , I tried programming pepper for the first time.

Pepper Day "App Development for Pepper in Base Camp Nagoya"

What I challenged this time

This time, when I said "Tell me Pepper?", Pepper responded "Yes", and when I asked "What is today's event?", I asked "What is today's event?" We have created a program that will give you information about members checking in to the base camp when you ask "Who is coming?" For the latest event.

Environmental arrangement

First, download the Pepper development environment from the following site. https://community.aldebaran.com/en/resources/software/language/en-gb After downloading, various apps will be installed. From among them, launch the app with the C mark as shown in the figure below.

Pepper programming method

Basically, you can move the pepper just by combining the blocks that have already been programmed, but you have to program by yourself using Python that you can not do with the existing blocks. The wiring diagram of the program created this time is as follows. The blocks used are as follows.

Say block

Block to make pepper speak

Speech Reco block

A block for making pepper recognize voice. By separating words with; in this way, you can separate the words to be recognized. The recognized words span the next block.

Switch Case block

This is a block for conditional branching. This time, the conditions are divided according to the words recognized as follows.

Text Edit block

A block for passing a string to the next block. I want Pepper to pull the JSON data of the member information and talk, so I specify the JSON file I want to get as follows. At this time, the JSON file to be output is generated on the CMS side. In other words, the CMS manages everything that Pepper speaks. That will lower the threshold of Pepper's programming.

http://basecamp-nagoya.jp/*****.json

Python Script block

I didn't have a block to access the server and pull the JSON data, so I made it myself. Below is the source. However, dependent libraries such as json need to be downloaded separately.

import json, urllib2, sys, os, xml
 
class MyClass(GeneratedClass):
    def __init__(self):
        GeneratedClass.__init__(self)
 
    def onLoad(self):
        self.framemanager = ALProxy("ALFrameManager")
        pass
 
    def onUnload(self):
        self.framemanager = None
        pass
 
    def remove_tags(text):
        return ''.join(xml.etree.ElementTree.fromstring(text).itertext())
 
    def rest_request(self, url):
        self.folderName = os.path.join(self.framemanager.getBehaviorPath(self.behaviorId), "./lib")
        if self.folderName not in sys.path:
            sys.path.append(self.folderName)
        import requests
        try:
            r = requests.get(url)
            if r.status_code == 200 :
                return r.json();
            else:
                return False
        except:
            return False
        pass;
 
    def onInput_onStart(self, p):
        result = self.rest_request(str(p));
        output_text = "";
        i = 0;
        length = len(result);
        while i < length:
            output_text += str(result[i]['name'].encode('utf-8'))
            output_text += "\\pau=1000\\"
            output_text += str(result[i]['profile'].encode('utf-8'))
            output_text += "\\pau=3000\\"
            i += 1
        self.onStopped(output_text) 
        pass
 
    def onInput_onStop(self):
        self.onUnload() 
        self.onStopped() 
 
    def import_service(self):
        pass

Program packaging

After the program is completed, you can package the created program and install it in pepper by selecting Robot Application from the lower right panel and clicking the icon on the upper left as shown below.

Impressions

No. was fun. Usually, it's all about the front of the Web, so sometimes it's fun to program robots.

Recommended Posts

I tried to let Pepper talk about event information and member information
I tried to get Web information using "Requests" and "lxml"
I tried to organize about MCMC.
I tried to let optuna solve Sudoku
I tried to let VAE learn motion graphics
[Introduction to PID] I tried to control and play ♬
I tried to read and save automatically with VOICEROID2 2
I tried to implement and learn DCGAN with PyTorch
I tried adding post-increment to CPython. Overview and summary
I tried to automatically read and save with VOICEROID2
I tried adding system calls and scheduler to Linux
I tried to debug.
I tried to visualize the spacha information of VTuber
I tried to paste
I tried to implement Grad-CAM with keras and tensorflow
I tried to install scrapy on Anaconda and couldn't
I tried web application development and thought about how to prevent beginners from getting sick.
I tried to predict and submit Titanic survivors with Kaggle
I tried to find out the outline about Big Gorilla
I tried to get the location information of Odakyu Bus
I tried to combine Discord Bot and face recognition-for LT-
I tried to notify the train delay information with LINE Notify
I tried mushrooms Pepper x IBM Bluemix Text to Speech
I tried to illustrate the time and time in C language
[Python] I tried to visualize tweets about Corona with WordCloud
I wanted to worry about execution time and memory usage
I tried to display the time and today's weather w
[Introduction to infectious disease model] I tried fitting and playing ♬
I tried to enumerate the differences between java and python
I tried to create a bot for PES event notification
I tried to make GUI tic-tac-toe with Python and Tkinter
I tried to get various information from the codeforces API
I tried to organize SVM.
I tried to implement PCANet
I tried to reintroduce Linux
I tried to introduce Pylint
I tried to summarize SparseMatrix
I tried to touch jupyter
I tried to implement StarGAN (1)
I tried to make an activity that collectively sets location information
I tried to visualize bookmarks flying to Slack with Doc2Vec and PCA
I tried to make a periodical process with Selenium and Python
I tried to create Bulls and Cows with a shell program
I tried to easily detect facial landmarks with python and dlib
I tried to extract players and skill names from sports articles
[Python] I tried to get various information using YouTube Data API!
When I tried to write about logistic regression, I ended up finding the mean and variance of the logistic distribution.
I tried to create Quip API
I tried to touch Python (installation)
I tried to implement adversarial validation
I tried to explain Pytorch dataset
I tried Watson Speech to Text
I tried to touch Tesla's API
I tried to implement hierarchical clustering
I tried to implement Realness GAN
I tried to move the ball
I tried to estimate the interval.
I tried to summarize until I quit the bank and became an engineer
I tried moving the image to the specified folder by right-clicking and left-clicking
I tried to implement a blockchain that actually works with about 170 lines
I tried to visualize the age group and rate distribution of Atcoder