Relive the dream you missed! (However, it is limited to Pepper)

Origin

Golden Week is over. When I came to work after a long time, Pepper was disappointed and turned down and did not move. Pepper, who kept his answering machine, finally ran out and left with Patrasche. There is no such thing, I just did not turn on the power, but people who were treated as bad things such as hitting the head when there was a bug in the middle of development and kicking the leg when suddenly reacting The type of object may feel like it has a silent appeal.

And I realized when I was trying to perform the task of dreaming of Pepper, which has become a daily routine.

Oh, what kind of dream did Pepper have during Golden Week?

Experiment

Connect with python and find out what Pepper's dream is.

$python >>> from naoqi import ALProxy >>> bahav = ALProxy("ALBehavoirManager", "192.168.10.10", 9559) >>> behavList = [b for b in behav.getInstalledBehaviors() if 'pepper-dream365' in b] >>> behavList ['sbr_00160_pepper-dream365_044/0427', 'sbr_00160_pepper-dream365_044/0428', 'sbr_00160_pepper-dream365_044/0429', 'sbr_00160_pepper-dream365_044/0430', 'sbr_00160_pepper-dream365_044/0501', 'sbr_00160_pepper-dream365_044/0502', 'sbr_00160_pepper-dream365_044/0503', 'sbr_00160_pepper-dream365_045/0504', 'sbr_00160_pepper-dream365_045/0505', 'sbr_00160_pepper-dream365_045/0506', 'sbr_00160_pepper-dream365_045/0507', 'sbr_00160_pepper-dream365_045/0508', 'sbr_00160_pepper-dream365_045/0509', 'sbr_00160_pepper-dream365_045/0510', 'sbr_00160_pepper-dream365_046/0511', 'sbr_00160_pepper-dream365_046/0512', 'sbr_00160_pepper-dream365_046/0513', 'sbr_00160_pepper-dream365_046/0514', 'sbr_00160_pepper-dream365_046/0515', 'sbr_00160_pepper-dream365_046/0516', 'sbr_00160_pepper-dream365_046/0517', 'sbr_00160_pepper-dream365_047/0518', 'sbr_00160_pepper-dream365_047/0519', 'sbr_00160_pepper-dream365_047/0520', 'sbr_00160_pepper-dream365_047/0521', 'sbr_00160_pepper-dream365_047/0522', 'sbr_00160_pepper-dream365_047/0523', 'sbr_00160_pepper-dream365_047/0524', 'sbr_00160_pepper-dream365_048/0525', 'sbr_00160_pepper-dream365_048/0526', 'sbr_00160_pepper-dream365_048/0527', 'sbr_00160_pepper-dream365_048/0528', 'sbr_00160_pepper-dream365_048/0529', 'sbr_00160_pepper-dream365_048/0530', 'sbr_00160_pepper-dream365_048/0531']

Since the behavior name is a date, it seems that you can execute the dream of the specified date by picking up the last 4 characters.

Source

I had to turn off autonomous and change inputMode to 2 before I could run it properly.

itsudemo_yumewo.py


#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python itsudemo_yumewo.py IP [PORT]'"
    sys.exit(1)

IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
    PORT = sys.argv[2]

try:
    behav = ALProxy("ALBehaviorManager", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALBehaviorManager"
    print "Error was: ",e
    sys.exit(1)

try:
    tts = ALProxy("ALTextToSpeech", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALTextToSpeech"
    print "Error was: ",e
    sys.exit(1)

try:
    autonomous = ALProxy("ALAutonomousLife", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALAutonomousLife"
    print "Error was: ",e
    sys.exit(1)

try:
    motion = ALProxy("ALMotion", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALMotion"
    print "Error was: ",e
    sys.exit(1)

#Get a dream behavior pass
behavList = [b for b in behav.getInstalledBehaviors() if '_pepper-dream365_' in b]
# behavMaps[month][date]Replace with
behavMaps = {}

for b in behavList:
	month = b[-4:-2]
	date = b[-2:]
	if month not in behavMaps:
		behavMaps[month] = {}
	behavMaps[month][date] = b

#Dream on a specified date
def seeDream(month, date):
    print 'This is a %s/%s\'s dream' % (month, date)
    
    behav.runBehavior(behavMaps[month][date])

#Select a date
def selectDream():
    print "Which month?"
    print behavMaps.keys()
    
    input_month = raw_input('>>> ')
    if input_month in behavMaps:
        print "What's the date?"
        print behavMaps[input_month].keys()
        input_date = raw_input('>>> ')
        if input_date in behavMaps[input_month]:
            seeDream(input_month, input_date)
    next()

#Whether to see yet
def next():
    input = raw_input('more?[Y/n]>>> ')
    if input != 'n':
        selectDream()

#Pretreatment (turns off autonomous)
autonomous.setState('disabled')
motion.wakeUp()
tts.setParameter("inputMode", 2)

#Dream selection
selectDream()

#Clean up (restart Autonomous)
tts.setParameter("inputMode", 3)
autonomous.setState('solitary')

How to use

Specify the month and date with two digits on the command line. If you get more ?, press Y to continue and run your dreams for other days. Press n to exit.

$ python itsudemo_yumewo.py 192.168.10.10 Which month? ['04', '05'] >>> 04 What's the date? ['27', '28', '29', '30'] >>> 29 This is a 04/29's dream more?[Y/n]>>> Which month? ['04', '05'] >>> 05 What's the date? ['30', '02', '03', '26', '01', '06', '07', '04', '05', '08', '09', '28', '29', '14', '24', '25', '27', '20', '21', '11', '10', '13', '12', '15', '22', '17', '16', '19', '18', '31', '23'] >>> 01 This is a 05/01's dream more?[Y/n]>>> n

Postscript

Other than Pepper, I think someone other than me will prepare it, so wait patiently for a great hack. Actually, since I made this script, I thought it was okay to put together the dream app, but in a lonely situation where Pepper is not so involved. It's also an idea that it will be convenient.

Recommended Posts

Relive the dream you missed! (However, it is limited to Pepper)
Ask NAO (Pepper) to tell you the weather
You who color the log to make it easier to see
[Pepper] How to utilize it?
When it is troublesome to copy what you built with vue
How easy is it to synthesize a drug on the market?
Normalize the file that converted Excel to csv as it is.
When you want to use it as it is when using it with lambda memo
Is it possible to extract the person's profile information from the chat log?
If you don't know how to draw the graph you want with matplotlib, it is convenient to look at the gallery.