Completed things docs

This commit is contained in:
Pascal Serrarens 2025-04-30 11:40:59 +02:00
parent 97eafeccfc
commit de73cd5edc
2 changed files with 22 additions and 6 deletions

View File

@ -23,9 +23,10 @@ class Thing:
Servo = 0x08 Servo = 0x08
# Other # Other
Roboid = 0x09 Roboid = 0x09
Humanoid = 0x10 Humanoid = 0x0A
ExternalSensor = 0x11 ExternalSensor = 0x0B
Animator = 0x40 Animator = 0x0C
DifferentialDrive = 0x0D
Position = 0x01 Position = 0x01
Orientation = 0x02 Orientation = 0x02

View File

@ -5,21 +5,32 @@ from LinearAlgebra.Angle import Angle
class DifferentialDrive(Thing): class DifferentialDrive(Thing):
"""! A thing which can move itself using a differential drive system """! A thing which can move itself using a differential drive system
@sa @link https://en.wikipedia.org/wiki/Differential_wheeled_robot @endlink
""" """
def __init__(self, participant = None): def __init__(self, owner = None, parent = None, thing_id = 0):
"""! Create a new differential drive """! Create a differential drive
""" """
super().__init__(participant) super().__init__(owner = owner, parent = parent, thing_type = Thing.Type.DifferentialDrive, thing_id = thing_id)
## The radius of a wheel in meters ## The radius of a wheel in meters
self.wheel_radius = 1.0 self.wheel_radius = 1.0
## The distance between the wheels in meters ## The distance between the wheels in meters
self.wheel_separation = 1.0 self.wheel_separation = 1.0
## The left wheel
self.wheel_left: Thing = None self.wheel_left: Thing = None
## The right wheel
self.wheel_right: Thing = None self.wheel_right: Thing = None
def SetDriveDimensions(self, wheel_diameter, wheel_separation): def SetDriveDimensions(self, wheel_diameter, wheel_separation):
"""! Configures the dimensions of the drive
@param wheelDiameter The diameter of the wheels in meters
@param wheelSeparation The distance between the wheels in meters
These values are used to compute the desired wheel speed from the set
linear and angular velocity.
@sa SetLinearVelocity SetAngularVelocity
"""
if wheel_diameter < 0: if wheel_diameter < 0:
wheel_diameter = -wheel_diameter wheel_diameter = -wheel_diameter
self.wheel_radius = wheel_diameter / 2 self.wheel_radius = wheel_diameter / 2
@ -31,6 +42,10 @@ class DifferentialDrive(Thing):
self.SetMotors(self.wheel_left, self.wheel_right) self.SetMotors(self.wheel_left, self.wheel_right)
def SetMotors(self, wheel_left, wheel_right): def SetMotors(self, wheel_left, wheel_right):
"""! Congures the motors for the wheels
@param leftWheel The motor for the left wheel
@param rightWheel The motor for the right wheel
"""
distance: float = self.wheel_separation / 2 distance: float = self.wheel_separation / 2
self.wheel_left = wheel_left self.wheel_left = wheel_left