Skip to content

Commit 2710c9c

Browse files
committed
docs: removed arg types from docstrings
1 parent b356392 commit 2710c9c

File tree

16 files changed

+687
-1072
lines changed

16 files changed

+687
-1072
lines changed

opensourceleg/actuators/base.py

Lines changed: 170 additions & 475 deletions
Large diffs are not rendered by default.

opensourceleg/actuators/decorators.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def check_actuator_connection(func: Callable) -> Callable:
1616
offline, it raises an ActuatorConnectionException using the actuator's tag.
1717
1818
Args:
19-
func (Callable): The method to wrap. It is expected to be an instance method of ActuatorBase.
19+
func: The method to wrap. It is expected to be an instance method of ActuatorBase.
2020
2121
Returns:
22-
Callable: The wrapped method that executes only if the actuator is online.
22+
The wrapped method that executes only if the actuator is online.
2323
2424
Raises:
2525
ActuatorConnectionException: If the actuator is offline.
@@ -52,10 +52,10 @@ def check_actuator_open(func: Callable) -> Callable:
5252
it raises an ActuatorConnectionException with the actuator's tag.
5353
5454
Args:
55-
func (Callable): The method to wrap. It is expected to be an instance method of ActuatorBase.
55+
func: The method to wrap. It is expected to be an instance method of ActuatorBase.
5656
5757
Returns:
58-
Callable: The wrapped method that executes only if the actuator is open.
58+
The wrapped method that executes only if the actuator is open.
5959
6060
Raises:
6161
ActuatorConnectionException: If the actuator is not open.
@@ -68,7 +68,6 @@ def check_actuator_open(func: Callable) -> Callable:
6868
...
6969
>>> actuator = MyActuator()
7070
>>> actuator.my_method()
71-
7271
"""
7372

7473
@wraps(func)
@@ -89,10 +88,10 @@ def check_actuator_stream(func: Callable) -> Callable:
8988
is not streaming, it raises an ActuatorStreamException using the actuator's tag.
9089
9190
Args:
92-
func (Callable): The method to wrap. It is expected to be an instance method of ActuatorBase.
91+
func: The method to wrap. It is expected to be an instance method of ActuatorBase.
9392
9493
Returns:
95-
Callable: The wrapped method that executes only if the actuator is streaming.
94+
The wrapped method that executes only if the actuator is streaming.
9695
9796
Raises:
9897
ActuatorStreamException: If the actuator is not streaming.

opensourceleg/actuators/dephy.py

Lines changed: 62 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ def home(
297297
also load the encoder map if it exists. The encoder map is a polynomial that maps the encoder counts
298298
to joint position in radians. This is useful for more accurate joint position estimation.
299299
Args:
300-
homing_voltage (int): Voltage in mV to use for homing. Default is 2000 mV.
301-
homing_frequency (int): Frequency in Hz to use for homing. Default is the actuator's frequency.
302-
homing_direction (int): Direction to move the actuator during homing. Default is -1.
303-
joint_direction (int): Direction to move the joint during homing. Default is -1.
304-
joint_position_offset (float): Offset in radians to add to the joint position. Default is 0.0.
305-
motor_position_offset (float): Offset in radians to add to the motor position. Default is 0.0.
306-
current_threshold (int): Current threshold in mA to stop homing the joint or actuator.
300+
homing_voltage: Voltage in mV to use for homing. Default is 2000 mV.
301+
homing_frequency: Frequency in Hz to use for homing. Default is the actuator's frequency.
302+
homing_direction: Direction to move the actuator during homing. Default is -1.
303+
joint_direction: Direction to move the joint during homing. Default is -1.
304+
joint_position_offset: Offset in radians to add to the joint position. Default is 0.0.
305+
motor_position_offset: Offset in radians to add to the motor position. Default is 0.0.
306+
current_threshold: Current threshold in mA to stop homing the joint or actuator.
307307
This is used to detect if the actuator or joint has hit a hard stop. Default is 5000 mA.
308-
velocity_threshold (float): Velocity threshold in rad/s to stop homing the joint or actuator.
308+
velocity_threshold: Velocity threshold in rad/s to stop homing the joint or actuator.
309309
This is also used to detect if the actuator or joint has hit a hard stop. Default is 0.001 rad/s.
310310
Examples:
311311
>>> actuator = DephyActuator(port='/dev/ttyACM0')
@@ -457,7 +457,7 @@ def set_motor_torque(self, value: float) -> None:
457457
"""
458458
Sets the motor torque in Nm. This is the torque that is applied to the motor rotor, not the joint or output.
459459
Args:
460-
value (float): The torque to set in Nm.
460+
value: The torque to set in Nm.
461461
Returns:
462462
None
463463
Examples:
@@ -475,7 +475,7 @@ def set_joint_torque(self, value: float) -> None:
475475
This is the torque that is applied to the joint, not the motor.
476476
477477
Args:
478-
value (float): torque in N_m
478+
value: torque in N_m
479479
480480
Returns:
481481
None
@@ -494,7 +494,7 @@ def set_output_torque(self, value: float) -> None:
494494
This is the torque that is applied to the joint, not the motor.
495495
496496
Args:
497-
value (float): torque in N_m
497+
value: torque in N_m
498498
499499
Returns:
500500
None
@@ -514,7 +514,7 @@ def set_motor_current(
514514
Sets the motor current in mA.
515515
516516
Args:
517-
value (float): The current to set in mA.
517+
value: The current to set in mA.
518518
Returns:
519519
None
520520
@@ -534,15 +534,15 @@ def set_motor_voltage(self, value: float) -> None:
534534
Sets the motor voltage in mV.
535535
536536
Args:
537-
value (float): The voltage to set in mV.
537+
value: The voltage to set in mV.
538538
539539
Returns:
540540
None
541541
542542
Examples:
543543
>>> actuator = DephyActuator(port='/dev/ttyACM0')
544544
>>> actuator.start()
545-
>>> actuator.set_motor_voltage(100) TODO: Validate number
545+
>>> actuator.set_motor_voltage(100)
546546
"""
547547
self.command_motor_voltage(value=int(value))
548548

@@ -556,7 +556,7 @@ def set_motor_position(self, value: float) -> None:
556556
If in impedance mode, this sets the equilibrium angle in radians.
557557
558558
Args:
559-
value (float): The position to set
559+
value: The position to set
560560
561561
Returns:
562562
None
@@ -593,10 +593,10 @@ def set_position_gains(
593593
Sets the position gains in arbitrary Dephy units.
594594
595595
Args:
596-
kp (float): The proportional gain
597-
ki (float): The integral gain
598-
kd (float): The derivative gain
599-
ff (float): The feedforward gain
596+
kp: The proportional gain
597+
ki: The integral gain
598+
kd: The derivative gain
599+
ff: The feedforward gain
600600
601601
Returns:
602602
None
@@ -626,10 +626,10 @@ def set_current_gains(
626626
Sets the current gains in arbitrary Dephy units.
627627
628628
Args:
629-
kp (float): The proportional gain
630-
ki (float): The integral gain
631-
kd (float): The derivative gain
632-
ff (float): The feedforward gain
629+
kp: The proportional gain
630+
ki: The integral gain
631+
kd: The derivative gain
632+
ff: The feedforward gain
633633
634634
Returns:
635635
None
@@ -666,12 +666,12 @@ def set_output_impedance(
666666
B_motor = B_joint / (gear_ratio ** 2)
667667
668668
Args:
669-
kp (float): Proportional gain. Defaults to 40.
670-
ki (float): Integral gain. Defaults to 400.
671-
kd (float): Derivative gain. Defaults to 0.
672-
k (float): Spring constant. Defaults to 100 Nm/rad.
673-
b (float): Damping constant. Defaults to 3.0 Nm/rad/s.
674-
ff (float): Feedforward gain. Defaults to 128.
669+
kp: Proportional gain. Defaults to 40.
670+
ki: Integral gain. Defaults to 400.
671+
kd: Derivative gain. Defaults to 0.
672+
k: Spring constant. Defaults to 100 Nm/rad.
673+
b: Damping constant. Defaults to 3.0 Nm/rad/s.
674+
ff: Feedforward gain. Defaults to 128.
675675
676676
Returns:
677677
None
@@ -704,12 +704,12 @@ def set_impedance_gains(
704704
See Dephy's webpage for conversions or use other library methods that handle conversion for you.
705705
706706
Args:
707-
kp (float): The proportional gain
708-
ki (float): The integral gain
709-
kd (float): The derivative gain
710-
k (float): The spring constant
711-
b (float): The damping constant
712-
ff (float): The feedforward gain
707+
kp: The proportional gain
708+
ki: The integral gain
709+
kd: The derivative gain
710+
k: The spring constant
711+
b: The damping constant
712+
ff: The feedforward gain
713713
714714
Returns:
715715
None
@@ -741,20 +741,20 @@ def set_motor_impedance(
741741
Set the impedance gains of the motor in real units: Nm/rad and Nm/rad/s.
742742
743743
Args:
744-
kp (float): Proportional gain. Defaults to 40.
745-
ki (float): Integral gain. Defaults to 400.
746-
kd (float): Derivative gain. Defaults to 0.
747-
k (float): Spring constant. Defaults to 0.08922 Nm/rad.
748-
b (float): Damping constant. Defaults to 0.0038070 Nm/rad/s.
749-
ff (float): Feedforward gain. Defaults to 128.
744+
kp: Proportional gain. Defaults to 40.
745+
ki: Integral gain. Defaults to 400.
746+
kd: Derivative gain. Defaults to 0.
747+
k: Spring constant. Defaults to 0.08922 Nm/rad.
748+
b: Damping constant. Defaults to 0.0038070 Nm/rad/s.
749+
ff: Feedforward gain. Defaults to 128.
750750
751751
Returns:
752752
None
753753
754754
Examples:
755755
>>> actuator = DephyActuator(port='/dev/ttyACM0')
756756
>>> actuator.start()
757-
>>> actuator.set_motor_impedance(kp=40, ki=400, kd=0, k=0.08922, b=0.0038070, ff=128) TODO: Validate numbers
757+
>>> actuator.set_motor_impedance(kp=40, ki=400, kd=0, k=0.08922, b=0.0038070, ff=128)
758758
"""
759759
self.set_impedance_gains(
760760
kp=kp,
@@ -770,7 +770,7 @@ def set_encoder_map(self, encoder_map: np.polynomial.polynomial.Polynomial) -> N
770770
Sets the joint encoder map
771771
772772
Args:
773-
encoder_map (np.polynomial.polynomial.Polynomial): The encoder map to set
773+
encoder_map: The encoder map to set
774774
775775
Returns:
776776
None
@@ -1478,7 +1478,7 @@ def set_motor_current(
14781478
Sets the motor current in mA.
14791479
14801480
Args:
1481-
value (float): The current to set in mA.
1481+
value: The current to set in mA.
14821482
"""
14831483
self.send_motor_command(ctrl_mode=c_int(self.mode.value), value=int(value))
14841484

@@ -1491,7 +1491,15 @@ def set_motor_voltage(self, value: float) -> None:
14911491
Sets the motor voltage in mV.
14921492
14931493
Args:
1494-
value (float): The voltage to set in mV.
1494+
value: The voltage to set in mV.
1495+
1496+
Returns:
1497+
None
1498+
1499+
Examples:
1500+
>>> actuator = DephyActuator(port='/dev/ttyACM0')
1501+
>>> actuator.start()
1502+
>>> actuator.set_motor_voltage(100)
14951503
"""
14961504
self.send_motor_command(ctrl_mode=c_int(self.mode.value), value=int(value))
14971505

@@ -1505,7 +1513,15 @@ def set_motor_position(self, value: float) -> None:
15051513
If in impedance mode, this sets the equilibrium angle in radians.
15061514
15071515
Args:
1508-
value (float): The position to set
1516+
value: The position to set
1517+
1518+
Returns:
1519+
None
1520+
1521+
Examples:
1522+
>>> actuator = DephyActuator(port='/dev/ttyACM0')
1523+
>>> actuator.start()
1524+
>>> actuator.set_motor_position(0.1)
15091525
"""
15101526
self.send_motor_command(
15111527
ctrl_mode=c_int(self.mode.value),

opensourceleg/actuators/moteus.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def set_motor_torque(self, value: float) -> None:
283283
Sets the motor torque in Nm.
284284
285285
Args:
286-
value (float): The torque to set in Nm.
286+
value: The torque to set in Nm.
287287
"""
288288
self._command = self.make_position(
289289
position=math.nan,
@@ -302,7 +302,7 @@ def set_joint_torque(self, value: float) -> None:
302302
This is the torque that is applied to the joint, not the motor.
303303
304304
Args:
305-
value (float): torque in N_m
305+
value: torque in N_m
306306
"""
307307
self.set_motor_torque(value=value / self.gear_ratio)
308308

@@ -325,7 +325,7 @@ def set_motor_voltage(self, value: float) -> None:
325325
Sets the motor voltage in mV.
326326
327327
Args:
328-
value (float): The voltage to set in mV.
328+
value: The voltage to set in mV.
329329
"""
330330
LOGGER.info("Voltage Mode Not Implemented")
331331

@@ -335,7 +335,7 @@ def set_motor_position(self, value: float) -> None:
335335
If in impedance mode, this sets the equilibrium angle in radians.
336336
337337
Args:
338-
value (float): The position to set
338+
value: The position to set
339339
"""
340340
self._command = self.make_position(
341341
position=float((value) / (2 * np.pi)), # TODO: Verify this conversion, are we converting from rad to rev?
@@ -352,8 +352,8 @@ async def set_torque_gains(
352352
Sets the position gains in arbitrary Moteus units.
353353
354354
Args:
355-
kp (float): The proportional gain
356-
ki (float): The integral gain
355+
kp: The proportional gain
356+
ki: The integral gain
357357
"""
358358
await self._stream.command(f"conf set servo.pid_dq.kp {kp}".encode())
359359
await self._stream.command(f"conf set servo.pid_dq.ki {ki}".encode())
@@ -369,10 +369,10 @@ async def set_position_gains(
369369
Sets the position gains in arbitrary Moteus units.
370370
371371
Args:
372-
kp (float): The proportional gain
373-
ki (float): The integral gain
374-
kd (float): The derivative gain
375-
ff (float): The feedforward gain
372+
kp: The proportional gain
373+
ki: The integral gain
374+
kd: The derivative gain
375+
ff: The feedforward gain
376376
"""
377377
await self._stream.command(f"conf set servo.pid_position.kp {kp}".encode())
378378
await self._stream.command(f"conf set servo.pid_position.ki {ki}".encode())
@@ -389,10 +389,10 @@ async def set_velocity_gains(
389389
Sets the position gains in arbitrary Moteus units.
390390
391391
Args:
392-
kp (float): The proportional gain
393-
ki (float): The integral gain
394-
kd (float): The derivative gain
395-
ff (float): The feedforward gain
392+
kp: The proportional gain
393+
ki: The integral gain
394+
kd: The derivative gain
395+
ff: The feedforward gain
396396
"""
397397
await self._stream.command(f"conf set servo.pid_position.kp {kp}".encode())
398398
await self._stream.command(f"conf set servo.pid_position.ki {ki}".encode())
@@ -409,10 +409,10 @@ def set_current_gains(
409409
Sets the current gains in arbitrary Moteus units.
410410
411411
Args:
412-
kp (float): The proportional gain
413-
ki (float): The integral gain
414-
kd (float): The derivative gain
415-
ff (float): The feedforward gain
412+
kp: The proportional gain
413+
ki: The integral gain
414+
kd: The derivative gain
415+
ff: The feedforward gain
416416
"""
417417
LOGGER.info(msg=f"[{self.__repr__()}] Current mode not implemented.")
418418

@@ -425,6 +425,17 @@ def set_impedance_gains(
425425
b: float = DEFAULT_IMPEDANCE_GAINS.b,
426426
ff: float = DEFAULT_IMPEDANCE_GAINS.ff,
427427
) -> None:
428+
"""
429+
Sets the impedance gains in arbitrary Moteus units.
430+
431+
Args:
432+
kp: The proportional gain
433+
ki: The integral gain
434+
kd: The derivative gain
435+
k: The stiffness gain
436+
b: The damping gain
437+
ff: The feedforward gain
438+
"""
428439
LOGGER.info(msg=f"[{self.__repr__()}] Impedance mode not implemented.")
429440

430441
@property

0 commit comments

Comments
 (0)