-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTurtleMover.py
More file actions
55 lines (40 loc) · 1.33 KB
/
Copy pathTurtleMover.py
File metadata and controls
55 lines (40 loc) · 1.33 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
from turtlesim.msg import Pose
from visualization_msgs.msg import Marker
import std_msgs.msg as stm
from multiprocessing import Process
def callback(data):
#rospy.init_node("mark")
# Creates Marker object named marker
marker = Marker()
# Define marker parameters
marker.header.frame_id = "/world1"
marker.header.stamp = rospy.Time.now()
marker.type = Marker.CUBE
marker.action = Marker.ADD
marker.scale.x = 1
marker.scale.y = 1
marker.scale.z = 1
marker.id = 10
marker.pose.position.x = data.x;
marker.pose.position.y = data.y;
marker.pose.position.z = 0;
marker.pose.orientation.x = 0.0;
marker.pose.orientation.y = 0.0;
marker.pose.orientation.z = 0.0;
marker.pose.orientation.w = 1.0;
marker.color = stm.ColorRGBA(r=0.0, g=1.0, b=0.0, a=0.8)
marker.lifetime.secs = 10
#Create Publisher called 'process_test' of type Marker
pub = rospy.Publisher("TurtleMark", Marker, queue_size=10)
#Publish marker
pub.publish(marker)
def listener():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("/turtle1/pose", Pose, callback)
# spin() simply keeps python from exiting until this node is stopped
rospy.spin()
if __name__ == '__main__':
listener()