8 import roslib; roslib.load_manifest(
'velma_core_ve_body')
16 from std_msgs.msg
import ColorRGBA
21 if __name__ ==
"__main__":
23 rospy.init_node(
'cimp_test', anonymous=
True)
25 print "This script tests Vitrual Effector of Velma robot for" 26 print "stability of safe behavior." 27 print "It can be run in simulation environment only." 31 rospy.wait_for_service(
'/gazebo/apply_body_wrench', timeout=10.0)
32 rospy.wait_for_service(
'/gazebo/get_model_properties', timeout=10.0)
33 rospy.wait_for_service(
'/gazebo/get_joint_properties', timeout=10.0)
34 except rospy.ServiceException, e:
35 print "wait_for_service failed: %s"%e
39 apply_wrench = rospy.ServiceProxy(
'/gazebo/apply_body_wrench', ApplyBodyWrench)
40 except rospy.ServiceException, e:
41 print "ServiceProxy failed: %s"%e
45 get_model_properties = rospy.ServiceProxy(
'/gazebo/get_model_properties', GetModelProperties)
46 except rospy.ServiceException, e:
47 print "ServiceProxy failed: %s"%e
51 get_joint_proporties = rospy.ServiceProxy(
'/gazebo/get_joint_properties', GetJointProperties)
52 except rospy.ServiceException, e:
53 print "ServiceProxy failed: %s"%e
57 if not model_prop.success:
58 print "error while executing rosservice '/gazebo/get_model_properties':", model_prop.status_message
61 print "applying external forces..." 63 apply_wrench(
"torso_link0",
"world", Point(), Wrench(force=Vector3(), torque=Vector3(0,0,200)), rospy.Time(), rospy.Duration.from_sec(0.01))
64 apply_wrench(
"left_arm_4_link",
"world", Point(), Wrench(force=Vector3(), torque=Vector3(0,0,50)), rospy.Time(), rospy.Duration.from_sec(0.01))
65 apply_wrench(
"right_arm_4_link",
"world", Point(), Wrench(force=Vector3(), torque=Vector3(0,0,50)), rospy.Time(), rospy.Duration.from_sec(0.01))
68 print "waitning for stabilization..." 72 for joint_name
in model_prop.joint_names:
74 if not joint_prop.success:
75 print "error while executing rosservice '/gazebo/get_joint_properties' for joint", joint_name,
":", model_prop.status_message
77 joint_pos[joint_name] = joint_prop.position[0]
79 print "waitning for next measurement..." 81 for joint_name
in model_prop.joint_names:
83 if not joint_prop.success:
84 print "error while executing rosservice '/gazebo/get_joint_properties' for joint", joint_name,
":", model_prop.status_message
86 diff = joint_prop.position[0] - joint_pos[joint_name]
87 if abs(diff) > 1.0/180.0*math.pi:
88 print "joint", joint_name,
"is still moving:", diff