From 5759412f70924ea5bc19bec7fbb332b852d10cc6 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 6 Jun 2025 09:13:38 +0200 Subject: [PATCH] Create placeholder motors when they are not found --- src/Things/DifferentialDrive.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Things/DifferentialDrive.cs b/src/Things/DifferentialDrive.cs index 78459ae..c973145 100644 --- a/src/Things/DifferentialDrive.cs +++ b/src/Things/DifferentialDrive.cs @@ -14,7 +14,7 @@ namespace RoboidControl { /// The parent thing public DifferentialDrive(Thing parent = default) : base(parent) { this.type = Type.DifferentialDrive; - } + } /// @brief Configures the dimensions of the drive /// @param wheelDiameter The diameter of the wheels in meters @@ -49,7 +49,7 @@ namespace RoboidControl { // this.leftWheel.position = new Spherical(distance, Direction.left); this.rightWheel = rightWheel; - this.rightWheel.parent= this; + this.rightWheel.parent = this; // if (this.rightWheel != null) // this.rightWheel.position = new Spherical(distance, Direction.right); @@ -139,8 +139,12 @@ namespace RoboidControl { byte ix = 0; byte leftWheelId = data[ix++]; this.leftWheel = this.owner.Get(leftWheelId) as Motor; + this.leftWheel ??= new Motor(this) { id = leftWheelId }; + byte rightWheelId = data[ix++]; this.rightWheel = this.owner.Get(rightWheelId) as Motor; + this.rightWheel ??= new Motor(this) { id = rightWheelId }; + this._wheelRadius = LowLevelMessages.ReceiveFloat16(data, ref ix); //this._wheelSeparation = LowLevelMessages.ReceiveFloat16(data, ref ix); this.updateQueue.Enqueue(new CoreEvent(BinaryMsg.Id));