-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrviz_scenario_editor.py
40 lines (30 loc) · 1.24 KB
/
rviz_scenario_editor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
# -*- coding: utf-8 -*
import rospy
from geometry_msgs.msg import PoseStamped
from geometry_msgs.msg import PointStamped
import tf
import pyperclip
import math
class RvizScenarioEditor():
# def __init__(self):
def pointCb(self, point):
str = "{:.1f},{:.1f},{:.1f}".format(point.point.x, -point.point.y, 1.0)
print(str)
pyperclip.copy(str)
def poseCb(self, pose):
euler = self.quatToEuler(pose.pose.orientation)
str = "{:.1f},{:.1f},{:.1f},{:.1f},{:.1f},{:.1f}".format(pose.pose.position.x, -pose.pose.position.y, 1.0, -euler[1] * 180 / math.pi, -euler[2] * 180 / math.pi, euler[0] * 180 / math.pi)
print(str)
pyperclip.copy(str)
def quatToEuler(self, orientation):
euler = tf.transformations.euler_from_quaternion((orientation.x, orientation.y, orientation.z, orientation.w))
return euler
def main():
rospy.init_node('rviz_scenario_editor_node')
rviz_scenario_editor = RvizScenarioEditor()
sub_point = rospy.Subscriber('/clicked_point', PointStamped, rviz_scenario_editor.pointCb)
sub_point = rospy.Subscriber('/move_base_simple/goal', PoseStamped, rviz_scenario_editor.poseCb)
rospy.spin()
if __name__ == '__main__':
main()