-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol_point.py
44 lines (33 loc) · 968 Bytes
/
control_point.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
41
42
43
44
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import ams
import rospy
from geometry_msgs.msg import Twist
from nav_msgs.msg import Odometry
import tf2_ros
from geometry_msgs.msg import TransformStamped
try:
rospy.init_node('control_line')
# Velocity commands publisher.
pubCmdVel = rospy.Publisher('cmd_vel', Twist, queue_size=1)
# TF buffer and listener
tfBuffer = tf2_ros.Buffer()
tfListener = tf2_ros.TransformListener(tfBuffer)
# Velocity commands message
msgCmdVel = Twist()
rate = rospy.Rate(50)
while not rospy.is_shutdown():
t = rospy.Time.now()
try:
trans = tfBuffer.lookup_transform('world', 'agv', rospy.Time())
x, y, phi = ams.msgToPose(trans)
except tf2_ros.TransformException:
pass
vs, ws = 0.0, 0.0
msgCmdVel.linear.x = vs
msgCmdVel.angular.z = ws
# Publish velocity commands
pubCmdVel.publish(msgCmdVel)
rate.sleep()
except KeyboardInterrupt:
pass