-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
49 lines (35 loc) · 940 Bytes
/
test.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
45
46
47
48
49
#!/usr/bin/env python3
import rospy
import atexit
import time
from geometry_msgs.msg import Twist
from std_msgs.msg import Bool
rospy.init_node('kvad')
status_pub = rospy.Publisher('/head/status', Bool, queue_size=1)
cmd_vel_pub = rospy.Publisher('/head/cmd_vel', Twist, queue_size=1)
def stop():
print('stop!')
status_pub.publish(False)
time.sleep(1)
rospy.on_shutdown(stop)
r = rospy.Rate(10)
start = time.time()
while not rospy.is_shutdown():
r.sleep()
cmd_vel = Twist()
# cmd_vel.linear.x = 1
cmd_vel.linear.x = 0.1
# cmd_vel.angular.z = -0.85
cmd_vel_pub.publish(cmd_vel)
status_pub.publish(True)
if time.time() - start > 10:
print('stop')
break
while not rospy.is_shutdown():
r.sleep()
cmd_vel = Twist()
# cmd_vel.linear.x = 1
cmd_vel.linear.x = 0.0
# cmd_vel.angular.z = -0.85
cmd_vel_pub.publish(cmd_vel)
status_pub.publish(True)