-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_clacson.py
126 lines (112 loc) · 3.84 KB
/
test_clacson.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import leds
import ultrasonic_sensors
import system_info
import engines
import servo
import clacson
import accelerometr
import smbus
import time
import threading
import speaking_car
import pygame
import RPi.GPIO as GPIO
clacson = clacson.clacson()
t_clacson = threading.Thread(target=clacson.main )
t_clacson.start()
# #
clacson.clacson_on = True
clacson.play_short = True
time.sleep(5)
# acc.velocity = 0
speaking_car = speaking_car.speaking_car()
speaking_car.play_cinquanta()
time.sleep(0.5)
#acc.stop()
# clacson = clacson.clacson()
# t_clacson = threading.Thread(target=clacson.main )
# t_clacson.start()
#
# clacson.clacson_on = True
# while True:
# print " front distance " , front_distance.distance
# print " rear distance ", rear_distance.distance
# time.sleep(0.3)
# while end_cycle == False:
# time.sleep(0.1)
# if time.time() - start_time > 10 :
# end_cycle = True
# if rear_distance.distance < 40 and front_distance.distance < 40 :
# print " NON MI MUOVO !!!!!!!"
# print " NON MI MUOVO !!!!!!!"
# print " NON MI MUOVO !!!!!!!"
# print " NON MI MUOVO !!!!!!!"
# print " NON MI MUOVO !!!!!!!"
# print " NON MI MUOVO !!!!!!!"
# servo.turning_time = 0
# servo.desired_degree = 0
# end_cycle = True
#
# if engine.actual_direction== "forward":
# if front_distance.distance >= 100 :
# print " front distance ", front_distance.distance
# if last_turn_to_left > 0:
# servo.desired_degree = 0
# obstacle_avoided = True
# engine.acceleration = 2
# engine.desired_speed = 50
# time.sleep(.5)
# print "returning straight "
# print "returning straight "
# print "returning straight "
# print "returning straight "
# servo.turning_time = 0
# servo.desired_degree = 0
# servo.desired_degree = +35
# engine.desired_speed = 50
# engine.acceleration = 2
#
# time.sleep(1)
# servo.desired_degree = 0
# time.sleep(1)
# end_cycle = True
#
#
# if obstacle_avoided == False:
# if 40 < front_distance.distance < 100:
# print " front distance ", front_distance.distance
# if servo.actual_degree == 0 :
# servo.turning_time = 0.3
# servo.desired_degree = -35
# last_turn_to_left = time.time()
# print "TRYING TO AVOID OBSTACLE TURNING LEFT = "
#
# if front_distance.distance <= 40 and obstacle_avoided == False:
# print " ostacolo DAVANTI TROPPO VICINO !!!! INTERROMPO !!!!"
# # servo.turning_time = 0
# # servo.desired_degree = +25
# #
# # engine.desired_direction = "backward"
# # engine.desired_speed = 70
# # engine.acceleration = 3
# # time.sleep(1.5)
# # servo.desired_degree = 0
# # engine.desired_direction = "forward"
# engine.desired_direction = "stay"
# end_cycle = True
#
# # if engine.actual_direction== "backward":
# # if rear_distance.distance < 40:
# # print " ostacolo dietro !!!!"
# # print " ostacolo dietro !!!!"
# # print " ostacolo dietro !!!!"
# # print " ostacolo dietro !!!!"
# # servo.turning_time = 0
# # servo.desired_degree = 15
# # engine.desired_speed = 70
# # engine.acceleration = 2
# # engine.desired_direction = "forward"
# time.sleep(0.01)
clacson.clacson_on = False
time.sleep(.5)
#stop_everything()