-
Notifications
You must be signed in to change notification settings - Fork 0
/
seperatetest.py
67 lines (51 loc) · 1.27 KB
/
seperatetest.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
### this is to test the functionality of the ugv to make sure it can move, will not use ros or mavros
### uses l298n motor driver
import RPi.GPIO as GPIO
import time
import peripherals
# pin setup
GPIO.setmode(GPIO.BCM)
ussTrigPin = 18
ussEchoPin = 24
servoPin = 17
uss = peripherals.uss(ussTrigPin, ussEchoPin)
servo = peripherals.servo(servoPin)
enA = 12
in1 = 22
in2 = 10
in3 = 5
in4 = 6
enB = 13
lmotor = peripherals.motor(enA, in1, in2)
rmotor = peripherals.motor(enB, in3, in4)
# wait till aircraft says it is dropping ugv
time.sleep(5)
print('UGV NOW DROPPING')
# loop till uss sense that it is close to ground
# distance in centimeters, needs to be test with vechile to determine value while on floor
while True:
x= uss.distance()
print('UGV is {} centimeters from the ground\n'.format(x))
time.sleep(0.5)
if x < 2:
break
# move servo to cut wire
servo.moveTo(180)
time.sleep(0.5)
servo.moveTo(0)
print('UGV DISCONNECTED FROM UAV')
# tell uav or ground station that we disconnected and they can continue mission
time.sleep(2.5)
print('UGV WILL NOW DO MISSION')
lmotor.speed(50)
rmotor.speed(50)
lmotor.forward()
rmotor.forward()
time.sleep(3)
lmotor.backward()
rmotor.backward()
time.sleep(3)
lmotor.forward()
rmotor.backward()
time.sleep(3)
GPIO.cleanup()