Skip to content

Commit af5e437

Browse files
committed
Sphinx auto-docs working!
1 parent 59c13ab commit af5e437

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

XRPLib/differential_drive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def stop(self) -> None:
8686

8787
def reset_encoder_position(self) -> None:
8888
"""
89-
Set the position of the motors' encoders in degrees. Note that this does not actually move the motor but just recalibrates the stored encoder value.
90-
If only one encoder position is specified, the encoders for each motor will be set to that position.
89+
Resets the position of both motors' encoders to 0
9190
"""
9291

9392
self.left_motor.reset_encoder_position()
@@ -208,7 +207,8 @@ def turn(self, turn_degrees: float, max_effort: float = 0.5, timeout: float = No
208207
:type main_controller: Controller
209208
:param secondary_controller: The secondary controller, for maintaining position during the turn by controlling the encoder count difference
210209
:type secondary_controller: Controller
211-
:param use_imu: A boolean flag that changes if the main controller bases it's movement off of
210+
:param use_imu: A boolean flag that changes if the main controller bases its movement off of the imu (True) or the encoders (False)
211+
:type use_imu: bool
212212
:return: if the distance was reached before the timeout
213213
:rtype: bool
214214
"""

XRPLib/encoded_motor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def __init__(self, motor: Motor, encoder: Encoder):
5959

6060
self.target_speed = None
6161
self.DEFAULT_SPEED_CONTROLLER = PID(
62-
5,
63-
0.25,
64-
0,
62+
kp=5,
63+
ki=0.25,
64+
kd=0,
6565
)
6666
self.speedController = self.DEFAULT_SPEED_CONTROLLER
6767
self.prev_position = 0

XRPLib/imu.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
from machine import I2C, Pin, Timer, disable_irq, enable_irq
88
import time, math
99

10-
LSM6DSO_CTRL1_XL = const(0x10)
11-
LSM6DSO_CTRL2_G = const(0x11)
12-
LSM6DSO_CTRL3_C = const(0x12)
13-
LSM6DSO_CTRL6_C = const(0x15)
14-
LSM6DSO_CTRL8_XL = const(0x17)
15-
LSM6DSO_STATUS = const(0x1E)
16-
LSM6DSO_OUT_TEMP_L = const(0x20)
17-
LSM6DSO_OUTX_L_G = const(0x22)
18-
LSM6DSO_OUTY_L_G = const(0x24)
19-
LSM6DSO_OUTZ_L_G = const(0x26)
20-
LSM6DSO_OUTX_L_A = const(0x28)
21-
LSM6DSO_OUTY_L_A = const(0x2A)
22-
LSM6DSO_OUTZ_L_A = const(0x2C)
10+
LSM6DSO_CTRL1_XL = 0x10
11+
LSM6DSO_CTRL2_G = 0x11
12+
LSM6DSO_CTRL3_C = 0x12
13+
LSM6DSO_CTRL6_C = 0x15
14+
LSM6DSO_CTRL8_XL = 0x17
15+
LSM6DSO_STATUS = 0x1E
16+
LSM6DSO_OUT_TEMP_L = 0x20
17+
LSM6DSO_OUTX_L_G = 0x22
18+
LSM6DSO_OUTY_L_G = 0x24
19+
LSM6DSO_OUTZ_L_G = 0x26
20+
LSM6DSO_OUTX_L_A = 0x28
21+
LSM6DSO_OUTY_L_A = 0x2A
22+
LSM6DSO_OUTZ_L_A = 0x2C
2323

2424
"""
2525
Options for accelerometer and gyroscope scale factors
@@ -378,11 +378,11 @@ def calibrate(self, calibration_time:float=3, vertical_axis:int= 2, update_time:
378378

379379
self.acc_offsets = avg_vals[0]
380380
self.gyro_offsets = avg_vals[1]
381-
self.update_timer.init(period=update_time, callback=lambda t:self.update_imu_readings())
381+
self.update_timer.init(period=update_time, callback=lambda t:self._update_imu_readings())
382382
self.update_time = update_time/1000
383383

384384

385-
def update_imu_readings(self):
385+
def _update_imu_readings(self):
386386
# Called every tick through a callback timer
387387

388388
delta_pitch = self._get_gyro_x_rate()*self.update_time / 1000

XRPLib/webserver.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def get_default_webserver(cls):
1515
return webserver
1616

1717
def __init__(self):
18+
"""
19+
Host a webserver for the XRP v2 Robot; Register your own callbacks and log your own data to the webserver using the methods below.
20+
"""
21+
1822
gc.threshold(50000) # garbage collection
1923
self.DOMAIN = "remote.xrp"
2024
self.logged_data = {}
@@ -30,6 +34,7 @@ def __init__(self):
3034
def start_server(self, robot_number:int):
3135
"""
3236
Start the webserver
37+
3338
:param robot_number: The number of the robot, used to generate the access point name
3439
:type robot_number: int
3540
"""
@@ -68,6 +73,7 @@ def _catch_all(self, request):
6873
def log_data(self, label:str, data):
6974
"""
7075
Register a custom label to be displayed on the webserver
76+
7177
:param label: The label as it will be displayed, must be unique
7278
:type label: str
7379
:param data: The data to be displayed
@@ -78,6 +84,7 @@ def log_data(self, label:str, data):
7884
def add_button(self, button_name:str, function):
7985
"""
8086
Register a custom button to be displayed on the webserver
87+
8188
:param button_name: The label for the button as it will be displayed, must be unique
8289
:type button_name: str
8390
:param function: The function to be called when the button is pressed
@@ -88,6 +95,7 @@ def add_button(self, button_name:str, function):
8895
def registerForwardButton(self, function):
8996
"""
9097
Assign a function to the forward button
98+
9199
:param function: The function to be called when the button is pressed
92100
:type function: function
93101
"""
@@ -97,6 +105,7 @@ def registerForwardButton(self, function):
97105
def registerBackwardButton(self, function):
98106
"""
99107
Assign a function to the backward button
108+
100109
:param function: The function to be called when the button is pressed
101110
:type function: function
102111
"""
@@ -106,6 +115,7 @@ def registerBackwardButton(self, function):
106115
def registerLeftButton(self, function):
107116
"""
108117
Assign a function to the left button
118+
109119
:param function: The function to be called when the button is pressed
110120
:type function: function
111121
"""
@@ -115,6 +125,7 @@ def registerLeftButton(self, function):
115125
def registerRightButton(self, function):
116126
"""
117127
Assign a function to the right button
128+
118129
:param function: The function to be called when the button is pressed
119130
:type function: function
120131
"""
@@ -123,7 +134,8 @@ def registerRightButton(self, function):
123134

124135
def registerStopButton(self, function):
125136
"""
126-
Assign a function to the stop button
137+
Assign a function to the stop
138+
127139
:param function: The function to be called when the button is pressed
128140
:type function: function
129141
"""

docs/api.rst

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
API Reference
88
=============
9+
910
.. automodule:: XRPLib
1011
:members:
1112
:undoc-members:
@@ -62,27 +63,15 @@ Miscellaneous
6263
:members:
6364
:undoc-members:
6465

65-
.. automodule:: XRPLib.defaults
66-
:members:
67-
:undoc-members:
68-
6966
.. autoclass:: XRPLib.pid.PID
7067
:members:
7168
:undoc-members:
7269
:show-inheritance:
7370

74-
.. automodule:: XRPLib.resetbot
75-
:members:
76-
:undoc-members:
77-
7871
.. autoclass:: XRPLib.timeout.Timeout
7972
:members:
8073
:undoc-members:
8174

82-
.. automodule:: XRPLib.version
83-
:members: __version__
84-
:undoc-members:
85-
8675
.. autoclass:: XRPLib.webserver.Webserver
8776
:members:
8877
:undoc-members:

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
'btree',
4040
'rp2',
4141
'phew',
42-
]
42+
'gc']
4343

4444
autodoc_preserve_defaults = True
4545

0 commit comments

Comments
 (0)