本文整理汇总了Python中naoqi.ALProxy.angleInterpolation方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.angleInterpolation方法的具体用法?Python ALProxy.angleInterpolation怎么用?Python ALProxy.angleInterpolation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.angleInterpolation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RedBallDetectionModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
class RedBallDetectionModule(ALModule):
""" A basic module to test events """
def __init__(self, name):
ALModule.__init__(self, name)
self.name = name
#self.tts = ALProxy("ALTextToSpeech")
self.memory = ALProxy("ALMemory")
self.motion = ALProxy("ALMotion")
self.memory.subscribeToEvent("RedBallDetectedEvent", name, "handleBallDetection")
def handleBallDetection(self, key, value, message):
""" A method that handles detection of the ball. """
names = ['HeadYaw', 'HeadPitch']
times = [[0.01], [0.01]] # what is the fastest rate?
xStep = 0.03
yStep = 0.022
moveX = -xStep if value[0]>0 else xStep if value[0]<0 else 0.0 # since robot camera has a mirror view, we need to alternate directions
moveY = yStep if value[1]>0 else -yStep if value[1]<0 else 0.0
print moveX, moveY
self.memory.unsubscribeToEvent("RedBallDetectedEvent", self.name)
self.motion.angleInterpolation(names, [moveX, moveY], times, False)
#self.tts.say("Recevied the values! " + str(value[0]) + " " + str(value[1]))
self.memory.subscribeToEvent("RedBallDetectedEvent", self.name, "handleBallDetection")
示例2: ReactionModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
class ReactionModule(ALModule):
""" A basic module to test events """
def __init__(self, name):
ALModule.__init__(self, name)
self.name = name
self.memory = ALProxy("ALMemory")
self.motion = ALProxy("ALMotion")
self.memory.subscribeToEvent("ColorDetectedEvent", name, "handleDetection")
def handleDetection(self, key, value, message):
""" A method that handles detection of the color. """
names = ['HeadYaw', 'HeadPitch']
times = [[0.01], [0.01]] # what is the fastest rate?
xStep = 0.03
yStep = 0.022
moveX = -xStep if value[0]>0 else xStep if value[0]<0 else 0.0 # since robot camera has a mirror view, we need to alternate directions
moveY = yStep if value[1]>0 else -yStep if value[1]<0 else 0.0
print moveX, moveY
self.memory.unsubscribeToEvent("ColorDetectedEvent", self.name)
self.motion.angleInterpolation(names, [moveX, moveY], times, False)
self.memory.subscribeToEvent("ColorDetectedEvent", self.name, "handleDetection")
def disconnect(self):
try:
self.memory.unsubscribeToEvent("ColorDetectedEvent", self.getName())
except BaseException, err:
print "Error while disconnecting from color reaction module: " + str(err)
示例3: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
def main():
""" Simple code to test above motion data. """
# Choregraphe simplified export in Python.
from naoqi import ALProxy
from pprint import pprint
names = list()
times = list()
keys = list()
leftArmMovementList = [leftArmMovementList0, leftArmMovementList1, leftArmMovementList2, leftArmMovementList3]
choice = 2
for n, t, k in leftArmMovementList[1]:
names.append(n)
times.append(t)
keys.append(k)
try:
# uncomment the following line and modify the IP if you use this script outside Choregraphe.
IP = "mistcalf.local"
motion = ALProxy("ALMotion", IP, 9559)
posture = ALProxy("ALRobotPosture", IP, 9559)
motion.wakeUp()
posture.goToPosture("StandInit", 0.8)
# motion = ALProxy("ALMotion")
motion.angleInterpolation(names, keys, times, True)
posture.goToPosture("Crouch", 0.8)
motion.rest()
except BaseException, err:
print err
开发者ID:mikemcfarlane,项目名称:TickleMeNAO,代码行数:36,代码来源:python_motion_data_export_from_Choregraph_inc_run_code.py
示例4: FaceTracker
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
class FaceTracker():
def __init__(self, use_nao, ip = "10.0.1.3", port = 9559):
self.use_nao = use_nao
if use_nao:
self.faceProxy = ALProxy("ALFaceTracker", ip, port)
self.motion = ALProxy("ALMotion", ip, port)
def start_tracking(self):
if self.use_nao:
print "StartTracking"
self.motion.setStiffnesses("Head", 1.0)
self.faceProxy.startTracker()
self.faceProxy.setWholeBodyOn(True)
def stop_tracking(self):
if self.use_nao:
self.faceProxy.stopTracker()
self.motion.setStiffnesses("Head", 0.0)
self.to_default_pos()
print "Tracking stopped"
def to_default_pos(self):
if self.use_nao:
self.motion.setStiffnesses("Head", 0.5)
self.motion.setAngles("HeadYaw", 0.0, 0.1)
self.motion.setAngles("HeadPitch", -0.25, 0.1)
# self.motion.setStiffnesses("Head", 0)
def shake_no(self):
if self.use_nao:
names = "HeadYaw"
currentAngle = self.motion.getAngles("Head", True)[0]
angles = [0.25, 0, -0.25, 0, 0.25, currentAngle]
angles = [currentAngle+0.25, currentAngle, currentAngle-0.25, currentAngle, currentAngle+0.25, currentAngle]
times = [(i/len(angles))+0.2 for i in np.arange(1, len(angles)+1)]
self.faceProxy.stopTracker()
print "no"
self.motion.setStiffnesses("Head", 1.0)
self.motion.angleInterpolation(names, angles, times, True)
self.motion.setStiffnesses("Head", 0.0)
self.start_tracking()
def shake_yes(self):
if self.use_nao:
names = "HeadPitch"
currentAngle = self.motion.getAngles("Head", False)[1]
angles = [currentAngle+0.15, currentAngle]
times = [i/len(angles)*0.5 for i in np.arange(1, len(angles)+1)]
self.faceProxy.stopTracker()
self.motion.setStiffnesses("Head", 1.0)
self.motion.angleInterpolation(names, angles, times, True)
self.motion.setStiffnesses("Head", 0.0)
self.start_tracking()
示例5: searchBall
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
def searchBall(angle, isenabled, robotIP="127.0.0.1", port=9559):
MEMORY = ALProxy("ALMemory", robotIP, port)
REDBALL = ALProxy("ALRedBallDetection", robotIP, port)
MOTION = ALProxy("ALMotion", robotIP, port)
#周期为200毫秒,也就是每隔200毫秒刷入一次内存(memory)
period = 200
REDBALL.subscribe("Redball",period,0.0)
MEMORY.insertData("redBallDetected",None)
time.sleep(0.5)
MOTION.angleInterpolation("HeadYaw",angle*math.pi/180.0,0.5,isenabled)
time.sleep(2)
#读取检测到的红球数据,如果没有被检测到则返回None
temp = MEMORY.getData("redBallDetected")
MEMORY.insertData("redBallDetected",None)
REDBALL.unsubscribe("Redball")
return temp
示例6: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
def main():
""" Some simple robot processes.
"""
motion = ALProxy("ALMotion", NAO_IP, 9559)
posture = ALProxy("ALRobotPosture", NAO_IP, 9559)
memory = ALProxy("ALMemory", NAO_IP, 9559)
data = list()
# Set stiffness on for Head motors and go to start pose.
print "Starting move...."
motion.setStiffnesses("Head", 1.0)
posture.goToPosture("Crouch", 2.0)
# Core processes. Do some moves and record data.
for i in range(STEPS):
positiveAngleStep = 1.0 / STEPS
negativeAngleStep = -1 * positiveAngleStep
timeStep = 20 / STEPS
motion.angleInterpolation(
["HeadYaw"],
[positiveAngleStep],
[timeStep],
False
)
motion.angleInterpolation(
["HeadPitch"],
[negativeAngleStep],
[timeStep],
False
)
line = list()
for key in ALMEMORY_KEY_NAMES:
value = memory.getData(key)
line.append(value)
data.append(line)
# Gently set stiff off for Head motors and relax.
print "...Going to stop now!"
motion.setStiffnesses("Head", 0.0)
motion.rest()
print data
示例7: run
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
#.........这里部分代码省略.........
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.0827939, 0.337438, -0.314512, -0.520068, 0.0919981])
names.append("LAnkleRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.138018, -0.05058, -0.101202, -0.0183661, -0.12728])
names.append("LElbowRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.440216, -1.54462, -0.647306, -1.50021, -0.41107])
names.append("LElbowYaw")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-1.16742, -1.15361, -0.605972, -0.395814, -1.17048])
names.append("LHand")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.2908, 0.268, 0.2776, 0.2776, 0.2884])
names.append("LHipPitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.128898, -0.0843279, -0.223922, -0.400332, 0.131966])
names.append("LHipRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.10282, -0.0168321, -0.0858622, -0.0843279, 0.090548])
names.append("LHipYawPitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.170232, -0.404934, -0.493906, -0.550664, -0.164096])
names.append("LKneePitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.0828778, -0.0828778, 0.714802, 1.07989, -0.092082])
names.append("LShoulderPitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([1.43885, 0.182504, 0.053648, 0.875872, 1.45266])
names.append("LShoulderRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.0858622, -0.306841, -0.30991, 0.00149202, 0.139552])
names.append("LWristYaw")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.0536479, -1.01708, -1.02322, -0.903568, 0.07359])
names.append("RAnklePitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.0859461, 0.388144, 0.520068, 0.53234, 0.096684])
names.append("RAnkleRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.138102, 0.11049, 0.265424, 0.270026, 0.128898])
names.append("RElbowRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.443368, 1.53558, 0.257754, 0.20253, 0.400416])
names.append("RElbowYaw")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([1.15659, 0.88661, 1.04154, 1.03541, 1.18114])
names.append("RHand")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.3132, 0.392, 0.254, 0.2724, 0.2952])
names.append("RHipPitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.139552, -0.170316, -0.397348, -0.37894, 0.138018])
names.append("RHipRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.101202, -0.11194, -0.331302, -0.384992, -0.0950661])
names.append("RHipYawPitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.170232, -0.404934, -0.493906, -0.550664, -0.164096])
names.append("RKneePitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.0904641, -0.0904641, -0.0889301, -0.0923279, -0.0923279])
names.append("RShoulderPitch")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([1.42973, 4.19617e-05, -0.51845, -1.27164, 1.44967])
names.append("RShoulderRoll")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([-0.11049, 0.0628521, -0.642788, -1.04623, -0.162646])
names.append("RWristYaw")
times.append([0.84, 1.72, 3.04, 3.52, 5.16])
keys.append([0.156426, 1.75639, 0.374254, -0.498592, 0.0873961])
motion = ALProxy("ALMotion", self.IP, 9559)
say = shuo(self.IP)
say.run()
motion.angleInterpolation(names, keys, times, True)
示例8: Tracker
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
class Tracker():
def __init__(self):
rospy.init_node('tracker_mykinect', anonymous=True)
self.myFrame = 'kinect_link'
self.r = rospy.Rate(20) #rospy.Rate(1) = 1Hz
#Skeleton Listener
self.tf = tf.TransformListener()
#Nao init and connect
self.nao_init()
self.startXPosition = 0.0;
self.startYPosition = 0.0;
self.naoXPosition = self.startXPosition
self.naoYPosition = self.startYPosition
rospy.loginfo("Start tracking for 3s...")
rospy.sleep(3.0)
rospy.loginfo("Tracking started!")
self.hoh = 0.86 #Nao Hight in meters
for i in range(1, 4):
#Get all nessecery joins. (Right side = Left side if you stand front to sensor)
try:
self.j_head = "{0}_{1}".format(rospy.get_param('~target_joint', '/head'), i)
self.j_l_hand = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_hand'), i)
self.j_r_hand = "{0}_{1}".format(rospy.get_param('~target_joint', '/right_hand'), i)
self.j_l_shoul = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_shoulder'), i)
self.j_torso = "{0}_{1}".format(rospy.get_param('~target_joint', '/torso'), i)
self.j_l_ehand = "{0}_{1}".format(rospy.get_param('~target_joint', '/left_elbow'), i)
self.j_r_ehand = "{0}_{1}".format(rospy.get_param('~target_joint', '/right_elbow'), i)
break
except:
pass
def toRAD(self,angle):
return angle*almath.TO_RAD
def nao_init(self):
#NAO CONNECT AND INIT
# PORT AND IP NAO ROBOT
#ip = rospy.get_param('~ip', '127.0.0.1')
#port = int(rospy.get_param('~port', '51888'))
ip = rospy.get_param('~ip', '10.104.16.53')
port = int(rospy.get_param('~port', '9559'))
self.al = ALProxy("ALAutonomousLife", ip, port)
self.postureProxy = ALProxy("ALRobotPosture", ip, port)
self.tts = ALProxy("ALTextToSpeech", ip, port)
self.motionProxy = ALProxy("ALMotion", ip, port)
self.behavior = ALProxy("ALBehaviorManager",ip,port)
self.mistake = almath.Pose2D(self.motionProxy.getRobotPosition(False))
#self.audioProxy = ALProxy("ALSpeechRecognition",ip,port)
#self.audioProxy.setLanguage("English")
#vocabulary = ["go"]
#self.audioProxy.setVocabulary(vocabulary, False)
#self.al.setState("disabled")
#self.postureProxy.goToPosture("StandInit", 0.5)
#ALProxy("ALBasicAwareness", ip, port).stopAwareness()
#self.motionProxy.setFallManagerEnabled(False)
self.motionProxy.setExternalCollisionProtectionEnabled("All",False)
def nao_hello(self):
#Nao hello module
#self.postureProxy.goToPosture("StandInit",1.0)
self.behavior.stopAllBehaviors()
self.motionProxy.setAngles('RShoulderPitch',self.toRAD(-97.3),1.0)
self.motionProxy.setAngles('RShoulderRoll',self.toRAD(-39.2),1.0)
self.motionProxy.setAngles('RElbowRoll',self.toRAD(50.8),1.0)
self.motionProxy.setAngles('RElbowYaw',self.toRAD(8.5),1.0)
self.motionProxy.setAngles('RWristYaw',self.toRAD(-13.4),1.0)
self.motionProxy.openHand('RHand')
thread.start_new_thread((lambda:self.tts.say("Hello my friend")),())
for i in range(0,2):
self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(-12.2),0.3,True)
self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(39.2),0.3,True)
self.motionProxy.angleInterpolation("RShoulderRoll",self.toRAD(-50.4),0.3,True)
self.postureProxy.goToPosture("StandInit",1.0)
self.behavior.runBehavior('nao-14eaf5/BogdAL')
def nao_sensei(self):
#Nao hello(sensei) module
self.behavior.stopAllBehaviors()
self.postureProxy.goToPosture("StandInit",1.0)
self.motionProxy.setAngles(['RShoulderPitch','LShoulderPitch'],[self.toRAD(52.7),self.toRAD(49.1)],1.0)
self.motionProxy.setAngles(['RShoulderRoll','LShoulderRoll'],[self.toRAD(13.3),self.toRAD(-8.9)],1.0)
self.motionProxy.setAngles(['RElbowRoll','LElbowRoll'],[self.toRAD(88.3),self.toRAD(-87.6)],1.0)
self.motionProxy.setAngles(['RElbowYaw','LElbowYaw'],[self.toRAD(68.1),self.toRAD(-60.9)],1.0)
self.motionProxy.setAngles(['RWristYaw','LWristYaw'],[self.toRAD(-10.3),self.toRAD(11.0)],1.0)
self.motionProxy.setAngles(['RHand','LHand'],[self.toRAD(-10.3),self.toRAD(11.0)],1.0)
self.motionProxy.openHand('RHand')
self.motionProxy.openHand('LHand')
#sequence head
self.tts.say("Domo Arigato")
#self.motionProxy.angleInterpolation("HeadPitch",0.0,1.0,True)
self.motionProxy.angleInterpolation("HeadPitch",self.toRAD(26.5),1.0,True)
self.motionProxy.angleInterpolation("HeadPitch",0.0,1.0,True)
self.postureProxy.goToPosture("StandInit",1)
#.........这里部分代码省略.........
示例9: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
from naoqi import ALProxy
from naoconfig import *
proxyMo = ALProxy('ALMotion',robot_IP,robot_port)
proxyMo.stiffnessInterpolation('Body', 1.0, 1.0)
proxyMo.angleInterpolation(['LHand','RHand'], [[1.0],[1.0]], [[1.0],[1.0]], True)
proxyMo.angleInterpolation(['LHand','RHand'], [[0.0],[0.0]], [[1.0],[1.0]], True)
proxyMo.angleInterpolation(['LHand','RHand'], [[0.5],[0.5]], [[1.0],[1.0]], True)
示例10: run
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
#.........这里部分代码省略.........
names.append("LAnkleRoll")
times.append([1, 2.56])
keys.append([-0.122678, -0.122678])
names.append("LElbowRoll")
times.append([1, 2.56])
keys.append([-0.4034, -0.446352])
names.append("LElbowYaw")
times.append([1, 2.56])
keys.append([-1.2165, -1.32082])
names.append("LHand")
times.append([1, 2.56])
keys.append([0.2896, 0.2896])
names.append("LHipPitch")
times.append([1, 2.56])
keys.append([0.127364, 0.127364])
names.append("LHipRoll")
times.append([1, 2.56])
keys.append([0.0951499, 0.0951499])
names.append("LHipYawPitch")
times.append([1, 2.56])
keys.append([-0.168698, -0.168698])
names.append("LKneePitch")
times.append([1, 2.56])
keys.append([-0.0923279, -0.0923279])
names.append("LShoulderPitch")
times.append([1, 2.56])
keys.append([1.4818, -0.320648])
names.append("LShoulderRoll")
times.append([1, 2.56])
keys.append([0.168698, 0.27301])
names.append("LWristYaw")
times.append([1, 2.56])
keys.append([0.0797259, -0.39428])
names.append("RAnklePitch")
times.append([1, 2.56])
keys.append([0.0813439, 0.092082])
names.append("RAnkleRoll")
times.append([1, 2.56])
keys.append([0.127364, 0.127364])
names.append("RElbowRoll")
times.append([1, 2.56])
keys.append([0.415757, 1.54018])
names.append("RElbowYaw")
times.append([1, 2.56])
keys.append([1.21028, 0.697927])
names.append("RHand")
times.append([1, 2.56])
keys.append([0.2908, 0.2908])
names.append("RHipPitch")
times.append([1, 2.56])
keys.append([0.128814, 0.128814])
names.append("RHipRoll")
times.append([1, 2.56])
keys.append([-0.093532, -0.093532])
names.append("RHipYawPitch")
times.append([1, 2.56])
keys.append([-0.168698, -0.168698])
names.append("RKneePitch")
times.append([1, 2.56])
keys.append([-0.0827939, -0.0827939])
names.append("RShoulderPitch")
times.append([1, 2.56])
keys.append([1.45888, 0.773177])
names.append("RShoulderRoll")
times.append([1, 2.56])
keys.append([-0.170316, 0.233125])
names.append("RWristYaw")
times.append([1, 2.56])
keys.append([0.0904641, 0.444818])
motion = ALProxy("ALMotion", self.IP, 9559)
tosay = shuo(self.IP)
motion.angleInterpolation(names, keys, times, True)
tosay.run()
time.sleep(0.8)
posture = ALProxy("ALRobotPosture", self.IP, 9559)
posture.goToPosture("Stand", 0.5)
示例11: motion_module
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
#.........这里部分代码省略.........
shoulder_pitch_position_default = 1.45726
shoulder_pitch_range = 0.5
shoulder_pitch_scaled_to_dominance = dominance * shoulder_pitch_range
shoulder_pitch_scaled_to_pleasure = pleasure * shoulder_pitch_range
shoulder_pitch_dominance = shoulder_pitch_position_default - shoulder_pitch_scaled_to_dominance
shoulder_pitch_pleasure = shoulder_pitch_position_default - shoulder_pitch_scaled_to_pleasure
shoulder_pitch = (shoulder_pitch_dominance + shoulder_pitch_pleasure) / 2
# TODO: does shoulder_pitch need limited?
motion_names.append("LShoulderPitch")
motion_times.append([t1, t2, t3])
motion_keys.append([shoulder_pitch_position_default, shoulder_pitch, shoulder_pitch_position_default])
motion_names.append("RShoulderPitch")
motion_times.append([t1, t2, t3])
motion_keys.append([shoulder_pitch_position_default, shoulder_pitch, shoulder_pitch_position_default])
# Ankles have a pitch of approx +0.9 to -1.1radians.
# Used in absolute mode, central pitch value is 0.08radians.
# Scaled: current dominance / max dominance = current range / max range
ankle_pitch_position_default = 0.06
ankle_pitch_range = 0.1
ankle_pitch_range_scaled_to_dominance = dominance * ankle_pitch_range
ankle_pitch_range_scaled_to_pleasure = pleasure * ankle_pitch_range
ankle_pitch_dominance = ankle_pitch_position_default - ankle_pitch_range_scaled_to_dominance
ankle_pitch_pleasure = ankle_pitch_position_default - ankle_pitch_range_scaled_to_pleasure
ankle_pitch = (ankle_pitch_dominance + ankle_pitch_pleasure) / 2
# Limit ankle pitch to prevent falls
ankle_pitch_limit = 0.12
if ankle_pitch > ankle_pitch_limit:
ankle_pitch = ankle_pitch_limit
motion_names.append("LAnklePitch")
motion_times.append([t1, t2, t3])
motion_keys.append([ankle_pitch_position_default, ankle_pitch, ankle_pitch_position_default])
motion_names.append("RAnklePitch")
motion_times.append([t1, t2, t3])
motion_keys.append([ankle_pitch_position_default, ankle_pitch, ankle_pitch_position_default])
# Position on ground = proportional to dominance AND pleasure, only activated by strong values.
walk_activation_threshold = 0.8
walk_distance = 0.1 # meters
if (abs(dominance) > walk_activation_threshold):
walk_dominance = math.copysign(walk_distance, dominance)
if (abs(pleasure) > walk_activation_threshold):
walk_pleasure = math.copysign(walk_distance, pleasure)
walk = walk_dominance + walk_pleasure
# Stance openness (shoulder roll) = proportional to pleasure
# Shoulder roll ranges -1.3265 to 0.3142radians.
# Used in absolute mode, central roll value is right -0.16radians, left 0.16radians.
shoulder_roll_move = 0.3
shoulder_roll_right = -0.16 - shoulder_roll_move * pleasure
shoulder_roll_left = 0.16 + shoulder_roll_move * pleasure
motion_names.append("RShoulderRoll")
motion_times.append([t1, t2, t3])
motion_keys.append([-0.16, shoulder_roll_right, -0.16])
motion_names.append("LShoulderRoll")
motion_times.append([t1, t2, t3])
motion_keys.append([0.16, shoulder_roll_left, 0.16])
# Head pitch - directly 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
motion_names.append("HeadPitch")
motion_times.append([t1, t2, t3])
motion_keys.append([0.0, head_pitch, 0.0])
# TODO: height, how ??? Whole Body Balancer ??
# TODO: Might be better to use the reactive methods - ALMotionProxy::setAngles(). or Whole Body Balancer.
# TODO: add walk, whilst running motion.angleInterpolation in background.
try:
self.motion.angleInterpolation(motion_names, motion_keys, motion_times, True)
except Exception, e:
print "Motion exception, ", e
print "pleasure: ", pleasure
print "arousal: ", arousal
print "dominance: ", dominance
print "t1: ", t1
print "shoulder_pitch: ", shoulder_pitch
print "ankle_pitch: ", ankle_pitch
print "walk: ", walk
print "shoulder_roll_right: ", shoulder_roll_right
print "shoulder_roll_left: ", shoulder_roll_left
print "head_pitch: ", head_pitch
print "---------- done ----------"
memory.subscribeToEvent("TouchChanged", self.getName(), "emotive_motion")
示例12: movefunc
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
def movefunc(self,a):
"""method to move head"""
motion=ALProxy("ALMotion")
print 'Head is moving!'
motion.angleInterpolation ("HeadPitch", a, 2.0, True)
示例13: motion_module
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
class motion_module(ALModule):
""" A simple module to change the head position and stance to represent emotions.
"""
def __init__(self, name):
ALModule.__init__(self, name)
# Create proxies for the instance.
self.motion = ALProxy("ALMotion")
# Run behaviour when a tactile touched.
global memory
memory = ALProxy("ALMemory")
memory.subscribeToEvent("TouchChanged", self.getName(), "emotive_motion")
def emotive_motion(self, *_args):
""" Changes head position based on arousal and stance based on valence.
"""
memory.unsubscribeToEvent("TouchChanged", self.getName())
motion_names = list()
motion_times = list()
motion_keys = list()
current_emotion = memory.getData("Emotion/Current")
valence = current_emotion[0][0]
arousal = current_emotion[0][1]
# Head pitch - directly 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
motion_names.append("HeadPitch")
motion_times.append([1, 2, 3])
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([1, 2, 3])
motion_keys.append([1.45726, shoulder_pitch, 1.45726])
motion_names.append("RShoulderPitch")
motion_times.append([1, 2, 3])
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([1, 2, 3])
motion_keys.append([0.08, ankle_pitch, 0.08])
motion_names.append("RAnklePitch")
motion_times.append([1, 2, 3])
motion_keys.append([0.08, ankle_pitch, 0.08])
# Might be better to use the reactive methods - ALMotionProxy::setAngles().
self.motion.angleInterpolation(motion_names, motion_keys, motion_times, True)
print "done"
memory.subscribeToEvent("TouchChanged", self.getName(), "emotive_motion")
示例14: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
keys.append([ 0.11356, 0.11356, 0.11356, 0.11356, 0.10589, 0.10589, 0.10589, 0.09055, 0.07367, 0.07214, 0.07214, 0.06907, 0.06294, 0.05220, 0.04913, 0.04913, 0.05066, 0.05066, 0.05066, 0.05066, 0.05066, 0.05066, 0.05066, 0.05066, 0.04913, 0.05373, 0.08595])
names.append("RAnkleRoll")
times.append([ 0.04000, 0.20000, 0.40000, 0.60000, 0.80000, 1.00000, 1.20000, 1.40000, 1.60000, 1.80000, 2.00000, 2.20000, 2.40000, 2.60000, 3.08000, 3.52000, 3.88000, 4.28000, 4.48000, 4.64000, 4.80000, 4.96000, 5.12000, 5.32000, 5.52000, 5.68000, 5.88000])
keys.append([ 0.05066, 0.05066, 0.02765, -0.02450, -0.09507, -0.13342, -0.16716, -0.21165, -0.24847, -0.24693, -0.24693, -0.24693, -0.26227, -0.31136, -0.32210, -0.32977, -0.33284, -0.33284, -0.33437, -0.33437, -0.33437, -0.33437, -0.31750, -0.30216, -0.20091, -0.03217, 0.02919])
names.append("RHipPitch")
times.append([ 0.04000, 0.20000, 0.40000, 0.60000, 0.80000, 1.00000, 1.20000, 1.40000, 1.60000, 1.80000, 2.00000, 2.20000, 2.40000, 2.60000, 3.08000, 3.52000, 3.88000, 4.28000, 4.48000, 4.64000, 4.80000, 4.96000, 5.12000, 5.32000, 5.52000, 5.68000, 5.88000])
keys.append([ 0.12881, 0.13035, 0.14109, 0.14415, 0.15949, 0.17330, 0.18097, 0.18250, 0.18250, 0.18097, 0.17944, 0.17944, 0.18097, 0.18250, 0.18250, 0.18250, 0.18250, 0.18250, 0.18404, 0.18404, 0.18404, 0.18404, 0.22392, 0.22239, 0.22239, 0.21932, 0.15029])
names.append("RHipRoll")
times.append([ 0.04000, 0.20000, 0.40000, 0.60000, 0.80000, 1.00000, 1.20000, 1.40000, 1.60000, 1.80000, 2.00000, 2.20000, 2.40000, 2.60000, 3.08000, 3.52000, 3.88000, 4.28000, 4.48000, 4.64000, 4.80000, 4.96000, 5.12000, 5.32000, 5.52000, 5.68000, 5.88000])
keys.append([ -0.04444, -0.04444, -0.02297, 0.01231, 0.08748, 0.14577, 0.20560, 0.23014, 0.23321, 0.23321, 0.23321, 0.23321, 0.23321, 0.24395, 0.24702, 0.24702, 0.24855, 0.24855, 0.24855, 0.24702, 0.24855, 0.24702, 0.30684, 0.28230, 0.20560, 0.05987, 0.01692])
names.append("RHipYawPitch")
times.append([ 0.04000, 0.20000, 0.40000, 0.60000, 0.80000, 1.00000, 1.20000, 1.40000, 1.60000, 1.80000, 2.00000, 2.20000, 2.40000, 2.60000, 3.08000, 3.52000, 3.88000, 4.28000, 4.48000, 4.64000, 4.80000, 4.96000, 5.12000, 5.32000, 5.52000, 5.68000, 5.88000])
keys.append([ -0.17637, -0.17637, -0.17330, -0.16563, -0.14415, -0.11808, -0.10120, -0.07819, -0.06132, -0.06132, -0.06132, -0.06132, -0.05518, -0.04444, -0.04291, -0.04291, -0.04291, -0.04291, -0.04291, -0.04291, -0.04291, -0.04291, -0.12575, -0.12268, -0.10734, -0.10734, -0.14415])
names.append("RKneePitch")
times.append([ 0.04000, 0.20000, 0.40000, 0.60000, 0.80000, 1.00000, 1.20000, 1.40000, 1.60000, 1.80000, 2.00000, 2.20000, 2.40000, 2.60000, 3.08000, 3.52000, 3.88000, 4.28000, 4.48000, 4.64000, 4.80000, 4.96000, 5.12000, 5.32000, 5.52000, 5.68000, 5.88000])
keys.append([ -0.09046, -0.09046, -0.08893, -0.09046, -0.09046, -0.09046, -0.08893, -0.09046, -0.08893, -0.08893, -0.08893, -0.08893, -0.09046, -0.09046, -0.09046, -0.09046, -0.08893, -0.09046, -0.08893, -0.08893, -0.08893, -0.08893, -0.08740, -0.08893, -0.08893, -0.08740, -0.08740])
try:
# uncomment the following line and modify the IP if you use this script outside Choregraphe.
# motion = ALProxy("ALMotion", IP, 9559)
motion = ALProxy("ALMotion")
motion.angleInterpolation(names, keys, times, True);
except BaseException, err:
print err
示例15: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import angleInterpolation [as 别名]
#.........这里部分代码省略.........
MOTION.moveTo(0,0,redBallInfo[1],moveConfig)
time.sleep(0.5)
MOTION.moveTo(0.60, MoveDirectYOffSet, MoveDirectAngleOffSet,moveConfig)
time.sleep(0.5)
if(redBallInfo[0] - 0.60 < 0.60):
redBallInfo = redBallDetection(red_thresholdMin, red_thresholdMax, False, redBallDetectMethod, 0, robotIP, port)
break
if(redBallInfo[0] - 0.60 >= 1.2):
redBallInfo = redBallDetection(red_thresholdMin, red_thresholdMax, True, redBallDetectMethod, 0, robotIP, port)
else:
redBallInfo = redBallDetection(red_thresholdMin, red_thresholdMax, False, redBallDetectMethod, 0, robotIP, port)
#移动到机器人30cm前
MOTION.moveTo(0,0,redBallInfo[1],moveConfig)
time.sleep(0.5)
MOTION.moveTo(redBallInfo[0]-0.40, MoveDirectYOffSet/2, MoveDirectAngleOffSet/2, moveConfig)
#最后一次对红球的校准
redBallInfo = redBallDetection(red_thresholdMin, red_thresholdMax, False, redBallDetectMethod, 20, robotIP, port)
MOTION.moveTo(0,0,redBallInfo[1],moveConfig)
time.sleep(0.5)
MOTION.moveTo(redBallInfo[0]-0.3,0,0,moveConfig)
#-----------------------高尔夫击球第三个阶段,后两个球洞的黄杆识别--------------------------------------#
if(holeFlag == 2 or holeFlag == 3):
#三点一线,第一次移动
redBallInfo = redBallInfo = redBallDetection(red_thresholdMin, red_thresholdMax, False, redBallDetectMethod, 20, robotIP, port)
stickInfo = yellowStickDetection(yellow_thresholdMin, yellow_thresholdMax, robotIP, port)
theta,x,y = calculation(redBallInfo,stickInfo)
robotRotate(theta, robotIP, port)
time.sleep(0.5)
MOTION.moveTo(x-0.3,0.0,0.0,moveConfig)
time.sleep(0.5)
MOTION.moveTo(0.0,y,0.0,moveConfig)
MOTION.angleInterpolation("HeadYaw",0,0.5,True)
#校准,第二次移动
redBallInfo = redBallInfo = redBallDetection(red_thresholdMin, red_thresholdMax, False, redBallDetectMethod, 20, robotIP, port)
stickInfo = yellowStickDetection(yellow_thresholdMin, yellow_thresholdMax, robotIP, port)
theta,x,y = calculation(redBallInfo,stickInfo)
robotRotate(theta, robotIP, port)
time.sleep(0.5)
MOTION.moveTo(x-0.2,0.0,0.0,moveConfig)
time.sleep(0.5)
MOTION.moveTo(0.0,y,0.0,moveConfig)
MOTION.angleInterpolation("HeadYaw",0,0.5,True)
#击球
MOTION.moveTo(0.0, 0.0, math.pi/2-AngleOffSetBeforeHitBall, moveConfig)
time.sleep(0.5)
MOTION.moveTo(XOffSetBeforeHitBall, 0.0, 0.0, moveConfig)
time.sleep(0.5)
MOTION.moveTo(0.0, YOffSetBeforeHitBall, 0.0, moveConfig)
redBallInfo = redBallDetection(red_thresholdMin, red_thresholdMax, False, redBallDetectMethod, 20, robotIP, port)
MOTION.moveTo(redBallInfo[0]*math.cos(redBallInfo[1])-HitBallDist, 0, 0,moveConfig)
time.sleep(0.5)
if(holeFlag == 2):
hitBall(HitBallSpeed_SecondHole_Num_2, robotIP, port)
elif(holeFlag == 3):
hitBall(HitBallSpeed_ThirdHole_Num_2, robotIP, port)
time.sleep(0.5)
raiseStick(robotIP, port)
standWithStick(0.1, robotIP, port)
MOTION.moveTo(0, 0, -math.pi/2+10*math.pi/180.0, moveConfig)
time.sleep(0.5)