Skip to content

Commit a263ce9

Browse files
DrClickWasabiFan
authored andcommitted
Use speed instead of duty cycle in EXPLOR3R/auto-drive.py (#250)
1 parent 1f783c3 commit a263ce9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

demo/EXPLOR3R/auto-drive.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
ir = InfraredSensor(); assert ir.connected
4949
ts = TouchSensor(); assert ts.connected
5050

51+
print('Robot Starting')
52+
5153
# We will need to check EV3 buttons state.
5254
btn = Button()
5355

@@ -76,7 +78,7 @@ def backup():
7678
# until both motors are stopped before continuing.
7779
for m in motors:
7880
m.stop(stop_action='brake')
79-
m.run_timed(duty_cycle_sp=-50, time_sp=1500)
81+
m.run_timed(speed_sp=-500, time_sp=1500)
8082

8183
# When motor is stopped, its `state` attribute returns empty list.
8284
# Wait until both motors are stopped:
@@ -99,7 +101,7 @@ def turn():
99101
t = randint(250, 750)
100102

101103
for m, p in zip(motors, power):
102-
m.run_timed(duty_cycle_sp=p*75, time_sp=t)
104+
m.run_timed(speed_sp = p * 750, time_sp = t)
103105

104106
# Wait until both motors are stopped:
105107
while any(m.state for m in motors):
@@ -122,10 +124,10 @@ def turn():
122124

123125
if distance > 60:
124126
# Path is clear, run at full speed.
125-
dc = 90
127+
dc = 95
126128
else:
127129
# Obstacle ahead, slow down.
128-
dc = 40
130+
dc = 30
129131

130132
for m in motors:
131133
m.duty_cycle_sp = dc

0 commit comments

Comments
 (0)