66from .timeout import Timeout
77import time
88import math
9- from sys import implementation
109
1110class DifferentialDrive :
1211
@@ -38,9 +37,9 @@ def __init__(self, left_motor: EncodedMotor, right_motor: EncodedMotor, imu: IMU
3837 :type rightMotor: EncodedMotor
3938 :param imu: The IMU of the robot. If None, the robot will not use the IMU for turning or maintaining heading.
4039 :type imu: IMU
41- :param wheelDiam: The diameter of the wheels in inches. Defaults to 6 cm.
40+ :param wheelDiam: The diameter of the wheels in cm.
4241 :type wheelDiam: float
43- :param wheelTrack: The distance between the wheels in inches. Defaults to 15.5 cm.
42+ :param wheelTrack: The distance between the wheels in cm.
4443 :type wheelTrack: float
4544 """
4645
@@ -53,27 +52,18 @@ def __init__(self, left_motor: EncodedMotor, right_motor: EncodedMotor, imu: IMU
5352 # Resolve hardware defaults when the caller leaves the arg at its 0.0 sentinel;
5453 # honor any explicit non-zero value that is passed in.
5554 if wheel_diam == 0.0 :
56- if "NanoXRP" in implementation ._machine :
57- self .wheel_diam = 3.46
58- else :
59- self .wheel_diam = 6.0
55+ self .wheel_diam = 3.46 if Board .get_type () == Board .NANO else 6.0
6056 else :
6157 self .wheel_diam = wheel_diam
6258
6359 if wheel_track == 0.0 :
64- if "NanoXRP" in implementation ._machine :
65- self .wheel_track = 7.8
66- else :
67- self .wheel_track = 15.5
60+ self .wheel_track = 7.8 if Board .get_type () == Board .NANO else 15.5
6861 else :
6962 self .wheel_track = wheel_track
7063
7164 # Effort is raw PWM duty, so torque scales with pack voltage. Gains are tuned against
7265 # nominal_voltage and voltage_scale corrects the duty for the pack actually installed.
73- if "NanoXRP" in implementation ._machine :
74- self .nominal_voltage = 4.2
75- else :
76- self .nominal_voltage = 6.0
66+ self .nominal_voltage = 4.2 if Board .get_type () == Board .NANO else 6.0
7767
7868 self .voltage_scale = 1.0
7969 self .update_voltage_compensation ()
@@ -84,7 +74,7 @@ def __init__(self, left_motor: EncodedMotor, right_motor: EncodedMotor, imu: IMU
8474 self ._holding_heading = False
8575
8676 if self .imu :
87- if "NanoXRP" in implementation . _machine :
77+ if Board . get_type () == Board . NANO :
8878 self .heading_pid = PID (kp = 0.014 , kd = 0.001 )
8979 else :
9080 self .heading_pid = PID (kp = 0.064 , kd = 0.0045 )
@@ -224,9 +214,9 @@ def _move(self, distance_target: float, heading_target: float, max_effort: float
224214 Shared translation/rotation controller for straight() and turn().
225215 """
226216
227- if "NanoXRP" in implementation . _machine :
217+ if Board . get_type () == Board . NANO :
228218 if min_effort is None :
229- min_effort = 0.10
219+ min_effort = 0.10
230220
231221 if distance_controller is None :
232222 distance_controller = PID (
0 commit comments