Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 import actionlib
00035 import rospy
00036
00037 from python_qt_binding.QtGui import QComboBox, QMessageBox
00038 from naoqi_bridge_msgs.msg import BodyPoseWithSpeedAction, BodyPoseWithSpeedGoal
00039
00040 class PostureWidget(QComboBox):
00041 def __init__(self, topic_prefix):
00042 super(PostureWidget, self).__init__()
00043 self.setSizeAdjustPolicy(QComboBox.AdjustToContents)
00044 self.setInsertPolicy(QComboBox.InsertAlphabetically)
00045 self.setEditable(True)
00046
00047 if topic_prefix == "nao_robot":
00048 posture_list = ["---", "Crouch", "LyingBack", "LyingBelly", "Sit", "SitOnChair", "SitRelax", "Stand", "StandInit", "StandZero"]
00049 elif topic_prefix == "pepper_robot":
00050 posture_list = [ "---", "Crouch", "Stand", "StandInit", "StandZero" ]
00051
00052 self.addItems( posture_list )
00053 self.currentIndexChanged.connect( self.apply_posture )
00054
00055 self.bodyPoseClient = actionlib.SimpleActionClient(str(topic_prefix)+'/pose/body_pose_naoqi', BodyPoseWithSpeedAction)
00056
00057 def apply_posture(self):
00058 posture = self.currentText()
00059 rospy.loginfo("go to posture: "+ str(posture))
00060 self.bodyPoseClient.send_goal_and_wait(BodyPoseWithSpeedGoal(posture_name = posture, speed=0.7))
00061 state = self.bodyPoseClient.get_state()
00062 if not state == actionlib.GoalStatus.SUCCEEDED:
00063 QMessageBox(self, 'Error', str(posture)+' posture did not succeed: %s - cannot remove stiffness' % self.bodyPoseClient.get_goal_status_text())
00064 rospy.logerror("crouch pose did not succeed: %s", self.bodyPoseClient.get_goal_status_text())