@@ -12,18 +12,18 @@ class EncodedMotor:
12
12
_DEFAULT_MOTOR_FOUR_INSTANCE = None
13
13
14
14
@classmethod
15
- def get_default_encoded_motor (cls , index :int ):
15
+ def get_default_encoded_motor (cls , index :int = 0 ):
16
16
"""
17
17
Get one of the default XRP v2 motor instances. These are singletons, so only one instance of each of these will ever exist.
18
+ Motor indexes:
19
+ 0 - Left Motor
20
+ 1 - Right Motor
21
+ 2 - Motor 3
22
+ 3 - Motor 4
23
+ Left Motor is the default, so if no index is specified, the left motor will be returned.
18
24
"""
19
- if index == 0 : # Left Motor
20
- if cls ._DEFAULT_LEFT_MOTOR_INSTANCE is None :
21
- cls ._DEFAULT_LEFT_MOTOR_INSTANCE = cls (
22
- Motor (6 , 7 , flip_dir = True ),
23
- Encoder (0 , 4 , 5 )
24
- )
25
- motor = cls ._DEFAULT_LEFT_MOTOR_INSTANCE
26
- elif index == 1 :
25
+
26
+ if index == 1 :
27
27
if cls ._DEFAULT_RIGHT_MOTOR_INSTANCE is None :
28
28
cls ._DEFAULT_RIGHT_MOTOR_INSTANCE = cls (
29
29
Motor (14 , 15 ),
@@ -44,8 +44,16 @@ def get_default_encoded_motor(cls, index:int):
44
44
Encoder (3 , 8 , 9 )
45
45
)
46
46
motor = cls ._DEFAULT_MOTOR_FOUR_INSTANCE
47
+ else :
48
+ # Left Motor
49
+ if cls ._DEFAULT_LEFT_MOTOR_INSTANCE is None :
50
+ cls ._DEFAULT_LEFT_MOTOR_INSTANCE = cls (
51
+ Motor (6 , 7 , flip_dir = True ),
52
+ Encoder (0 , 4 , 5 )
53
+ )
54
+ motor = cls ._DEFAULT_LEFT_MOTOR_INSTANCE
47
55
return motor
48
-
56
+
49
57
@classmethod
50
58
def get_default_encoded_motor (cls ):
51
59
"""
0 commit comments