@@ -14,8 +14,8 @@ class WheelsAxel:
14
14
that makes one wheel go slower than the other """
15
15
16
16
def __init__ (self , pi , enable_pin ,
17
- left_forward_pin , left_backward_pin , left_encoder_feedback_pin ,
18
- right_forward_pin , right_backward_pin , right_encoder_feedback_pin ):
17
+ left_forward_pin , left_backward_pin , left_encoder_feedback_pin_A , left_encoder_feedback_pin_B ,
18
+ right_forward_pin , right_backward_pin , right_encoder_feedback_pin_A , right_encoder_feedback_pin_B ):
19
19
20
20
# state variables
21
21
self ._is_moving = False
@@ -25,13 +25,15 @@ def __init__(self, pi, enable_pin,
25
25
enable_pin ,
26
26
left_forward_pin ,
27
27
left_backward_pin ,
28
- left_encoder_feedback_pin )
28
+ left_encoder_feedback_pin_A ,
29
+ left_encoder_feedback_pin_B )
29
30
# right motor
30
31
self ._right_motor = MotorEncoder (pi ,
31
32
enable_pin ,
32
33
right_forward_pin ,
33
34
right_backward_pin ,
34
- right_encoder_feedback_pin )
35
+ right_encoder_feedback_pin_B ,
36
+ right_encoder_feedback_pin_A )
35
37
36
38
# other
37
39
self ._wheelsAxle_lock = threading .Condition () # race condition lock
@@ -55,16 +57,16 @@ def speed(self):
55
57
""" Motor time control allows the motors
56
58
to run for a certain amount of time """
57
59
def control_time (self , power_left = 100 , power_right = 100 , time_elapse = 0 ):
58
- self ._wheelsAxle_lock .acquire () # wheelsAxle lock acquire
60
+ self ._wheelsAxle_lock .acquire () # wheelsAxle lock acquire
59
61
60
- # applying tension to motors
61
- self ._left_motor .control (power_left )
62
- self ._right_motor .control (power_right )
63
- self ._is_moving = True
62
+ # applying tension to motors
63
+ self ._left_motor .control (power_left )
64
+ self ._right_motor .control (power_right )
65
+ self ._is_moving = True
64
66
65
- # moving for desired time
66
- sleep (time_elapse )
67
- self .stop ()
67
+ # moving for desired time
68
+ sleep (time_elapse )
69
+ self .stop ()
68
70
69
71
""" Motor distance control allows the motors
70
72
to run for a certain amount of distance (mm) """
@@ -85,11 +87,6 @@ def control_distance(self, power_left=100, power_right=100, target_distance=0):
85
87
# robot arrived
86
88
self .stop ()
87
89
88
- """ Motor speed control allows the motors
89
- to run at a certaing amount of speed (mm/s) """
90
- def control_speed (self ):
91
- pass
92
-
93
90
# old control distance, trying to adjust power
94
91
# def control_distance(self, power_left = 100, power_right = 100, target_distance = 0):
95
92
# self._is_moving = True
@@ -120,8 +117,8 @@ def control_speed(self):
120
117
# self.stop()
121
118
122
119
""" The stop function calls the two stop functions of the two
123
- correspondent motors
124
- locks are automatically obtained """
120
+ correspondent motors.
121
+ Locks are automatically obtained """
125
122
def stop (self ):
126
123
self ._left_motor .stop ()
127
124
self ._right_motor .stop ()
@@ -130,8 +127,6 @@ def stop(self):
130
127
self ._wheelsAxle_lock .release ()
131
128
132
129
# CALLBACK
133
-
134
-
135
130
def cancel_callback (self ):
136
131
self ._right_motor .cancel_callback ()
137
132
self ._left_motor .cancel_callback ()
0 commit comments