Skip to content

Commit 34758f5

Browse files
committed
Forgot to convert units for set_speed
1 parent d47dda1 commit 34758f5

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

XRPLib/differential_drive.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ def set_speed(self, left_speed: float, right_speed: float) -> None:
5656
: param rightSpeed: The speed (In Centimeters per Second) to set the right motor to.
5757
: type rightSpeed: float
5858
"""
59-
60-
self.left_motor.set_speed(left_speed)
61-
self.right_motor.set_speed(right_speed)
59+
# Convert from cm/s to RPM
60+
cmpsToRPM = 60 / (math.pi * self.wheel_diam)
61+
self.left_motor.set_speed(left_speed*cmpsToRPM)
62+
self.right_motor.set_speed(right_speed*cmpsToRPM)
6263

6364
def stop(self) -> None:
6465
"""

XRPLib/encoded_motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def set_speed(self, speed_rpm: float | None = None):
133133
# Convert from rev per min to ticks per 20ms (60 sec/min, 50 Hz)
134134
self.target_speed = speed_rpm*self._encoder.ticks_per_rev/(60*50)
135135

136-
def set_speed_controller(self, new_controller):
136+
def set_speed_controller(self, new_controller: Controller):
137137
"""
138138
Sets a new controller for speed control
139139

XRPLib/imu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Author: shaoziyang (shaoziyang@micropython.org.cn)
55
# v1.0 2019.7
66

7-
from machine import I2C,Pin, Timer, disable_irq, enable_irq
7+
from machine import I2C, Pin, Timer, disable_irq, enable_irq
88
import time, math
99

1010
LSM6DSO_CTRL1_XL = const(0x10)

docs/conf.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@
2828
# Uncomment the below if you use native CircuitPython modules such as
2929
# digitalio, micropython and busio. List the modules you use. Without it, the
3030
# autodoc module docs will fail to generate with a warning.
31-
# autodoc_mock_imports = ["digitalio", "busio"]
31+
autodoc_mock_imports = [
32+
'micropython',
33+
'ustruct',
34+
'machine',
35+
'board',
36+
'network',
37+
'esp',
38+
'uos',
39+
'btree',
40+
'rp2',
41+
'phew',
42+
]
3243

3344
autodoc_preserve_defaults = True
3445

0 commit comments

Comments
 (0)