37 PKG =
'hironx_ros_bridge' 41 import hironx_ros_bridge
43 import roslib; roslib.load_manifest(PKG)
44 import hironx_ros_bridge
46 from hironx_ros_bridge
import hironx_client
as hironx
47 import rospy, actionlib, math, numpy
49 from tf.transformations
import quaternion_matrix, euler_from_matrix
55 roslib.load_manifest(
'pr2_controllers_msgs')
56 import pr2_controllers_msgs.msg
59 import trajectory_msgs.msg
61 from sensor_msgs.msg
import JointState
63 from pr2_controllers_msgs.msg
import JointTrajectoryAction
64 from pr2_controllers_msgs.msg
import JointTrajectoryGoal
65 joint_trajectory_action =
'joint_trajectory_action' 66 print(
"from pr2_controllers_msgs.msg import JointTrajectoryAction")
68 from control_msgs.msg
import FollowJointTrajectoryAction
as JointTrajectoryAction
69 from control_msgs.msg
import FollowJointTrajectoryGoal
as JointTrajectoryGoal
70 joint_trajectory_action =
'follow_joint_trajectory_action' 71 print(
"from control_msgs.msg import FollowJointTrajectoryAction as JointTrajectoryAction")
72 from trajectory_msgs.msg
import JointTrajectoryPoint
81 self.joint_states.append(msg)
85 super(TestHiroROSBridge, self).
__init__(*args, **kwargs)
88 rospy.init_node(
'hironx_ros_bridge_test')
104 self.larm.wait_for_server()
105 self.rarm.wait_for_server()
106 self.torso.wait_for_server()
107 self.head.wait_for_server()
109 rospy.wait_for_service(
'/SequencePlayerServiceROSBridge/setTargetPose')
110 self.
set_target_pose = rospy.ServiceProxy(
'/SequencePlayerServiceROSBridge/setTargetPose', OpenHRP_SequencePlayerService_setTargetPose)
111 rospy.wait_for_service(
'/SequencePlayerServiceROSBridge/waitInterpolationOfGroup')
112 self.
wait_interpolation_of_group = rospy.ServiceProxy(
'/SequencePlayerServiceROSBridge/waitInterpolationOfGroup', OpenHRP_SequencePlayerService_waitInterpolationOfGroup)
124 larm_goal = self.
setup_Positions(larm_goal, [[ 0.0, -40.0, -90.0, 0.0, 0.0, 0.0]])
126 rarm_goal = self.
setup_Positions(rarm_goal, [[ 0.0, -40.0, -90.0, 0.0, 0.0, 0.0]])
131 self.larm.send_goal(larm_goal)
132 self.rarm.send_goal(rarm_goal)
133 self.head.send_goal(head_goal)
134 self.torso.send_goal(torso_goal)
135 self.larm.wait_for_result()
136 self.rarm.wait_for_result()
137 self.head.wait_for_result()
138 self.torso.wait_for_result()
141 goal = JointTrajectoryGoal()
142 goal.trajectory.joint_names.append(
"LARM_JOINT0")
143 goal.trajectory.joint_names.append(
"LARM_JOINT1")
144 goal.trajectory.joint_names.append(
"LARM_JOINT2")
145 goal.trajectory.joint_names.append(
"LARM_JOINT3")
146 goal.trajectory.joint_names.append(
"LARM_JOINT4")
147 goal.trajectory.joint_names.append(
"LARM_JOINT5")
151 goal = JointTrajectoryGoal()
152 goal.trajectory.joint_names.append(
"RARM_JOINT0")
153 goal.trajectory.joint_names.append(
"RARM_JOINT1")
154 goal.trajectory.joint_names.append(
"RARM_JOINT2")
155 goal.trajectory.joint_names.append(
"RARM_JOINT3")
156 goal.trajectory.joint_names.append(
"RARM_JOINT4")
157 goal.trajectory.joint_names.append(
"RARM_JOINT5")
161 goal = JointTrajectoryGoal()
162 goal.trajectory.joint_names.append(
"CHEST_JOINT0")
166 goal = JointTrajectoryGoal()
167 goal.trajectory.joint_names.append(
"HEAD_JOINT0")
168 goal.trajectory.joint_names.append(
"HEAD_JOINT1")
173 point = trajectory_msgs.msg.JointTrajectoryPoint()
174 point.positions = [ x * math.pi / 180.0
for x
in p]
175 point.time_from_start = rospy.Duration(tm)
176 goal.trajectory.points.append(point)
187 current_time = j.header.stamp.to_sec();
188 current_value = [p*180/math.pi
for p
in j.position]
189 data.append([current_time, current_value[5]])
190 f.write(str(current_time)+
' '+
' '.join([str(i)
for i
in current_value])+
"\n")
192 self.filenames.append(name)
197 cmd =
"gnuplot -p -e \"set terminal pdf; set output '"+name+
"'; plot " 199 cmd +=
"'"+name+
"' using 0:7 title '"+name+
"' with lines" 207 if __name__ ==
'__main__':
209 rostest.rosrun(PKG,
'test_hronx_ros_bridge', TestHiroROSBridge)
wait_interpolation_of_group
def setup_Positions(self, goal, positions, tm=1.0)
def joint_states_cb(self, msg)
def check_q_data(self, name)
def write_output_to_pdf(self, name)
def __init__(self, args, kwargs)