本文整理汇总了Python中naoqi.ALProxy.fadeRGB方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.fadeRGB方法的具体用法?Python ALProxy.fadeRGB怎么用?Python ALProxy.fadeRGB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.fadeRGB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ledBlink
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class ledBlink(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.ALLeds = ALProxy("ALLeds", Settings.naoHostName, Settings.naoPort)
self.cmd = "LED_BLINK"
self.running = False
def exe(self, args=None, addr=None):
if not self.running:
self.led()
def led(self):
self.running = True
rDuration = 0.05;
self.ALLeds.post.fadeRGB( "FaceLed0", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed1", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed2", 0xffffff, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed3", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed4", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed6", 0xffffff, rDuration );
self.ALLeds.fadeRGB( "FaceLed7", 0x000000, rDuration );
sleep(0.1)
self.ALLeds.fadeRGB( "FaceLeds", 0xffffff, rDuration );
self.running = False
示例2: setEyeCol
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
def setEyeCol( color ):
# Verbindung mit ALBroker herstellen
led = ALProxy( "ALLeds", config.naoIP, config.naoPort )
# color in Integer umwandeln
color = int(color)
# Augenfarbe setzen
try: led.fadeRGB( "FaceLeds", int(color), float(config.stdEyeColorFade) )
except: return False
return True
示例3: LED_eyes_module
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class LED_eyes_module(ALModule):
""" A simple module to change the eye LEDs colour to represent emotions.
"""
def __init__(self, name):
ALModule.__init__(self, name)
# Create proxies for the instance.
self.tts = ALProxy("ALTextToSpeech")
self.leds = ALProxy("ALLeds")
# Run behaviour when a tactile touched.
global memory
memory = ALProxy("ALMemory")
memory.subscribeToEvent("TouchChanged", self.getName(), "emotive_eyes")
def emotive_eyes(self, *_args):
""" Change eye colour to express emotion.
Uses VA mapping based on a RYB (artists) colour wheel.
"""
memory.unsubscribeToEvent("TouchChanged", self.getName())
eye_colour_lookup_table = [[(0xF82C35),(0xF82C35),(0xD55528),(0xD55528),(0xFF622B),(0xFF622B),(0xFFB047),(0xFFB047),(0xFFB047),(0xFFB047),(0xFFB047)],
[(0xF82C35),(0xF82C35),(0xD5542A),(0xD5542A),(0xE96A37),(0xFF8232),(0xFF8232),(0xFEB340),(0xFEB340),(0xFEB340),(0xFFFF00)],
[(0xF62D35),(0xF62D35),(0xF62D35),(0xE96A37),(0xE96A37),(0xFF984D),(0xFF8232),(0xFDC147),(0xFFB144),(0xFFFF00),(0xFFFF00)],
[(0xF72C32),(0xF72C32),(0xFF4048),(0xFE5761),(0xED8659),(0xFEB278),(0xFECE6A),(0xFECE6A),(0xFEE566),(0xFFFF00),(0xFFFF00)],
[(0xF6255C),(0xF6255C),(0xF9386F),(0xFD585E),(0xF78C84),(0xFFB379),(0xFEDEA1),(0xFEE67C),(0xFFE564),(0xFFFF00),(0xFFFF00)],
[(0xF6255C),(0xF93871),(0xF93871),(0xFE9EB9),(0xFE9EB9),(0xFFFFFF),(0xD0E7B3),(0xA5D277),(0x85B957),(0x6EAB34),(0x6EAB34)],
[(0xA82C72),(0xA82C72),(0xC03381),(0xDB5CA1),(0xE8A1C3),(0xD1E5F0),(0xCFDADE),(0x73B8B3),(0x87B958),(0x6EAB34),(0x6EAB34)],
[(0xA82C72),(0xA82C72),(0xC03381),(0x9C3F74),(0xB36893),(0xD1E4F2),(0x91C3E6),(0x91C3E6),(0x219A95),(0x00948E),(0x6BAC34)],
[(0xA82C72),(0xA82C72),(0x86305D),(0x86305D),(0x94C8D6),(0x93C8D8),(0x92C2E6),(0x3196CE),(0x009591),(0x009591),(0x009591)],
[(0xA62D72),(0x692850),(0x692850),(0x692850),(0x2D9DB1),(0x2C9FB2),(0x2F96CE),(0x0085BE),(0x00968D),(0x00968D),(0x00968D)],
[(0x692850),(0x692850),(0x692850),(0x692850),(0x037F9B),(0x037F9B),(0x0085BE),(0x0085BE),(0x0085BE),(0x0085BE),(0x0085BE)]
]
current_emotion = memory.getData("Emotion/Current")
valence = current_emotion[0][0]
arousal = current_emotion[0][1]
valence_index = (int(valence * 5) + 5)
arousal_index = 10 - (int(arousal * 5) + 5)
hex_eye_colour = eye_colour_lookup_table[arousal_index][valence_index]
eye_duration = 2.0
self.leds.fadeRGB("FaceLeds", hex_eye_colour, eye_duration)
time.sleep(5.0)
self.leds.reset("FaceLeds")
memory.subscribeToEvent("TouchChanged", self.getName(), "emotive_eyes")
示例4: ledAngry
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class ledAngry(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.ALLeds = ALProxy("ALLeds", Settings.naoHostName, Settings.naoPort)
self.cmd = "LED_ANGRY"
self.running = False
def exe(self, args=None, addr=None):
if not self.running:
self.led()
def led(self):
self.running = True
rDuration = 0.2
self.ALLeds.post.fadeRGB( "FaceLed0", 0x060000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed1", 0xf30000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed2", 0xff0000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed3", 0x701a00, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed4", 0xff1a00, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed7", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed0", 0x140000, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed1", 0xff0000, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed2", 0xff0000, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed3", 0xf51a00, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed4", 0xff1a00, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed5", 0xff0000, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x7c0000, rDuration*3 );
self.ALLeds.fadeRGB( "FaceLed7", 0x260000, rDuration*3 );
self.running = False
示例5: ledCautious
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class ledCautious(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.ALLeds = ALProxy("ALLeds", Settings.naoHostName, Settings.naoPort)
self.cmd = "LED_CAUTIOUS"
self.running = False
def exe(self, args=None, addr=None):
if not self.running:
self.led()
def led(self):
self.running = True
rDuration = 0.2
self.ALLeds.post.fadeRGB( "FaceLed0", 0x1111FF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed1", 0x1111FF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed2", 0x6611FF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed3", 0x1111FF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed4", 0x33CCFF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x33CCFF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x6611FF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed7", 0x6611FF, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed0", 0x33CCFF, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed1", 0x33CCFF, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed2", 0x33CCFF, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed3", 0x33CCFF, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed4", 0x1111FF, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x1111FF, rDuration*3 );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x33CCFF, rDuration*3 );
self.ALLeds.fadeRGB( "FaceLed7", 0x33CCFF, rDuration*3 );
self.running = False
示例6: ledLaugh
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class ledLaugh(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.ALLeds = ALProxy("ALLeds", Settings.naoHostName, Settings.naoPort)
self.cmd = "LED_LAUGH"
self.running = False
def exe(self, args=None, addr=None):
if not self.running:
self.led()
def led(self):
self.running = True
rDuration = 0.5;
self.ALLeds.post.fadeRGB( "FaceLed0", 0x787e22, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed1", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed2", 0x2ec122, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed3", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed4", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x1e9922, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed7", 0x000000, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed0", 0x040022, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed1", 0x14a122, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed2", 0x000022, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed3", 0x000000, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed4", 0x00000e, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x56ff11, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x000022, rDuration*2 );
self.ALLeds.fadeRGB( "FaceLed7", 0x000011, rDuration*2 );
self.running = False
示例7: ledHappy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class ledHappy(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.ALLeds = ALProxy("ALLeds", Settings.naoHostName, Settings.naoPort)
self.cmd = "LED_HAPPY"
self.running = False
def exe(self, args=None, addr=None):
if not self.running:
self.led()
def led(self):
self.running = True
rDuration = 0.5
self.ALLeds.post.fadeRGB( "FaceLed0", 0x002e30, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed1", 0x002022, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed2", 0x20d700, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed3", 0xb59b04, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed4", 0x3aff00, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x001a2a, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x00182e, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed7", 0x001232, rDuration );
self.ALLeds.post.fadeRGB( "FaceLed0", 0x007030, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed1", 0x006622, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed2", 0xdb8f00, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed3", 0x0aff04, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed4", 0xd3dd00, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed5", 0x004c2a, rDuration*2 );
self.ALLeds.post.fadeRGB( "FaceLed6", 0x00502e, rDuration*2 );
self.ALLeds.fadeRGB( "FaceLed7", 0x004e32, rDuration*2 );
self.running = False
示例8: ledFlash
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class ledFlash(object):
"""
classdocs
"""
def __init__(self):
"""
Constructor
"""
self.ALLeds = ALProxy("ALLeds", Settings.naoHostName, Settings.naoPort)
self.cmd = "LED_FLASH"
self.running = False
def exe(self, args=None, addr=None):
if not self.running:
self.led()
def led(self):
self.running = True
rDuration = 0.2
self.ALLeds.post.fadeRGB("FaceLeds", 0xFFAA55, rDuration)
self.ALLeds.fadeRGB("FaceLeds", 0x111111, rDuration * 2)
self.running = False
示例9: interpretJointsPose
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
# Wait for the user to press the front tactile sensor.
print "Please press head front tactile sensor to start."
while not memoryProxy.getData("FrontTactilTouched"):
pass
print "To guide the robot use the robot left arm."
print "Move LShoulderPitch to set x, y target and move LWristYaw to set wz target."
print "When the robot eyes are green, the robot is ready to move."
print "Starting..."
print "Please press head rear tactile sensor to stop."
# Start by moving left foot.
isLeftSupport = False
isMoving = False
ledsProxy.fadeRGB("FaceLeds", 255, 0.1)
while not memoryProxy.getData("RearTactilTouched"):
targetPose = interpretJointsPose(motionProxy, memoryProxy)
# Filter the pose to avoid too small steps.
if (math.fabs(targetPose.x) > 0.01) or \
(math.fabs(targetPose.y) > 0.01) or \
(math.fabs(targetPose.theta) > 0.08):
moveToTargetPose(targetPose, motionProxy, isLeftSupport)
isLeftSupport = not isLeftSupport
isMoving = True
# Set LEDs to green.
ledsProxy.fadeRGB("FaceLeds", 256 * 255, 0.1)
elif isMoving:
示例10: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
timesList = [[5.0], [5.0]] # seconds
pathList = [#front,sideways,up
[[-0.04+random.uniform(-1, 1)/50.0, 0.17+random.uniform(-1, 1)/50.0, 0.1+random.uniform(-1, 1)/50.0, 0.0, 0.0, 0.0]],
[[-0.04+random.uniform(-1, 1)/50.0, -0.17+random.uniform(-1, 1)/50.0, 0.1+random.uniform(-1, 1)/50.0, 0.0, 0.0, 0.0]]
]
motionProxy.positionInterpolations(effectorList, space, pathList,
axisMaskList, timesList, isAbsolute)
#shine eyes
# Replace "127.0.0.1" with the IP of your NAO
leds = ALProxy("ALLeds",robotIp,9559)
# Turn the green face LEDs half on
leds.fadeRGB("FaceLeds", 0x0000FF00, 1.0)
time.sleep(10)
leds.fadeRGB("FaceLeds", 0xFF000000, 1.0)
#bring back
postureProxy.goToPosture("StandInit", 0.9)
#remove stiffness
SetStiffness(motionProxy, 0)
if __name__ == "__main__":
robotIp = "137.195.108.173"
示例11: NaoTouchModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
class NaoTouchModule(ALModule):
""" A simple module able to react
to facedetection events
"""
def __init__(self, name):
ALModule.__init__(self, name)
# No need for IP and port here because
# we have our Python broker connected to NAOqi broker
# HUE service
self._hue = None
self._teller = None
# Create a proxy to ALTextToSpeech for later use
global tts
tts = ALProxy("ALTextToSpeech", NAO_IP, 9559)
# Subscribe to the FaceDetected event:
global memory
self.leds = ALProxy("ALLeds", NAO_IP, 9559)
memory = ALProxy("ALMemory")
memory.subscribeToEvent("MiddleTactilTouched",
"HumanGreeter",
"onMiddleTouchSensed")
# memory.unsubscribeToEvent("WordRecognized",
# "HumanGreeter")
speechrecog = ALProxy("ALSpeechRecognition")
speechrecog.setLanguage("French")
wordList = ["bleu", "rouge", "vert", "jaune",
"porte", "température", "meteo"]
try:
speechrecog.setVocabulary(wordList, True)
except Exception as ex:
_logger.warning("Got exception: %s", ex)
tts.say("Je suis prêt à recevoir des ordres")
def changeLed(self, color):
"""
Changes the LEDs on the robot
"""
duration = 1.0
if color == "rouge":
rgb = 0x00FF0000
elif color == "vert":
rgb = 0x00009900
elif color == "bleu":
rgb = 0x00000099
elif color == "jaune":
rgb = 0x00FFFF00
else:
# Default
rgb = 0x00FFFFFF
# Change LEDs on the Robot
self.leds.fadeRGB('AllLeds', rgb, duration)
if self._hue is not None:
# Change lamp color
self._hue.color(1, color)
def onStateRequest(self, item):
"""
Requests the state of an item
"""
if item == "porte":
self._teller.say_door()
elif item == "température":
self._teller.say_temperature()
elif item == "meteo":
self._teller.say_weather()
def onSpeechRecognized(self, *_args):
"""
This will be called each time a speech is detected.
"""
# Unsubscribe to the event when talking,
# to avoid repetitions
words = memory.getData("WordRecognized");
word = words[0]
_logger.info("Heard %s (%s)", word, words)
if word in ("porte", "meteo", "température"):
# State order
self.onStateRequest(word)
else:
# Color given
self.changeLed(words[0])
time.sleep(1)
#.........这里部分代码省略.........
示例12: emotional_demo_module
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
#.........这里部分代码省略.........
[(0xA82C72),(0xA82C72),(0xC03381),(0x9C3F74),(0xB36893),(0xD1E4F2),(0x91C3E6),(0x91C3E6),(0x219A95),(0x00948E),(0x6BAC34)],
[(0xA82C72),(0xA82C72),(0x86305D),(0x86305D),(0x94C8D6),(0x93C8D8),(0x92C2E6),(0x3196CE),(0x009591),(0x009591),(0x009591)],
[(0xA62D72),(0x692850),(0x692850),(0x692850),(0x2D9DB1),(0x2C9FB2),(0x2F96CE),(0x0085BE),(0x00968D),(0x00968D),(0x00968D)],
[(0x692850),(0x692850),(0x692850),(0x692850),(0x037F9B),(0x037F9B),(0x0085BE),(0x0085BE),(0x0085BE),(0x0085BE),(0x0085BE)]
]
# Speech.
# Speech parameter lookup table. Format (pitch modifier, volume modifier)
speech_parameter_lookup_table = [((1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00)),
((1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00),(1.00,1.00)),
((1.00,0.75),(0.81,0.75),(0.00,0.00),(0.00,0.00),(-0.25,0.00),(0.50,1.00),(0.62,0.50),(0.75,),(0.75,),(0.75,0.75),(1.00,0.75)),
((1.00,0.50),(0.63,0.50),(-0.20,-0.50),(-1.00,-1.00),(-0.25,-0.50),(0.25,0.50),(0.25,0.50),(0.50,),(0.50,0.50),(0.50,0.50),(0.00,0.50)),
((1.00,0.25),(0.44,0.25),(0.40,-0.50),(0.30,-0.50),(0.25,-0.50),(0.25,0.00),(0.25,0.00),(0.25,0.25),(0.25,0.25),(0.25,0.25),(0.00,0.25)),
((1.00,0.00),(0.25,0.00),(0.10,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.10,0.00),(0.10,0.00),(0.10,0.00),(0.00,0.00)),
((0.25,-0.25),(0.06,-0.25),(-0.10,-0.25),(-0.20,0.00),(-0.20,0.00),(-0.10,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00)),
((-0.25,-0.50),(-0.13,-0.50),(-0.35,-0.50),(-0.20,-0.25),(-0.10,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00)),
((-0.25,-0.75),(-0.31,-0.75),(-0.35,-0.75),(-0.10,-0.50),(-0.10,-0.25),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00)),
((-0.50,-1.00),(-0.50,-1.00),(-0.40,-1.00),(-0.20,-0.75),(-0.10,-0.50),(0.00,-0.25),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00)),
((-0.50,-1.00),(-0.50,-1.00),(-0.50,-1.00),(-0.25,-0.75),(0.00,-0.50),(0.00,-0.25),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00),(0.00,0.00))]
# CALCULATIONS
# Get current emotional values and generic calcs.
current_emotion = memory.getData("Emotion/Current")
print "current_emotion (module): ", current_emotion
valence = current_emotion[0][0]
arousal = current_emotion[0][1]
emotion_name = current_emotion[3][0]
# Valence and arousal are normalised between -1 and 1, with an axis intersection at (0, 0). Convert axis intersection
# to index.
valence_index = (int(valence * 5) + 5)
arousal_index = 10 - (int(arousal * 5) + 5)
# Speech.
# The pitch and volume modifier values need scaled, final value to be determined. e.g. a value of 4 will divide the parameter by 4 to give a +/- of 25% of the default value
speech_parameter_scaling_value = 4
string_to_say = "I am feeling " + emotion_name
scaled_pitch_modifier = 1 + (speech_parameter_lookup_table[arousal_index][valence_index][0] / speech_parameter_scaling_value)
# NAO can only increase pitch! So need to check if a pitch reduction required and negate it. Range 1.0 - 4.0.
if scaled_pitch_modifier < 1.0:
scaled_pitch_modifier = 1.0
# NAO volume (gain) range 0.0 - 1.0.
scaled_volume_modifier = 0.5 + (speech_parameter_lookup_table[arousal_index][valence_index][1] / speech_parameter_scaling_value)
self.tts.setParameter("pitchShift", scaled_pitch_modifier)
self.tts.setVolume(scaled_volume_modifier)
# Eyes.
hex_eye_colour = eye_colour_lookup_table[arousal_index][valence_index]
eye_duration = 2.0
# Motion.
# Head pitch - inversely proportional to arousal.
# Head pitch has a range of approx +0.5 to -0.5 radians so divide normalised arousal value by 2.
head_pitch = arousal / 2 * -1
motion_names.append("HeadPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([0.0, head_pitch, 0.0])
# Stance (torso position + arms) - directly proportional to valence
# Shoulders have a pitch of +2 to -2 radians.
# Used in absolute mode, central pitch value is 1.4radians.
shoulder_pitch = 1.4 - valence * 0.5
motion_names.append("LShoulderPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([1.45726, shoulder_pitch, 1.45726])
motion_names.append("RShoulderPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([1.4, shoulder_pitch, 1.4])
# Ankles have a pitch of approx +0.9 to -1.1radians.
# Used in absolute mode, central pitch value is 0.08radians.
ankle_pitch = 0.08 - valence * 0.05
motion_names.append("LAnklePitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([0.08, ankle_pitch, 0.08])
motion_names.append("RAnklePitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([0.08, ankle_pitch, 0.08])
# OUTPUTS
# Speech.
self.tts.post.say(string_to_say)
# Motion.
self.motion.post.angleInterpolation(motion_names, motion_keys, motion_times, True)
# Eyes.
self.leds.fadeRGB("FaceLeds", hex_eye_colour, eye_duration)
time.sleep(5.0)
self.leds.reset("FaceLeds")
# TIDY UP
# Reset speech parameters to nominal.
self.tts.setParameter("pitchShift", 0)
self.tts.setVolume(0.5)
memory.subscribeToEvent("VAChanged", self.getName(), "express_current_emotion")
示例13: Robot
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
#.........这里部分代码省略.........
"""
Robot stands
"""
self.pose.goToPosture("Stand", 0.4)
def turnHead(self, yaw = None, pitch = None, speed = 0.2):
"""
Turns robot head to the specified yaw and/or pitch in degrees at the given speed.
Yaw can range from 119.5 deg (left) to -119.5 deg (right) and pitch can range from 38.5 deg (down) to -29.5 deg (up).
"""
if not yaw is None:
self.motion.setAngles("HeadYaw", math.radians(yaw), speed)
if not pitch is None:
self.motion.setAngles("HeadPitch", math.radians(pitch), speed)
def moveRightArm(self, pitch): # add yaw!
"""
Extends robot's right arm to point at the specified yaw and pitch in degrees.
The angles below are RShoulderPitch, RShoulderRoll, RElbowRoll, RWristYaw, and RHand.
The angle ranges can be found at http://doc.aldebaran.com/1-14/family/robots/joints_robot.html#right-arm-joints
For example, the pitch ranges from 119.5 (down) to 0 (horizontal) to -119.5 (up).
"""
angles = [pitch, 12, 39, 3, -8] # angles in degrees
angles = [math.radians(angle) for angle in angles] # convert to radians
angles.append(1) # also open hand
times = [1, 1, 1.5, 1.5, 1.5, 1.5]
self.motion.angleInterpolation("RArm", angles, times, True) # move to those arm angles and open hand
def moveLeftArm(self, pitch): # add yaw!
"""
Extends robot's left arm to point at the specified yaw and pitch in degrees.
The angles below are LShoulderPitch, LShoulderRoll, LElbowRoll, LWristYaw, and LHand.
The angle ranges can be found at http://doc.aldebaran.com/1-14/family/robots/joints_robot.html#left-arm-joints
For example, the pitch ranges from 119.5 (down) to 0 (horizontal) to -119.5 (up).
"""
angles = [pitch, -12, -39, -3, 8] # angles in degrees
angles = [math.radians(angle) for angle in angles] # convert to radians
angles.append(1) # also open hand
times = [1, 1, 1.5, 1.5, 1.5, 1.5]
self.motion.angleInterpolation("LArm", angles, times, True) # move to those arm angles and open hand
def colorEyes(self, color, fade_duration = 0.2):
"""
Fades eye LEDs to specified color over the given duration.
"Color" argument should be either in hex format (e.g. 0x0063e6c0) or one of the following
strings: pink, red, orange, yellow, green, blue, purple
"""
if color in self.colors:
color = self.colors[color]
self.leds.fadeRGB("FaceLeds", color, fade_duration)
def getHeadAngles(self):
"""
Returns current robot head angles in radians as a list of yaw, pitch.
For yaw, from the robot's POV, left is positive and right is negative. For pitch, up is positive and down is negative.
See http://doc.aldebaran.com/2-1/family/robots/joints_robot.html for info on the range of its yaw and pitch.
"""
robot_head_yaw, robot_head_pitch = self.motion.getAngles("Head", False)
# return adjusted robot head angles
return [robot_head_yaw, -robot_head_pitch]
def getArmAngles(self):
"""
Returns all arm angles in radians as a list in the following order.
[[LShoulderPitch, LShoulderRoll, LElbowRoll, LWristYaw, LHand],
[RShoulderPitch, RShoulderRoll, RElbowRoll, RWristYaw, RHand]]
"""
return [self.motion.getAngles("LArm", True), self.motion.getAngles("RArm", True)]
def resetEyes(self):
"""
Turns eye LEDs white.
"""
self.leds.on("FaceLeds")
def trackFace(self):
"""
Sets face tracker to just head and starts.
"""
# start face tracker
self.track.setWholeBodyOn(False)
self.track.startTracker()
def stopTrackingFace(self):
"""
Stops face tracker.
"""
self.track.stopTracker()
示例14: __eye_leds
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
def __eye_leds(self, data):
b = (data & 255 )/ 255.0
g = ((data >> 8) & 255) / 255.0
r = ((data >> 16) & 255) / 255.0
led = ALProxy("ALLeds", Settings.naoHostName, Settings.naoPort)
led.fadeRGB("FaceLeds", r, g, b, 1.0)
示例15: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import fadeRGB [as 别名]
#.........这里部分代码省略.........
valence_index = int(valence * 5) + 5
arousal_index = 10 - (int(arousal * 5) + 5)
# Eyes.
hex_eye_colour = eye_colour_lookup_table[arousal_index][valence_index]
eye_duration = 0.1
# Motion.
# Head pitch - inversely proportional to arousal.
# Head pitch has a range of approx +0.5 to -0.5 radians so divide normalised arousal value by 2.
head_pitch = arousal / 2 * -1
motion_names.append("HeadPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([0.0, head_pitch, 0.0])
# Stance (torso position + arms) - directly proportional to valence
# Shoulders have a pitch of +2 to -2 radians.
# Used in absolute mode, central pitch value is 1.4 radians.
shoulder_pitch = 1.4 - valence * 0.5
motion_names.append("LShoulderPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([1.45726, shoulder_pitch, 1.45726])
motion_names.append("RShoulderPitch")
motion_times.append([0.5, 2, 4])
motion_keys.append([1.4, shoulder_pitch, 1.4])
shoulder_roll = valence * 0.8
motion_names.append("LShoulderRoll")
motion_times.append([0.5, 2, 4])
motion_keys.append([0.5, -shoulder_roll, 0.3])
motion_names.append("RShoulderRoll")
motion_times.append([0.5, 2, 4])
motion_keys.append([-0.5, shoulder_roll, -0.3])
# Ankles have a pitch of approx +0.9 to -1.1radians.
# Used in absolute mode, central pitch value is 0.08 radians.
# ankle_pitch = 0.08 - valence * 0.05
#
# motion_names.append("LAnklePitch")
# motion_times.append([0.5, 2, 4])
# motion_keys.append([0.08, ankle_pitch, 0.08])
#
# motion_names.append("RAnklePitch")
# motion_times.append([0.5, 2, 4])
# motion_keys.append([0.08, ankle_pitch, 0.08])
# OUTPUTS
# Speech.
# self.tts.post.say(string_to_say)
# Eyes.
self.leds.fadeRGB("FaceLeds", hex_eye_colour, eye_duration)
# self.leds.reset("FaceLeds")
# Motion.
if self.state_activity == "WAITING_FOR_FEEDBACK" and self.do_it_once == True:
# self.posture.goToPosture("StandInit", 0.3)
self.motion.angleInterpolation(motion_names, motion_keys, motion_times, True)
self.motion.waitUntilMoveIsFinished()
# self.posture.goToPosture("StandInit", 0.3)
self.do_it_once = False
if self.activity != "drawing_nao":
# Speech.
# The pitch and volume modifier values need scaled, final value to be determined. e.g. a value of 4 will divide the parameter by 4 to give a +/- of 25% of the default value
speech_parameter_scaling_value = 4
string_to_say = "I am feeling " + emotion_name
scaled_pitch_modifier = 1 + (
speech_parameter_lookup_table[arousal_index][valence_index][0] / speech_parameter_scaling_value
)
# NAO can only increase pitch! So need to check if a pitch reduction required and negate it. Range 1.0 - 4.0.
if scaled_pitch_modifier < 1.0:
scaled_pitch_modifier = 1.0
# NAO volume (gain) range 0.0 - 1.0.
scaled_volume_modifier = 0.5 + (
speech_parameter_lookup_table[arousal_index][valence_index][1] / speech_parameter_scaling_value
)
# self.tts.setParameter("pitchShift", scaled_pitch_modifier)
# self.tts.setVolume(scaled_volume_modifier)
# Reset speech parameters to nominal.
# self.tts.setParameter("pitchShift", 0)
# self.tts.setVolume(0.5)
def current_state_callback(self, data):
self.state_activity = data.data
self.do_it_once = True
def activity_callback(self, data):
self.activity = data.data
def stop_request_callback(self, data):
self.motion.rest()
self.leds.reset("FaceLeds")
rospy.signal_shutdown("Interaction exited")