4 from control_msgs.msg
import (
5 FollowJointTrajectoryAction,
6 FollowJointTrajectoryGoal,
11 from trajectory_msgs.msg
import (
14 from jog_msgs.msg
import JogFrame
17 from sensor_msgs.msg
import JointState
24 rospy.init_node(
'test_jog_frame_node')
32 self.
frame_id = rospy.get_param(
'~frame_id',
'base_link')
33 self.
group_name = rospy.get_param(
'~group_name',
'manipulator')
34 self.
link_name = rospy.get_param(
'~link_name',
'ee_link')
40 self.
pub = rospy.Publisher(
'jog_frame', JogFrame, queue_size=10)
46 self.client.wait_for_server()
52 goal = FollowJointTrajectoryGoal()
53 goal.trajectory.header.stamp = rospy.Time.now()
54 goal_time_tolerance = rospy.Time(0.1)
55 goal.goal_time_tolerance = rospy.Time(0.1)
57 point = JointTrajectoryPoint()
59 point.time_from_start = rospy.Duration(1.0)
60 goal.trajectory.points.append(point)
63 self.client.send_goal(goal)
64 self.assertTrue(self.client.wait_for_result(timeout=rospy.Duration(5.0)))
68 '''Test to jog a command with linear delta''' 70 self.listener.waitForTransform(
72 (start_pos, start_rot) = self.listener.lookupTransform(
77 jog.header.stamp = rospy.Time.now()
88 self.listener.waitForTransform(
90 (pos, rot) = self.listener.lookupTransform(
94 self.assertAlmostEqual(pos[i], start_pos[i] + self.
linear_delta, delta=0.0001)
96 rot_diff = tf.transformations.quaternion_multiply(
97 tf.transformations.quaternion_inverse(start_rot), rot)
99 self.assertAlmostEqual(start_rot[i], rot[i], delta=0.0001)
102 '''Test to jog a command with angular delta''' 104 self.listener.waitForTransform(
106 (start_pos, start_rot) = self.listener.lookupTransform(
111 jog.header.stamp = rospy.Time.now()
118 self.pub.publish(jog)
122 self.listener.waitForTransform(
124 (pos, rot) = self.listener.lookupTransform(
128 self.assertAlmostEqual(pos[i], start_pos[i], delta=0.0001)
130 jog_q = tf.transformations.quaternion_about_axis(self.
angular_delta, [1,1,1])
131 ans_rot = tf.transformations.quaternion_multiply(jog_q, start_rot)
133 self.assertAlmostEqual(rot[i], ans_rot[i], delta=0.0001)
136 '''Test to jog ten commands with linear delta''' 138 self.listener.waitForTransform(
140 (start_pos, start_rot) = self.listener.lookupTransform(
146 jog.header.stamp = rospy.Time.now()
153 self.pub.publish(jog)
157 self.listener.waitForTransform(
159 (pos, rot) = self.listener.lookupTransform(
163 self.assertAlmostEqual(pos[i], start_pos[i] + self.
linear_delta*10, delta=0.0001)
166 self.assertAlmostEqual(start_rot[i], rot[i], delta=0.0001)
169 '''Test to jog ten commands with angular delta''' 171 self.listener.waitForTransform(
173 (start_pos, start_rot) = self.listener.lookupTransform(
179 jog.header.stamp = rospy.Time.now()
186 self.pub.publish(jog)
190 self.listener.waitForTransform(
192 (pos, rot) = self.listener.lookupTransform(
196 self.assertAlmostEqual(pos[i], start_pos[i], delta=0.0001)
198 jog_q = tf.transformations.quaternion_about_axis(self.
angular_delta*10, [1,1,1])
199 ans_rot = tf.transformations.quaternion_multiply(jog_q, start_rot)
201 self.assertAlmostEqual(rot[i], ans_rot[i], delta=0.0001)
203 if __name__ ==
'__main__':
204 rostest.rosrun(
'jog_controller',
'test_jog_frame_node', TestJogFrameNode)
def test_ten_jogs_with_linear_delta(self)
def test_a_jog_with_linear_delta(self)
def test_a_jog_with_angular_delta(self)
def test_ten_jogs_with_angular_delta(self)