Skip to content

Commit 34dee5e

Browse files
authored
Merge pull request #267 from dwalton76/develop-misc
utils move_motor and stop_motor update to python3
2 parents e06b7ff + 151110a commit 34dee5e

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

utils/move_motor.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
"""
44
Used to adjust the position of a motor in an already assembled robot
55
where you can"t move the motor by hand.
66
"""
77

8-
from ev3dev.auto import OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D
9-
from ev3dev.helper import LargeMotor
8+
from ev3dev.auto import OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D, Motor
109
import argparse
1110
import logging
1211
import sys
@@ -19,19 +18,18 @@
1918
args = parser.parse_args()
2019

2120
# logging
22-
logging.basicConfig(level=logging.DEBUG,
21+
logging.basicConfig(level=logging.INFO,
2322
format="%(asctime)s %(levelname)5s: %(message)s")
2423
log = logging.getLogger(__name__)
2524

26-
# For this it doesn't really matter if it is a LargeMotor or a MediumMotor
2725
if args.motor == "A":
28-
motor = LargeMotor(OUTPUT_A)
26+
motor = Motor(OUTPUT_A)
2927
elif args.motor == "B":
30-
motor = LargeMotor(OUTPUT_B)
28+
motor = Motor(OUTPUT_B)
3129
elif args.motor == "C":
32-
motor = LargeMotor(OUTPUT_C)
30+
motor = Motor(OUTPUT_C)
3331
elif args.motor == "D":
34-
motor = LargeMotor(OUTPUT_D)
32+
motor = Motor(OUTPUT_D)
3533
else:
3634
raise Exception("%s is invalid, options are A, B, C, D")
3735

@@ -40,13 +38,8 @@
4038
sys.exit(1)
4139

4240
if args.degrees:
43-
log.info("Motor %s, move to position %d, max speed %d" % (args.motor, args.degrees, motor.max_speed))
41+
log.info("Motor %s, current position %d, move to position %d, max speed %d" %
42+
(args.motor, motor.position, args.degrees, motor.max_speed))
4443
motor.run_to_rel_pos(speed_sp=args.speed,
4544
position_sp=args.degrees,
46-
# ramp_up_sp=500,
47-
# ramp_down_sp=500,
4845
stop_action='hold')
49-
motor.wait_for_running()
50-
motor.wait_for_stop()
51-
motor.stop(stop_action='brake')
52-
log.info("Motor %s stopped, final position %d" % (args.motor, motor.position))

utils/stop_all_motors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
"""
44
Stop all motors

0 commit comments

Comments
 (0)