rviz_mouse_point_to_tablet.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import numpy
5 from math import pi
6 from view_controller_msgs.msg import CameraPlacement
7 from geometry_msgs.msg import PointStamped
8 from jsk_gui_msgs.msg import Tablet
9 from threading import Lock
10 
11 lock = Lock()
12 latest_mouse_point = None
13 
14 def pointCallback(msg):
15  global latest_mouse_point
16  with lock:
17  latest_mouse_point = msg
18 
19 def timerCallback(event):
20  global latest_mouse_point
21  # print (latest_mouse_point and latest_mouse_point.point,
22  # prev_mouse_point and prev_mouse_point.point)
23  with lock:
24  if not latest_mouse_point:
25  return
26  next_x = latest_mouse_point.point.x * 640
27  next_y = latest_mouse_point.point.y * 480
28  msg = Tablet()
29  msg.header.stamp = rospy.Time.now()
30  msg.action.task_name = "MoveCameraCenter"
31  # chop
32  msg.action.touch_x = next_x
33  msg.action.touch_y = next_y
34  rospy.loginfo("neck actino to (%f, %f)" % (msg.action.touch_x, msg.action.touch_y))
35  pub.publish(msg)
36  latest_mouse_point = None
37 
38 
39 if __name__ == "__main__":
40  rospy.init_node("rviz_mouse_point_to_tablet")
41  pub = rospy.Publisher("/Tablet/Command", Tablet)
42  sub = rospy.Subscriber("/rviz/current_mouse_point",
43  PointStamped, pointCallback)
44  rospy.Timer(rospy.Duration(0.3), timerCallback)
45  rospy.spin()
rviz_mouse_point_to_tablet.timerCallback
def timerCallback(event)
Definition: rviz_mouse_point_to_tablet.py:19
rviz_mouse_point_to_tablet.pointCallback
def pointCallback(msg)
Definition: rviz_mouse_point_to_tablet.py:14


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Aug 2 2024 08:50:14