本文整理汇总了Python中naoqi.ALProxy.getAngles方法的典型用法代码示例。如果您正苦于以下问题:Python ALProxy.getAngles方法的具体用法?Python ALProxy.getAngles怎么用?Python ALProxy.getAngles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类naoqi.ALProxy
的用法示例。
在下文中一共展示了ALProxy.getAngles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FaceTracker
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [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()
示例2: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
def main(robot_IP, robot_PORT=9559):
# ----------> Connect to robot <----------
global tts, motion
tts = ALProxy("ALTextToSpeech", robot_IP, robot_PORT)
motion = ALProxy("ALMotion", robot_IP, robot_PORT)
# ----------> get angle <----------
# myGetAngles('Body', False)
# myGetAngles('Body', True) # 使用传感器检测会更加准确
# myGetAngles('Joints', False)
motion.setStiffnesses("Body", 1.0)
while True:
print motion.getAngles('HeadPitch', True)
time.sleep(0.5)
示例3: init
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
def init(ip='127.0.0.1', port=9559):
global myBroker
myBroker = ALBroker('myBroker', '0.0.0.0', 0, ip, port)
motion = ALProxy("ALMotion")
motion.setStiffnesses('Body', .3)
motion.setAngles('Body', motion.getAngles('Body', True), 1)
time.sleep(1)
motion.setStiffnesses('Body', 0)
示例4: TestModule
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
class TestModule(ALModule):
"""A module used for testing Nao's functionality"""
def __init__(self, var_name):
"""Define the module's attributes and initialize their value"""
# Request the parent module to initialize and register the module
ALModule.__init__(self, var_name)
# Declare the memory
global memory
memory = ALProxy("ALMemory")
# Initialize a motion module
self.motion = ALProxy("ALMotion")
# Initialize a posture module
self.posture = ALProxy("ALRobotPosture")
def initialize(self):
"""Initialize the inner modules of the module"""
# Wake the robot up
self.motion.wakeUp()
# Enable the whole body motion
self.motion.wbEnable(True)
def shutdown(self):
"""Shut the module down gracefully"""
# Disable the whole body motion
self.motion.wbEnable(False)
# Put the robot to rest
self.motion.rest()
def kick(self):
"""Define the procedure to follow to accomplish a kick"""
# Go to stand init posture
self.posture.goToPosture("StandInit", 0.5)
# Define the joints we are interested in
hip_joints = ["RHipRoll", "LHipRoll"]
# Get the angles for HipRolls
angles = self.motion.getAngles(hip_joints, True)
# Modify the value of the hip rolls
angles[0] -= 10 * almath.TO_RAD
angles[1] += 10 * almath.TO_RAD
# Set the angles to have Nao stand on one foot
self.motion.setAngles(hip_joints, angles, 0.2)
# Wait for some time
sleep(5)
# Go back to stand init posture
self.posture.goToPosture("StandInit", 0.5)
示例5: __init__
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
class MoveNao:
def __init__(self, ip, port):
self.__proxy = ALProxy("ALMotion", ip, port)
self.__proxyPosture = ALProxy("ALRobotPosture", ip, port)
self.__walk_sub = rospy.Subscriber(
_Constants.joy_topic,
Walk_control,
self.walk)
self.__subs = rospy.Subscriber(
_Constants.msg_topic,
String,
self.go_to_posture)
self.__move_head_sub = rospy.Subscriber(
_Constants.move_head_topic,
MoveHead,
self.look )
def walk(self, msg):
angular = msg.angular
linear = msg.linear
self.__proxy.move(
linear * _Constants.linear_factor, # Forwards
0.0, #Sideways
angular * _Constants.angular_factor ) #Turning
def go_to_posture(self, msg):
self.__proxyPosture.goToPosture(msg.data, 1.0)
def look(self, msg):
joint_names = ["HeadYaw", "HeadPitch"]
current = self.__proxy.getAngles( joint_names, False )
yaw = current[0] + msg.yaw
pitch = current[1] + msg.pitch
#rospy.logwarn("got here 0")
#rospy.logwarn(yaw)
#rospy.logwarn(pitch)
#Make sure we don't exceed angle limits
if yaw < _Constants.yaw_limits[0]:
yaw = _Constants.yaw_limits[0]
elif yaw > _Constants.yaw_limits[1]:
yaw = _Constants.yaw_limits[1]
if pitch < _Constants.pitch_limits[0]:
pitch = _Constants.pitch_limits[0]
elif pitch > _Constants.pitch_limits[1]:
pitch = _Constants.pitch_limits[1]
#rospy.logwarn("got here 1")
self.__proxy.setStiffnesses("Head", 1.0)
self.__proxy.angleInterpolationWithSpeed(
joint_names,
[ yaw, pitch ],
_Constants.head_speed)
time.sleep(0.5)
self.__proxy.setStiffnesses("Head", 0.0)
示例6: RobotAngle
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
class RobotAngle():
def __init__(self, host_name, port):
self.motionProxy = ALProxy("ALMotion", host_name, port)
self.head_joints = ["HeadPitch", "HeadYaw"]
self.hand_joints = ["LShoulderRoll", "LShoulderPitch", "LElbowRoll", "LElbowYaw", "RShoulderRoll",
"RShoulderPitch",
"RElbowRoll",
"RElbowYaw"]
def get_head_angles(self):
sensor_angles = self.motionProxy.getAngles(self.head_joints, True)
print "Head Pitch and Yaw:"
print str(sensor_angles)
def get_hand_angles(self):
sensor_angles = self.motionProxy.getAngles(self.hand_joints, True)
print "Shoulder and Elbow:"
print str(sensor_angles)
示例7: NaoWalks
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
class NaoWalks(ALModule, Thread):
"""docstring for NaoWalks"""
def __init__(self, name):
Thread.__init__(self)
ALModule.__init__(self, name)
# Create new object display a colored message on computer's terminal.
self.logs = logs()
# Create an ALMotion proxy.
self.motion = ALProxy("ALMotion")
self.logs.display("Subscribed to an ALMotion proxy", "Good")
# Method called by the Thread.start() method.
def run(self):
global direction
global alpha
global directions
self.motion.post.angleInterpolation(["HeadYaw"],
alpha,
1,
False)
direction = self.motion.getAngles("HeadYaw", True)
try:
if (direction.pop() != directions.pop()):
directions.append(direction.pop())
self.stop()
self.logs.display("Nao is walking in direction (radian):",
"Default",
str(direction.pop()))
self.motion.moveTo(0.2, 0, direction.pop())
except IndexError:
pass
global AnalyseANewPict
AnalyseANewPict = True
# Method called to stop Nao.
def stop(self):
self.motion.killMove()
# Method called to properly delete the thread.
def delete(self):
self.motion.killMove()
# ############################### END OF CLASS ############################## #
示例8: getAnglesInfo
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
def getAnglesInfo(names,useSensors):
# Puase to be able to read info
time.sleep(1.00)
MP = ALProxy("ALMotion", ROBOT_IP_GLOBAL, PORT2)
#test
print "::getAnglesInfo__"
anglesPrint = MP.getAngles(names,useSensors)
print "::MP___________:",MP
#print "::Name_________:",names
#print "::angleLists___:",angleLists
print "::angles_______:",anglesPrint
示例9: NaoValuesSender
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
class NaoValuesSender(OpenRTM_aist.DataFlowComponentBase):
def __init__(self, manager):
OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
return
def onInitialize(self):
self.naoMotionProxy = ALProxy('ALMotion', NAO_IP, PORT)
self._data = RTC.TimedDouble(RTC.Time(0,0),0)
self._outport = OpenRTM_aist.OutPort("out", self._data)
# Set OutPort buffer
self.addOutPort("out", self._outport)
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_WRITE, DataListener("ON_BUFFER_WRITE"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_FULL, DataListener("ON_BUFFER_FULL"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_WRITE_TIMEOUT, DataListener("ON_BUFFER_WRITE_TIMEOUT"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_OVERWRITE, DataListener("ON_BUFFER_OVERWRITE"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_BUFFER_READ, DataListener("ON_BUFFER_READ"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_SEND, DataListener("ON_SEND"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVED, DataListener("ON_RECEIVED"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_FULL, DataListener("ON_RECEIVER_FULL"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_TIMEOUT, DataListener("ON_RECEIVER_TIMEOUT"))
self._outport.addConnectorDataListener(OpenRTM_aist.ConnectorDataListenerType.ON_RECEIVER_ERROR, DataListener("ON_RECEIVER_ERROR"))
self._outport.addConnectorListener(OpenRTM_aist.ConnectorListenerType.ON_CONNECT, ConnectorListener("ON_CONNECT"))
self._outport.addConnectorListener(OpenRTM_aist.ConnectorListenerType.ON_DISCONNECT, ConnectorListener("ON_DISCONNECT"))
return RTC.RTC_OK
def onExecute(self, ec_id):
print "Hit any key...",
sys.stdin.readline()
names = "Body"
useSensors = True
sensorAngles = self.naoMotionProxy.getAngles(names, useSensors)
print "Sleep before sending data....\n"
time.sleep(2)
print "Go \n"
#TODO: use TimedDoubleSeq data port type
for i in range(0, len(sensorAngles)):
time.sleep(0.5)
self._data.data = sensorAngles[i]
OpenRTM_aist.setTimestamp(self._data)
print "Sending to subscriber: ", self._data.data
self._outport.write()
return RTC.RTC_OK # Hit any key... for all values
return RTC.RTC_OK
示例10: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
def main(robotIP, x, y, theta, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
# Wake up robot
# Maybe not needed
motionProxy.wakeUp()
# Send robot to Pose Init
# Maybe not needed
postureProxy.goToPosture("StandInit", 0.5)
# Example showing the moveTo command
# The units for this command are meters and radians
current_head_angle = motionProxy.getAngles("HeadPitch", True)
print "Command angles <True>:"
print str(current_head_angle)
print ""
motionProxy.moveTo(x, y, theta - current_head_angle[0])
示例11: Nao
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
#.........这里部分代码省略.........
def is_speaking(self):
if self.simulation:
return False
else:
is_done_speaking = self.__Memory.getData("ALTextToSpeech/TextDone")
if not is_done_speaking == None:
is_done_speaking = int(is_done_speaking)
if is_done_speaking == 0:
return True
return False
def say(self, Text, filename=None):
if self.__TTS:
#self.__TTS.say(str(Text))
if filename:
self.__TTS.sayToFile(Text, filename)
else:
self.__TTS.post.say(Text)
else:
print "[Nao says] " + Text
def get_sonar_distance(self):
# sonarValue= "SonarLeftDetected"
if self.__Sonar:
# data = self.__Sonar.getOutputNames()
data = {"left": self.__Memory.getData("SonarLeftDetected",0), "right" : self.__Memory.getData("SonarRightDetected",0)}
return data
def get_yaw_pitch(self):
#Get Nao's yaw and pitch neck angles in RADIANS:
names = "Body"
useSensors = True
sensorAngle = self.__Motion.getAngles(names, useSensors)
headYaw = sensorAngle[0]
headPitch = sensorAngle[1]
return [headYaw, headPitch]
def get_robot_ip(self):
'''
Returns the IP address as specified in the constructor.
'''
return self.__robot_ip
def get_port(self):
'''
Returns the port as specified in the constructor.
'''
return self.__port
def start_behavior(self, behaviorname, local=False):
"""
Start a behavior from choregraph which is stored on the robot.
The local parameter specifies that the file should be loaded from the
local filesystem instead of from the robot.
"""
behaviorID = self.get_behavior_id(behaviorname, local)
if behaviorID:
self.__FM.playBehavior(behaviorID)
def complete_behavior(self, behaviorname, local=False):
"""
Start a behavior from choregraph which is stored on the robot. Waits for
the behavior to finish. The behavior should call it's output, otherwise
this method will get stuck
The local parameter specifies that the file should be loaded from the
示例12: NaoSoundTrack
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
class NaoSoundTrack(ALModule):
'''
This is the module that connects remotely to the NAO microphones
'''
def __init__(self, name, ip, port):
#Init parent
super(NaoSoundTrack, self).__init__(name)
self.__ip = ip
self.__port = port
#self.__pub = rospy.Publisher(_Constants.topic, MoveHead , latch=True, queue_size =1000)
self.__facepub = rospy.Publisher(_Constants.face_det_topic, Face_detection , latch=True, queue_size =1000)
self.__CNCsub = rospy.Subscriber(_Constants.face_track_topic, String, self.start_sound_track)
self.__faceRessub = rospy.Subscriber(_Constants.face_res_topic, Face_detection, self.stop_sound_track)
def start_sound_track(self, msg):
self.__proxyTTS = ALProxy("ALAnimatedSpeech", self.__ip, self.__port)
# set the local configuration
sayconfig = {"bodyLanguageMode":"contextual"}
self.__proxyTTS.say("Can you help me find you by clapping your hand?", sayconfig)
self.__proxyMotion = ALProxy("ALMotion", self.__ip, self.__port)
#initialise microphone
#self.__audioProxy = ALProxy("ALAudioDevice", self.__ip, self.__port)
#initialise soundsourcelocalisation
self.__sslProxy = ALProxy("ALSoundLocalization", self.__ip, self.__port)
#initialise almemory
self.__memoryProxy = ALProxy("ALMemory", self.__ip, self.__port)
#debugging purpose
#self.__audioProxy.setClientPreferences( self.getName() , 16000, 3, 0 )
#self.__audioProxy.subscribe(self.getName())
#configure sound detection
self.__sslProxy.setParameter("Sensitivity",0.1)
#callback from memory
try:
self.__memoryProxy.unsubscribeToEvent("ALSoundLocalization/SoundLocated","soundtracking")
except:
pass
self.__sslProxy.subscribe("sound_source_locator")
self.__memoryProxy.subscribeToMicroEvent(
"ALSoundLocalization/SoundLocated",
self.getName(),
"AnotherUserDataToIdentifyEvent",
"sound_callback")
def stop_sound_track(self, msg):
self.__memoryProxy.unsubscribeToMicroEvent("ALSoundLocalization/SoundLocated",self.getName())
self.__sslProxy.unsubscribe("sound_source_locator")
rospy.logwarn("sound localisation stopped")
#self.__audioProxy.unsubscribe(self.getName())
def reset_sensitivity(self,msg):
if(msg.enable):
self.__sslProxy.setParameter("Sensitivity", msg.sensitivity)
rospy.logwarn(msg.sensitivity)
def sound_callback(self, event, val, msg):
"""Deal with sound localisation event"""
rospy.loginfo('sound location' + str(val[1][0])+str(val[1][1]))
rospy.loginfo('confidence' + str(val[1][2]))
#self.__TTSproxy.say("sound detected")
#self.__pub.publish(val[1][0],val[1][1])
rospy.logwarn("Moving Head to Sound")
joint_names = ["HeadYaw", "HeadPitch"]
current = self.__proxyMotion.getAngles( joint_names, False )
yaw = current[0] + val[1][0]
pitch = current[1] + val[1][1]
#Make sure we don't exceed angle limits
if yaw < _Constants.yaw_limits[0]:
yaw = _Constants.yaw_limits[0]
elif yaw > _Constants.yaw_limits[1]:
yaw = _Constants.yaw_limits[1]
if pitch < _Constants.pitch_limits[0]:
pitch = _Constants.pitch_limits[0]
elif pitch > _Constants.pitch_limits[1]:
pitch = _Constants.pitch_limits[1]
self.__proxyMotion.setStiffnesses("Head", 1.0)
self.__proxyMotion.angleInterpolationWithSpeed(
joint_names,
[ yaw, pitch ],
_Constants.head_speed)
time.sleep(2.0)
#self.__proxyMotion.setStiffnesses("Head", 0.0)
#.........这里部分代码省略.........
示例13: ALProxy
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
from naoqi import ALProxy
motionProxy = ALProxy("ALMotion", "nao2.local", 9559)
# names = ["LShoulderRoll", "LShoulderPitch", "LElbowRoll", "LElbowYaw","RShoulderRoll", "RShoulderPitch", "RElbowRoll", "RElbowYaw"]
# sensorAngles = motionProxy.getAngles(names, True)
# print "Angles:"
# print str(sensorAngles)
# print ""
#
# names = ["Body"]
# sensorAngles = motionProxy.getAngles(names, True)
# print "Body Angles:"
# print str(sensorAngles)
# print ""
names = ["HeadPitch", "HeadYaw"]
sensorAngles = motionProxy.getAngles(names, True)
print "Head Pitch and Yaw:"
print str(sensorAngles)
print ""
# Head Pitch and Yaw:
# [-0.3145120143890381, -0.013848066329956055]
#head reset
# [-0.018450021743774414, -0.009245872497558594]
示例14: main
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
def main(robotIP, PORT=9559):
motionProxy = ALProxy("ALMotion", robotIP, PORT)
postureProxy = ALProxy("ALRobotPosture", robotIP, PORT)
trackerProxy = ALProxy("ALTracker", robotIP, PORT)
camProxy = ALProxy("ALVideoDevice", robotIP, PORT)
resolution = 2 # VGA
colorSpace = 11 # RGB
videoClient = camProxy.subscribe("python_client", resolution, colorSpace, 5)
# Wake up robot
motionProxy.wakeUp()
# Send robot to Stand Init
postureProxy.goToPosture("StandInit", 0.5)
motionProxy.moveInit()
# Move Head to the left
#motionProxy.setAngles("HeadYaw", -math.pi/4.0, 0.6)
trackerProxy.lookAt([-5, 5, 1], 1, 0.2, False)
time.sleep(1)
# Get position of the head to set it fixed
names = "HeadYaw"
useSensors = False
commandAngles = motionProxy.getAngles(names, useSensors)
print "Command angles:"
print str(commandAngles)
print ""
testTime = 1.0 # seconds
t = 0.0
dt = 0.2
## while t<testTime:
## # WALK
## X = 0
## Y = 0
## Theta = math.pi/4.0
## #Frequency = random.uniform(0.5, 1.0)
## try:
## #motionProxy.moveToward(X, Y, Theta, [["Frequency", Frequency]])
## motionProxy.move(0, 0, Theta)
## #motionProxy.setAngles("HeadYaw", -0.5, 0.6)
## except Exception, errorMsg:
## print str(errorMsg)
## print "This example is not allowed on this robot."
## exit()
##
## # JERKY HEAD
## #motionProxy.setAngles("HeadYaw", -0.5, 0.6)
## #motionProxy.setAngles("HeadPitch", random.uniform(-0.5, 0.5), 0.6)
##
## t = t + dt
## time.sleep(dt)
X = 0
Y = 0
Theta = -math.pi/4.0
motionProxy.moveTo(X, Y, Theta)
# Rotate the head the displacement of the body
#motionProxy.setAngles("HeadYaw", -math.pi/2.0, 0.6)
trackerProxy.lookAt([-5, 5, 1], 1, 0.2, False)
time.sleep(1)
# stop move on the next double support
motionProxy.stopMove()
# Go to rest position
motionProxy.rest()
示例15: NAOServer
# 需要导入模块: from naoqi import ALProxy [as 别名]
# 或者: from naoqi.ALProxy import getAngles [as 别名]
#.........这里部分代码省略.........
sleep(0.25)
# check if to send info package
if( time() - self.__lastSend > Settings.infoResendDelay ):
request = self.__createDataRequestPackage( dataCommands.SYS_SEND_INFO, [] )
data = self.createDataResponsePackage(request, False)
self.send(data)
def __createStiffnessDatapackage(self):
'''
Creates stiffness data package
'''
data = {'jointStiffness': {}}
for joint in dataJoints.JOINTS:
try:
stiffnessList = []
if "stiffnessData" in self.__requiredData:
stiffnessList = self.__motionProxy.getStiffnesses( dataJoints.JOINTS[joint] )
stiffness = 0.0
for stiff in stiffnessList:
if stiff > 0.0:
stiffness += stiff
if len(stiffnessList) > 0:
stiffness = stiffness / len(stiffnessList)
data['jointStiffness'][ dataJoints.JOINTS[joint] ] = stiffness
except:
print "ERROR: Unknown joint " + str(joint)
data['leftHandOpen'] = self.__motionProxy.getAngles("LHand", True)[0] > 0.3
data['rightHandOpen'] = self.__motionProxy.getAngles("RHand", True)[0] > 0.3
return data
def __createAudioDatapackage(self):
'''
Creates audio data package
'''
data = {
'masterVolume': self.__audioProxy.getOutputVolume() if "masterVolume" in self.__requiredData else 0,
'playerVolume': self.__playerProxy.getMasterVolume() if "playerVolume" in self.__requiredData else 0.0,
'speechVolume': self.__ttsProxy.getVolume() if "speechVolume" in self.__requiredData else 0.0,
'speechVoice': self.__ttsProxy.getVoice() if "speechVoice" in self.__requiredData else "",
'speechLanguage': self.__ttsProxy.getLanguage() if "speechLanguage" in self.__requiredData else "",
'speechLanguagesList': self.__speechLanguagesList if "speechLanguagesList" in self.__requiredData else [],
'speechVoicesList': self.__speechVoicesList if "speechVoicesList" in self.__requiredData else [],
'speechPitchShift': self.__ttsProxy.getParameter("pitchShift") if "speechPitchShift" in self.__requiredData else 0.0,
'speechDoubleVoice': self.__ttsProxy.getParameter("doubleVoice") if "speechDoubleVoice" in self.__requiredData else 0.0,
'speechDoubleVoiceLevel': self.__ttsProxy.getParameter("doubleVoiceLevel") if "speechDoubleVoiceLevel" in self.__requiredData else 0.0,
'speechDoubleVoiceTimeShift': self.__ttsProxy.getParameter("doubleVoiceTimeShift") if "speechDoubleVoiceTimeShift" in self.__requiredData else 0.0
}
return data
def active(self):
'''
Returns true if the socket is active
'''
if self.__sock and self.__conn:
return True
return False