11 import roslib;roslib.load_manifest(PKG)
13 from sensor_msgs.msg
import Joy
16 from tf.transformations
import quaternion_from_euler
17 from jsk_rviz_plugins.msg
import OverlayText
26 display_separate_mode =
True 28 global x_max, y_max, z_max, rx_max, ry_max, rz_max, set_pose_pub
29 global prev_b, translate_mode
34 if prev_b == 0
and (b[0] == 1
or b[1] == 1):
35 translate_mode =
not translate_mode
37 if b[0] == 1
or b[1] == 1:
42 x_v1,y_v1,z_v1,rx_v1,ry_v1,rz_v1 = a
45 if not separate_mode
or (separate_mode
and translate_mode):
46 target_pose.position.x = x_v1 * x_max
47 target_pose.position.y = y_v1 * y_max
48 target_pose.position.z = z_v1 * z_max
50 target_pose.orientation.w = 1
51 if not separate_mode
or (separate_mode
and not translate_mode):
52 q = quaternion_from_euler(rx_v1 * rx_max, ry_v1 * ry_max, rz_v1 * rz_max,
'rxyz')
53 target_pose.orientation.x = q[0]
54 target_pose.orientation.y = q[1]
55 target_pose.orientation.z = q[2]
56 target_pose.orientation.w = q[3]
58 set_pose_pub.publish(target_pose)
59 if translate_mode
and separate_mode:
65 send_text = OverlayText()
66 send_text.text = message
72 send_text.bg_color.r = 0.9;
73 send_text.bg_color.b = 0.9;
74 send_text.bg_color.g = 0.9;
75 send_text.bg_color.a = 0.1;
76 send_text.fg_color.r = 0.3;
77 send_text.fg_color.g = 0.8;
78 send_text.fg_color.b = 0.3;
79 send_text.fg_color.a = 1;
80 send_text.line_width = 1;
81 send_text.text_size = 30;
82 send_text_pub.publish(send_text);
85 if __name__ ==
"__main__":
86 rospy.init_node(
"transformable_spacenav_configure")
87 ns = rospy.get_param(
'~transformable_interactive_server_nodename',
'')
89 x_max = rospy.get_param(
"~x_max")
90 y_max = rospy.get_param(
"~y_max")
91 z_max = rospy.get_param(
"~z_max")
92 rx_max = rospy.get_param(
"~rx_max")
93 ry_max = rospy.get_param(
"~ry_max")
94 rz_max = rospy.get_param(
"~rz_max")
96 separate_mode = rospy.get_param(
"~separate_mode")
97 display_separate_mode = rospy.get_param(
"~display_separate_mode")
99 set_pose_pub = rospy.Publisher(ns+
"/add_pose", Pose)
100 send_text_pub = rospy.Publisher(
"separate_mode_text", OverlayText)
102 s = rospy.Subscriber(
"input_joy", Joy, callback)