From de73cd5edc2d64530db26477de18a034a52a1584 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 30 Apr 2025 11:40:59 +0200 Subject: [PATCH] Completed things docs --- RoboidControl/Thing.py | 7 ++++--- RoboidControl/Things/DifferentialDrive.py | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/RoboidControl/Thing.py b/RoboidControl/Thing.py index 5da7919..d27c667 100644 --- a/RoboidControl/Thing.py +++ b/RoboidControl/Thing.py @@ -23,9 +23,10 @@ class Thing: Servo = 0x08 # Other Roboid = 0x09 - Humanoid = 0x10 - ExternalSensor = 0x11 - Animator = 0x40 + Humanoid = 0x0A + ExternalSensor = 0x0B + Animator = 0x0C + DifferentialDrive = 0x0D Position = 0x01 Orientation = 0x02 diff --git a/RoboidControl/Things/DifferentialDrive.py b/RoboidControl/Things/DifferentialDrive.py index 38853a0..2e8b3c4 100644 --- a/RoboidControl/Things/DifferentialDrive.py +++ b/RoboidControl/Things/DifferentialDrive.py @@ -5,21 +5,32 @@ from LinearAlgebra.Angle import Angle class DifferentialDrive(Thing): """! 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): - """! Create a new differential drive + def __init__(self, owner = None, parent = None, thing_id = 0): + """! 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 self.wheel_radius = 1.0 ## The distance between the wheels in meters self.wheel_separation = 1.0 + ## The left wheel self.wheel_left: Thing = None + ## The right wheel self.wheel_right: Thing = None 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: wheel_diameter = -wheel_diameter self.wheel_radius = wheel_diameter / 2 @@ -31,6 +42,10 @@ class DifferentialDrive(Thing): self.SetMotors(self.wheel_left, self.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 self.wheel_left = wheel_left