From 3892c2baebea12ec7fc877b1cc659fff9b1fa7e6 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 11 Mar 2025 17:34:23 +0100 Subject: [PATCH] Added diff.drive and touchsensor --- Things/DifferentialDrive.py | 11 +++++++++++ Things/TouchSensor.py | 13 ++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Things/DifferentialDrive.py b/Things/DifferentialDrive.py index 4fd62cb..04a3266 100644 --- a/Things/DifferentialDrive.py +++ b/Things/DifferentialDrive.py @@ -4,7 +4,11 @@ from LinearAlgebra.Direction import Direction from LinearAlgebra.Angle import Angle class DifferentialDrive(Thing): + """! A thing which can move itself using a differential drive system + """ def __init__(self, participant = None): + """! Create a new differential drive + """ super().__init__(participant) ## The radius of a wheel in meters @@ -38,6 +42,10 @@ class DifferentialDrive(Thing): self.wheel_right.SetPosition(Spherical(distance, Direction.Right)) def SetWheelVelocity(self, speed_left, speed_right): + """! Directly specify the speeds of the motors + @params speed_left The speed of the left wheel in degrees per second. Positive moves the robot in the forward direction. + @params speed_right The speed of the right wheel in degrees per second. Positive moves the robot in the forward direction. + """ if self.wheel_left is not None: self.wheel_left.SetAngularVelocity(Spherical(speed_left, Direction.Left)) @@ -45,6 +53,9 @@ class DifferentialDrive(Thing): self.wheel_right.SetAngularVelocity(Spherical(speed_right, Direction.Right)) def Update(self, currentTimeMs, recursive = True): + """! + @copydoc Thing::Update + """ # This assumes forward velocity only... linear_velocity: Spherical = self.GetLinearVelocity().distance diff --git a/Things/TouchSensor.py b/Things/TouchSensor.py index 2179107..f202552 100644 --- a/Things/TouchSensor.py +++ b/Things/TouchSensor.py @@ -1,14 +1,17 @@ from Thing import Thing class TouchSensor(Thing): + """! A sensor which can detect touches + """ def __init__(self, owner, parent): + """! Create a touch sensor + """ super().__init__(owner, parent) ## Value which is true when the sensor is touching something, false otherwise self.touched_somthing = False - def GenerateBinary(bytes, ix_ref): - pass - - def ProcessBinary(bytes): - pass \ No newline at end of file + def ProcessBinary(bytes): + """! Function to extract the touch state received in a binary message + """ + pass \ No newline at end of file