6 from jog_msgs.msg
import JogFrame
7 from geometry_msgs.msg
import Twist
13 self.
scale_linear = rospy.get_param(
'~scale_linear', {
'x': 0.05,
'y': 0.05,
'z': 0.05})
14 self.
scale_angular = rospy.get_param(
'~scales_angular', {
'x': 0.05,
'y': 0.05,
'z': 0.05})
15 self.
rotation_matrix = np.matrix(rospy.get_param(
'~rotation_matrix', [[1,0,0],[0,1,0],[0,0,1]]))
16 self.
pub = rospy.Publisher(
'jog_frame', JogFrame, queue_size=1)
20 axes = {twist_msg.linear.x, twist_msg.linear.y, twist_msg.linear.z, twist_msg.angular.x, twist_msg.angular.y, twist_msg.angular.z}
24 highest = axes.index(max(axes))
26 dominantTwist = Twist()
29 dominantTwist.linear.x = twist_msg.linear.x
31 dominantTwist.linear.y = twist_msg.linear.y
33 dominantTwist.linear.z = twist_msg.linear.z
35 dominantTwist.angular.x = twist_msg.angular.x
37 dominantTwist.angular.y = twist_msg.angular.y
39 dominantTwist.angular.z = twist_msg.angular.z
45 linear_mat = [twist_msg.linear.x, twist_msg.linear.y, twist_msg.linear.z] * self.
rotation_matrix 46 angular_mat = [twist_msg.angular.x, twist_msg.angular.y, twist_msg.angular.z] * self.
rotation_matrix 49 remappedTwist = Twist()
50 remappedTwist.linear.x = linear_mat[0,0]
51 remappedTwist.linear.y = linear_mat[0,1]
52 remappedTwist.linear.z = linear_mat[0,2]
53 remappedTwist.angular.x = angular_mat[0,0]
54 remappedTwist.angular.y = angular_mat[0,1]
55 remappedTwist.angular.z = angular_mat[0,2]
64 if num
not in final_list:
65 final_list.append(num)
67 if len(final_list) != len(duplicate):
68 final_list = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
76 msg.header.stamp = rospy.Time.now()
77 msg.header.frame_id = rospy.get_param(
'~frame_id',
'base_link')
78 msg.group_name = rospy.get_param(
'~group_name',
'manipulator')
79 msg.link_name = rospy.get_param(
'~link_name',
'tool0')
81 if rospy.get_param(
'~dominant_mode',
True):
84 if rospy.get_param(
'~axes_remap',
True):
91 msg.linear_delta.x = self.
scale_linear[
'x']*twist.linear.x
92 msg.linear_delta.y = self.
scale_linear[
'y']*twist.linear.y
93 msg.linear_delta.z = self.
scale_linear[
'z']*twist.linear.z
95 msg.avoid_collisions =
True 100 rospy.Subscriber(rospy.get_param(
'~sub_topic',
'spacenav/twist'), Twist, self.
callback)
104 if __name__ ==
'__main__':
105 rospy.init_node(
'twist_to_jog_frame', anonymous=
True)
107 republisher.republish()
def dominantAxisMode(self, twist_msg)
def axesRemap(self, twist_msg)
def callback(self, twist)
def hasDuplicate(self, duplicate)