11 roslib.load_manifest(
'jsk_joy')
13 from view_controller_msgs.msg
import CameraPlacement
14 from geometry_msgs.msg
import PoseStamped
15 from sensor_msgs.msg
import Joy
16 import tf.transformations
18 sys.path.append(commands.getoutput(
'rospack find jsk_joy') +
'/scripts')
19 from trackpoint_status
import TrackpointStatus
20 from nanokontrol_status
import NanoKONTROL2Status
21 from nanopad_status
import NanoPAD2Status
23 INTERACTIVE_MARKER_TOPIC =
'/goal_marker' 28 nanokontrol_st = NanoKONTROL2Status(msg)
32 nanopad_st = NanoPAD2Status(msg)
35 global pre_view, g_seq_num, pre_pose
36 global nanokontrol_st, nanopad_st
38 pre_pose = PoseStamped()
39 status = TrackpointStatus(msg)
43 new_pose = PoseStamped()
44 new_pose.header.frame_id =
'/map' 45 new_pose.header.stamp = rospy.Time(0.0)
47 local_xy_move = numpy.array((0.0,
53 if ( nanopad_st
and nanopad_st.buttonL1 ):
62 if not ( status.left
or status.right
or status.middle ):
67 if ( nanopad_st
and nanopad_st.buttonU1 ):
68 z_move = status.y / scale_z
69 elif ( nanopad_st
and nanopad_st.buttonU2 ):
70 yaw_move = status.y / scale_yaw
72 local_xy_move = numpy.array((- status.x / scale_xy,
73 - status.y / scale_xy,
76 q = numpy.array((pre_pose.pose.orientation.x,
77 pre_pose.pose.orientation.y,
78 pre_pose.pose.orientation.z,
79 pre_pose.pose.orientation.w))
82 xy_move = local_xy_move
84 new_pose.pose.position.x = pre_pose.pose.position.x + xy_move[0]
85 new_pose.pose.position.y = pre_pose.pose.position.y + xy_move[1]
86 new_pose.pose.position.z = pre_pose.pose.position.z + z_move
87 (roll, pitch, yaw) = tf.transformations.euler_from_quaternion(q)
90 new_q = tf.transformations.quaternion_from_euler(roll, pitch, yaw)
91 new_pose.pose.orientation.x = new_q[0]
92 new_pose.pose.orientation.y = new_q[1]
93 new_pose.pose.orientation.z = new_q[2]
94 new_pose.pose.orientation.w = new_q[3]
95 g_interactive_pub.publish(new_pose)
144 global g_camera_pub, g_interactive_pub
145 global nanokontrol_st, nanopad_st
147 rospy.init_node(
'trackpoint_controller')
148 g_camera_pub = rospy.Publisher(
'/rviz/camera_placement', CameraPlacement)
149 g_interactive_pub = rospy.Publisher(INTERACTIVE_MARKER_TOPIC +
'/move_marker', PoseStamped)
150 trackpoint_sub = rospy.Subscriber(
'/trackpoint/joy', Joy, trackpoint_joyCB)
151 nanokontrol_sub= rospy.Subscriber(
'/nanokontrol/joy', Joy, nanokontrol_joyCB)
152 nanopad_sub= rospy.Subscriber(
'/nanopad/joy', Joy, nanopad_joyCB)
153 nanokontrol_st =
None 159 if __name__ ==
'__main__':
def trackpoint_joyCB(msg)
def nanokontrol_joyCB(msg)