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"
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.
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.
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.
Block to make pepper speak
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.
This is a block for conditional branching. This time, the conditions are divided according to the words recognized as follows.
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
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
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.
No. was fun. Usually, it's all about the front of the Web, so sometimes it's fun to program robots.
Recommended Posts