-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl2_motor_p3.py
44 lines (37 loc) · 1012 Bytes
/
l2_motor_p3.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/env python
import rospy
import math
import time
from geometry_msgs.msg import Twist
from std_msgs.msg import String
def publisher_node():
print('TODO: initialize the publisher node here, \
and publish wheel command to the cmd_vel topic')
cmd_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1)
twist=Twist()
init_t = rospy.get_time()
rate = rospy.Rate(10)
while rospy.get_time()-init_t < (17.929):
twist.linear.x = 0.1
cmd_pub.publish(twist)
rospy.loginfo(twist.linear.x)
rate.sleep()
init_t = rospy.get_time()
while rospy.get_time()-init_t < (15):
twist.linear.x = 0.046
twist.angular.z = 0.157079632
cmd_pub.publish(twist)
rospy.loginfo(twist.linear.x)
rate.sleep()
twist.linear.x = 0
twist.angular.z = 0
cmd_pub.publish(twist)
pass
def main():
try:
rospy.init_node('motor')
publisher_node()
except rospy.ROSInterruptException:
pass
if __name__ == '__main__':
main()