5 from __future__
import division
9 from moveit_msgs.msg
import MoveGroupAction
10 from sensor_msgs.msg
import Joy
11 from geometry_msgs.msg
import PoseStamped
12 from geometry_msgs.msg
import Pose
13 from sr_robot_commander.sr_arm_commander
import SrArmCommander
25 rospy.init_node(
"mouse_tester", anonymous=
True)
26 client = actionlib.SimpleActionClient(
'move_group', MoveGroupAction)
27 client.wait_for_server()
34 self.
expvals = [[[0.3, 0.0, 1.1, 0, 0.7, 0.05, 0.05],
35 [0.51, 0.25, 1.1, 0.7, 0.71, 0.05, 0.048],
36 [0.51, 0.26, 1.1, 0.7, 0.71, 0.05, 0.048]],
37 [[0.27, 0.25, 1.1, 0.7, 0.7, 0.05, 0.05],
38 [0.27, 0.35, 1.1, 0.7, 0.7, 0.05, 0.05],
39 [0.27, 0.35, 1.1, 0.7, 0.7, 0.05, 0.05]],
40 [[0.27, 0.25, 1.1, 0.7, 0.7, 0.05, 0.05],
41 [0.27, 0.25, 0.9, 0.7, 0.7, 0.05, 0.05],
42 [0.27, 0.25, 0.85, 0.7, 0.7, 0.05, 0.05]],
43 [[0.27, 0.25, 1.1, 0.7, 0.7, 0.05, 0.05],
44 [0.27, 0.25, 1.1, 0.69, 0.7, 0.05, 0.1],
45 [0.27, 0.25, 1, 0.7, 0.7, 0.05, 0.1]],
46 [[0.27, 0.25, 1.1, 0.7, 0.7, 0.05, 0.05],
47 [0.27, 0.25, 1.1, 0.69, 0.69, 0.1, 0.1],
48 [0.27, 0.25, 1.1, 0.69, 0.69, 0.1, 0.1]],
49 [[0.27, 0.25, 1.1, 0.7, 0.7, 0.05, 0.05],
50 [0.27, 0.25, 1.1, 0.7, 0.6, 0.05, 0.08],
51 [0.27, 0.25, 1.1, 0.7, 0.6, 0.05, 0.05]]]
54 start_pose = self._arm_commander.get_current_pose()
55 self.new_pose.header.stamp = rospy.get_rostime()
56 self.new_pose.header.frame_id =
"world" 57 self.new_pose.pose = start_pose
59 self.new_pose.pose.position.x = 0.3
60 self.new_pose.pose.position.y = 0.25
61 self.new_pose.pose.position.z = 1.1
62 self.new_pose.pose.orientation.x = 0.7
63 self.new_pose.pose.orientation.y = 0.7
64 self.new_pose.pose.orientation.z = 0
65 self.new_pose.pose.orientation.w = 0
67 self.
pub_arm = rospy.Publisher(
"command", PoseStamped, queue_size=1)
68 self.
pub = rospy.Publisher(
"/spacenav/joy", Joy, queue_size=1)
70 self.data.buttons = [0, 0]
71 self.data.axes = [0, 0, 0, 0, 0, 0]
74 self.pub.publish(self.
data)
76 self._arm_commander.move_to_pose_value_target_unsafe(self.
new_pose,
77 avoid_collisions=
True,
89 self.data.axes = [0, 0, 0, 0, 0, 0]
90 self.data.axes[i] = -0.08
92 self.pub.publish(self.
data)
93 self.data.axes[i] = self.data.axes[i] + 0.08
95 self.assertAlmostEqual(self.target_pose.pose.position.x,
96 abs(self.
expvals[i][j][0]), msg=
"poseX failed", delta=2)
97 self.assertAlmostEqual(self.target_pose.pose.position.y,
98 abs(self.
expvals[i][j][1]), msg=
"poseY failed", delta=2)
99 self.assertAlmostEqual(self.target_pose.pose.position.z,
100 abs(self.
expvals[i][j][2]), msg=
"poseZ failed", delta=2)
101 self.assertAlmostEqual(self.target_pose.pose.orientation.x,
102 abs(self.
expvals[i][j][3]), msg=
"rotX failed", delta=2)
103 self.assertAlmostEqual(self.target_pose.pose.orientation.y,
104 abs(self.
expvals[i][j][4]), msg=
"rotY failed", delta=2)
105 self.assertAlmostEqual(self.target_pose.pose.orientation.z,
106 abs(self.
expvals[i][j][5]), msg=
"rotZ failed", delta=2)
107 self.assertAlmostEqual(self.target_pose.pose.orientation.w,
108 abs(self.
expvals[i][j][6]), msg=
"rotW failed", delta=2)
110 self.reset_joy.axes = [0, 0, 0, 0, 0, 0]
115 checks the output of the controller 119 if __name__ ==
'__main__':
121 rostest.rosrun(PKG,
"mouse_test", MouseTester)
def comparecall(self, data)