-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulation.py
78 lines (58 loc) · 1.44 KB
/
simulation.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
import roslib
import rospy
from geometry_msgs.msg import Twist, TransformStamped
from std_msgs.msg import Empty
import sys
import select
import termios
import tty
import time
speed = 0.2 # default linear speed
turn = 1.0 # default angular speed
pub = rospy.Publisher('/bebop/cmd_vel', Twist, queue_size=1)
pub_takeoff = rospy.Publisher('/bebop/takeoff', Empty, queue_size=10)
pub_land = rospy.Publisher('/bebop/land', Empty, queue_size=10)
print('Take off')
empty = Empty()zs
pub_takeoff.publish(empty)
twist = Twist()
(x,y,z,th) = (0, 0, 1, 0)
twist.linear.x = x * speed
twist.linear.y = y * speed
twist.linear.z = z * speed
twist.angular.x = 0
twist.angular.y = 0
twist.angular.z = th * turn
pub.publish(twist)
time.sleep(2)
(x,y,z,th) = (1, 0, 0, 1)
twist.linear.x = x * speed
twist.linear.y = y * speed
twist.linear.z = z * speed
twist.angular.x = 0
twist.angular.y = 0
twist.angular.z = th * turn
pub.publish(twist)
time.sleep(0.9)
(x,y,z,th) = (1, 0, 0, 0)
twist.linear.x = x * speed
twist.linear.y = y * speed
twist.linear.z = z * speed
twist.angular.x = 0
twist.angular.y = 0
twist.angular.z = th * turn
pub.publish(twist)
time.sleep(0.72)
(x,y,z,th) = (0, 0, -1, 0)
twist.linear.x = x * speed
twist.linear.y = y * speed
twist.linear.z = z * speed
twist.angular.x = 0
twist.angular.y = 0
twist.angular.z = th * turn
pub.publish(twist)
time.sleep(0.95)
print('Landing...')
empty = Empty()
pub_land.publish(empty)