Archived
773 lines
29 KiB
Python
773 lines
29 KiB
Python
# --------------------------------------------------------------------------
|
|
# Authors:
|
|
# 2017-03-06: Thirsa
|
|
# 2020-01-28: Luke Meyer < l.meyer.5@student.rug.nl >
|
|
|
|
# Copyright MRC-CBSU(UK), CNRS(FR), UMCG(NL) and the author(s).
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY
|
|
# without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see < http: // www.gnu.org/licenses/>.
|
|
# --------------------------------------------------------------------------
|
|
|
|
from naoqi import ALProxy
|
|
import random
|
|
import math
|
|
import time
|
|
import paramiko
|
|
import sys
|
|
import tools.settings as settings
|
|
import qi
|
|
|
|
|
|
class Robot(object):
|
|
|
|
def __init__(self, IPADRESS, PORT, LANG, SUBJECT):
|
|
self.language = LANG
|
|
self.ipadress = str(IPADRESS)
|
|
# port = 54011
|
|
self.port = int(PORT)
|
|
self.subject = SUBJECT
|
|
# self.speaking_volume = 65
|
|
# self.stimulus_volume = 75
|
|
self.speaking_volume = 40
|
|
self.stimulus_volume = 45
|
|
|
|
self.say_0 = ''
|
|
self.say_1 = ''
|
|
self.say_2 = ''
|
|
self.say_3 = ''
|
|
self.say_4 = ''
|
|
self.say_5 = ''
|
|
self.encouragement_pos = []
|
|
self.encouragement_neg = []
|
|
self.hips = ["LHipYawPitch", "RHipYawPitch", "LHipPitch", "RHipPitch"]
|
|
from naoqi import ALProxy
|
|
self.mtn = ALProxy("ALMotion", self.ipadress, self.port)
|
|
self.tts = ALProxy("ALTextToSpeech", self.ipadress, self.port)
|
|
self.mem = ALProxy("ALMemory", self.ipadress, self.port)
|
|
self.pst = ALProxy("ALRobotPosture", self.ipadress, self.port)
|
|
self.aas = ALProxy("ALAnimatedSpeech", self.ipadress, self.port)
|
|
self.aap = ALProxy("ALAudioPlayer", self.ipadress, self.port)
|
|
self.aad = ALProxy("ALAudioDevice", self.ipadress, self.port)
|
|
self.all = ALProxy("ALLeds", self.ipadress, self.port)
|
|
self.asr = ALProxy("ALSpeechRecognition", self.ipadress, self.port)
|
|
self.bms = ALProxy("ALBehaviorManager", self.ipadress, self.port)
|
|
self.aad.setOutputVolume(self.speaking_volume)
|
|
|
|
if self.language == 'EN':
|
|
self.tts.setLanguage("English")
|
|
elif self.language == 'NL':
|
|
self.tts.setLanguage("Dutch")
|
|
# Only work when connecting to an actual robot. Does not work with a virtual robot.
|
|
# self.afr = ALProxy("ALFaceDetection",self.ipadress,self.port)
|
|
|
|
def buiging(self):
|
|
'''
|
|
Choregraphe bezier export in Python.
|
|
|
|
Bowing gesture
|
|
'''
|
|
self.mtn.wakeUp()
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("HeadPitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.159578, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.116626, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.159578, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("HeadYaw")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.0123138, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.0123138, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.0123138, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LAnklePitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.0904641, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.115008, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.0904641, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LAnkleRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.12728, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.151824, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.12728, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LElbowRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.45709, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-1.50481, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.45709, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LElbowYaw")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-1.15054, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.529273, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-1.15054, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHand")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.2832, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.2832, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.2832, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHipPitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.131966, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.363515, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.131966, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHipRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.107422, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.0951499, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.107422, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHipYawPitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.162562, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.25767, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.162562, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LKneePitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.0844118, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.0844118, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.0844118, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderPitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[1.48334, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[1.14432, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[1.48334, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.11194, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.130348, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.11194, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("LWristYaw")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.0459781, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-1.09225, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.0459781, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RAnklePitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.0982179, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.0798099, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.0982179, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RAnkleRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.135034, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.145772, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.135034, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.385075, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.360533, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.385075, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowYaw")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[1.20415, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[1.39897, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[1.20415, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHand")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.2916, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.2916, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.2916, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHipPitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.130348, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.322183, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.130348, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHipRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.0996681, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.0413762, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.0996681, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHipYawPitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.162562, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.25767, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.162562, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RKneePitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.0858622, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.0923279, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.0858622, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderPitch")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[1.46961, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[0.93118, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[1.46961, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderRoll")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[-0.136568, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.306841, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[-0.136568, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
names.append("RWristYaw")
|
|
times.append([0.6, 1.84, 3])
|
|
keys.append([[0.076658, [3, -0.2, 0], [3, 0.413333, 0]],
|
|
[-0.372804, [3, -0.413333, 0], [3, 0.386667, 0]],
|
|
[0.076658, [3, -0.386667, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
self.aas.say(
|
|
"^start(animations/Stand/Gestures/Explain_2)Je gaat 3 keer een triplet van verschillende lettergrepen horen. 1 van de tripletten wordt gezegd met een andere stem. Het is jouw taak om aan te geven welke anders klinkt. Je kunt antwoorden door je hand op mijn rechterhand, \\pau=500\\ hoofd \\pau=500\\of linkerhand te leggen. Laten we het proberen. ^wait(animations/Stand/Gestures/Explain_2)"
|
|
)
|
|
|
|
except BaseException, err:
|
|
print err
|
|
self.mtn.rest()
|
|
self.mtn.setStiffnesses(self.hips, 1.0)
|
|
|
|
def intro(self):
|
|
'''
|
|
The intriduction to the experiment. Sam explains how the task will
|
|
work and what to do, as well as a demonstration on how to touch
|
|
the head and hands
|
|
'''
|
|
if self.language == "EN":
|
|
self.say_0 = "^start(animations/stand/Gestures/Enthusiastic_4) Hi there! My name is Sammmy.\\pau=500\\ Welcome to the PICKA auditory performance game.\\pau=500\\ Lets have some fun!"
|
|
elif self.language == 'NL':
|
|
if "HIK" in self.subject:
|
|
self.say_0 = "^start(animations/stand/Gestures/Enthusiastic_4) Hoi! \\pau=250\\ Ik ben Sam."
|
|
else:
|
|
self.say_0 = "^start(animations/stand/Gestures/Enthusiastic_4) Hallo! \\pau=250\\ Ik ben Sammmy. \\pau=500\\ Welkom bij de PICKA auditieve optreden spelletje. \\pau=500\\ Laten we wat plezier hebben!"
|
|
self.mtn.wakeUp()
|
|
self.aas.say(self.say_0)
|
|
|
|
def play_audio(self, stimulus):
|
|
'''
|
|
Uploads the stimuli files to Sam using a paramiko sftp server.
|
|
Sam then plays the files, then deletes them off its main storage.
|
|
'''
|
|
NAO_USERNAME = "nao"
|
|
NAO_PASSWORD = "nao"
|
|
t = paramiko.Transport((self.ipadress, 22))
|
|
t.connect(username=NAO_USERNAME, password=NAO_PASSWORD)
|
|
sftp = paramiko.SFTPClient.from_transport(t)
|
|
sftp.chdir('/home/nao/tests/')
|
|
remotepath = str('/home/nao/tests/' + stimulus)
|
|
|
|
try:
|
|
print "Uploading file..."
|
|
sftp.put(stimulus, remotepath)
|
|
print "File Uploaded"
|
|
except:
|
|
raise ValueError('No file provided for upload.')
|
|
for i in range(1, 1000):
|
|
dir_list = sftp.listdir()
|
|
if stimulus in dir_list:
|
|
break
|
|
else:
|
|
time.sleep(0.01)
|
|
if i == 999:
|
|
raise ValueError('File was not uploaded to nao')
|
|
|
|
# localpath = (
|
|
# 'C:\\Users\\Nao\\Documents\\Nao scripts\\Expe_files\\' + soundfile)
|
|
try:
|
|
# aap = self.aap.playFile(remotepath)
|
|
qi.async(self.aap.playFile, remotepath, delay=0)
|
|
except RuntimeError as e:
|
|
print e
|
|
sys.exit(0)
|
|
|
|
# sftp.remove(stimulus)
|
|
time.sleep(0.5)
|
|
|
|
return True
|
|
|
|
def game_break(self):
|
|
'''
|
|
Waits for a response from the subject to start the experiment.
|
|
'''
|
|
if self.language == 'EN':
|
|
self.say_1 = "When you're ready to begin, you can start the game by touching the top of my head."
|
|
self.say_2 = "Let's begin!"
|
|
self.say_3 = "Ok. Goodbye."
|
|
elif self.language == 'NL':
|
|
self.say_1 = "Wanneer je klaar bent om te beginnen, kun je het experiment starten door je hand op mijn hoofd te leggen."
|
|
self.say_2 = 'Hier gaan we'
|
|
self.say_3 = "Ok. Tot ziens."
|
|
self.tts.say(self.say_1)
|
|
self.mtn.setStiffnesses(["HeadYaw", "HeadPitch"], [1.0, 1.0])
|
|
self.hoofd_beweging()
|
|
# current_running_time = 0
|
|
# start_time = time.time()
|
|
# while current_running_time < (start_time+120):
|
|
# # check the data continously for 120 seconds
|
|
# head1 = self.mem.getData('RearTactilTouched')
|
|
# head2 = self.mem.getData('FrontTactilTouched')ell
|
|
# head = [head1, head2, head3]
|
|
# if any(head):
|
|
# break
|
|
# current_running_time = time.time()
|
|
self.tts.say(self.say_2)
|
|
|
|
def encouragement(self, robot_input):
|
|
'''Issues an encouragement message depending on how the subject is doing.'''
|
|
if self.language == 'EN':
|
|
self.encouragement_pos = [
|
|
"\\vct=110\\You're doing great!\\vct=100\\",
|
|
'\\vct=110\\ Keep going! \\vct=100\\',
|
|
'\\vct=110\\ Doing well!\\vct=100\\',
|
|
"\\vct=110\\ Great!\\vct=100\\"
|
|
]
|
|
self.encouragement_neg = [
|
|
"\\vct=110\\ You can do it! \\vct=100\\",
|
|
"\\vct=110\\ Keep trying! \\vct=100\\",
|
|
"\\vct=110\\ Give it another go! \\vct=100\\",
|
|
"\\vct=110\\ Don't give up!\\vct=100\\"
|
|
]
|
|
elif self.language == 'NL':
|
|
self.encouragement_pos = [
|
|
"\\vct=110\\ Goed bezig!\\vct=100\\",
|
|
'\\vct=110\\ Ga zo door! \\vct=100\\',
|
|
'\\vct=110\\ Je doet het super!\\vct=100\\',
|
|
"\\vct=110\\ Super!\\vct=100\\"
|
|
]
|
|
self.encouragement_neg = [
|
|
"\\vct=110\\ Je kunt het! \\vct=100\\",
|
|
"\\vct=110\\ Blijf proberen! \\vct=100\\",
|
|
"\\vct=110\\ Nog even doorgaan! \\vct=100\\",
|
|
"\\vct=110\\ Niet opgeven!\\vct=100\\"
|
|
]
|
|
answer = str(robot_input)
|
|
if answer == 'correct':
|
|
encouragement_options_positive = self.encouragement_pos
|
|
prob = random.randint(0, len(encouragement_options_positive) - 1)
|
|
encou = encouragement_options_positive[prob]
|
|
else:
|
|
encouragement_options_negative = self.encouragement_neg
|
|
prob = random.randint(0, len(encouragement_options_negative) - 1)
|
|
encou = encouragement_options_negative[prob]
|
|
self.tts.say(encou)
|
|
|
|
def ending(self):
|
|
'''Performs the ending of the experiment.'''
|
|
if self.language == 'EN':
|
|
self.say_1 = '^start(animations/Stand/Gestures/Enthusiastic_5) That\'s the end of our game! ^wait(animations/Stand/Gestures/Enthusiastic_5) \\pau=200\\ ^start(animations/Stand/Gestures/Explain_1)Thank you for playing with me! ^wait(animations/Stand/Gestures/Explain_1) ^start(animations/Stand/Gestures/Hey_6) Goodbye! ^wait(animations/Stand/Gestures/Hey_6)'
|
|
elif self.language == 'NL':
|
|
self.say_1 = '^start(animations/Stand/Gestures/Enthusiastic_5) Dit is het einde van ons spel! ^wait(animations/Stand/Gestures/Enthusiastic_5) \\pau=200\\ ^start(animations/Stand/Gestures/Explain_1)Dankjewel voor het meespelen ^wait(animations/Stand/Gestures/Explain_1) ^start(animations/Stand/Gestures/Hey_6)en tot ziens! ^wait(animations/Stand/Gestures/Hey_6)'
|
|
self.mtn.wakeUp()
|
|
self.aas.setBodyLanguageMode = 2
|
|
self.aas.say(self.say_1)
|
|
self.mtn.rest()
|
|
|
|
def head_shake(self):
|
|
# Choregraphe bezier export in Python.
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("HeadPitch")
|
|
times.append([0.8, 1.6, 2.4])
|
|
keys.append([[-0.0782759, [3, -0.266667, 0], [3, 0.266667, 0]],
|
|
[-0.090548, [3, -0.266667, 0], [3, 0.266667, 0]],
|
|
[-0.07214, [3, -0.266667, 0], [3, 0, 0]]])
|
|
|
|
names.append("HeadYaw")
|
|
times.append([0.8, 1.6, 2.4])
|
|
keys.append([[-0.842209, [3, -0.266667, 0], [3, 0.266667, 0]],
|
|
[0.619695, [3, -0.266667, 0], [3, 0.266667, 0]],
|
|
[-0.0107799, [3, -0.266667, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
|
|
def head_nod(self):
|
|
|
|
# Choregraphe bezier export in Python.
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("HeadPitch")
|
|
times.append([0.8, 1.6])
|
|
keys.append([[0.18864, [3, -0.266667, 0], [3, 0.266667, 0]],
|
|
[-0.0567999, [3, -0.266667, 0], [3, 0, 0]]])
|
|
|
|
names.append("HeadYaw")
|
|
times.append([0.8, 1.6])
|
|
keys.append([[-0.0567999, [3, -0.266667, 0], [3, 0.266667, 0]],
|
|
[-0.0322559, [3, -0.266667, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
|
|
def retry(self):
|
|
if self.language == 'EN':
|
|
# \\pau=500\\ If yes \\pau=500\\ touch my head \\pau=500\\ if no \\pau=500\\ touch my left or right hand."
|
|
self.say_1 = "Would you like to try again?"
|
|
|
|
self.tts.say(self.say_1)
|
|
current_running_time = 0
|
|
start_time = time.time()
|
|
self.asr.subscribe("retry")
|
|
while current_running_time < (start_time + 120):
|
|
if self.mem.getData("WordRecognized")[0] == "yes":
|
|
self.asr.unsubscribe("retry")
|
|
return True
|
|
elif self.mem.getData("WordRecognized")[0] == "no":
|
|
self.asr.unsubscribe("retry")
|
|
return False
|
|
|
|
def simple_say(self, msg):
|
|
self.tts.say(msg)
|
|
|
|
def take_break(self):
|
|
|
|
behaviour_name = "custom_packages-8cd326/take_break"
|
|
if self.bms.isBehaviorInstalled(behaviour_name):
|
|
if self.bms.isBehaviorRunning(behaviour_name) == True:
|
|
self.bms.stopBehavior(behaviour_name)
|
|
self.mtn.setStiffnesses(self.hips, 0.0)
|
|
self.bms.runBehavior(behaviour_name)
|
|
else:
|
|
self.tts.say(
|
|
"I don't appear to be able to take a break right now.")
|
|
self.mtn.setStiffnesses(self.hips, 1.0)
|
|
|
|
def hoofd_beweging(self):
|
|
'''Moves the head down for the subject to test the tactile function of Sam during the introduction.'''
|
|
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("HeadPitch")
|
|
times.append([0.7])
|
|
keys.append([[0.35738, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("HeadYaw")
|
|
times.append([0.7])
|
|
keys.append([[-0.0399261, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
|
|
start_time = time.time()
|
|
current_running_time = 0
|
|
while current_running_time < (start_time + 120):
|
|
# check the data continously for 7 seconds
|
|
head1 = self.mem.getData('RearTactilTouched')
|
|
head2 = self.mem.getData('FrontTactilTouched')
|
|
head3 = self.mem.getData('MiddleTactilTouched')
|
|
head = [head1, head2, head3]
|
|
if any(head):
|
|
answer_given = 2
|
|
break
|
|
current_running_time = time.time()
|
|
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("HeadPitch")
|
|
times.append([0.7])
|
|
keys.append([[-0.17185, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("HeadYaw")
|
|
times.append([0.7])
|
|
keys.append([[-0.0153821, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
|
|
def rechterhand_beweging(self):
|
|
'''Moves the right hand up for the subject to test the tactile function of Sam during the introduction.'''
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("LElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.412604, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[-1.19349, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHand")
|
|
times.append([0.7])
|
|
keys.append([[0.2904, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[1.52169, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.10427, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[0.108872, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.04146, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[1.12131, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHand")
|
|
times.append([0.7])
|
|
keys.append([[0.29, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[0.457174, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.254602, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[-1.03549, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
start_time = time.time()
|
|
current_running_time = 0
|
|
while current_running_time < (start_time + 120):
|
|
right1 = self.mem.getData('HandRightRightTouched')
|
|
right2 = self.mem.getData('HandRightBackTouched')
|
|
right3 = self.mem.getData('HandRightLeftTouched')
|
|
right = [right1, right2, right3]
|
|
if any(right):
|
|
break
|
|
current_running_time = time.time()
|
|
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("LElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.412604, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[-1.19349, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHand")
|
|
times.append([0.7])
|
|
keys.append([[0.2904, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[1.52169, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.102736, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[0.108872, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.382008, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[1.16733, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHand")
|
|
times.append([0.7])
|
|
keys.append([[0.29, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[1.45274, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.0752079, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[0.0413761, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
|
|
def linkerhand_beweging(self):
|
|
'''Moves the left hand up for the subject to test the tactile function of Sam during the introduction.'''
|
|
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("LElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.0367742, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[-0.974132, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHand")
|
|
times.append([0.7])
|
|
keys.append([[0.2904, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[0.624296, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.227074, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[0.88661, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.382008, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[1.16733, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHand")
|
|
times.append([0.7])
|
|
keys.append([[0.29, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[1.45274, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.0752079, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[0.0413761, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
current_running_time = 0
|
|
start_time = time.time()
|
|
while current_running_time < (start_time + 120):
|
|
left1 = self.mem.getData('HandLeftRightTouched')
|
|
left2 = self.mem.getData('HandLeftBackTouched')
|
|
left3 = self.mem.getData('HandLeftLeftTouched')
|
|
left = [left1, left2, left3]
|
|
if any(left):
|
|
break
|
|
current_running_time = time.time()
|
|
|
|
names = list()
|
|
times = list()
|
|
keys = list()
|
|
|
|
names.append("LElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.412604, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[-1.19349, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LHand")
|
|
times.append([0.7])
|
|
keys.append([[0.2904, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[1.52169, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.102736, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("LWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[0.108872, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowRoll")
|
|
times.append([0.7])
|
|
keys.append([[0.382008, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RElbowYaw")
|
|
times.append([0.7])
|
|
keys.append([[1.16733, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RHand")
|
|
times.append([0.7])
|
|
keys.append([[0.29, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderPitch")
|
|
times.append([0.7])
|
|
keys.append([[1.45274, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RShoulderRoll")
|
|
times.append([0.7])
|
|
keys.append([[-0.0752079, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
names.append("RWristYaw")
|
|
times.append([0.7])
|
|
keys.append([[0.0413761, [3, -0.133333, 0], [3, 0, 0]]])
|
|
|
|
try:
|
|
self.mtn.angleInterpolationBezier(names, times, keys)
|
|
except BaseException, err:
|
|
print err
|
|
|
|
|
|
if __name__ == "__main__":
|
|
nao = Robot('127.0.0.1', 9559, "EN")
|
|
nao.buiging()
|