Create placeholder motors when they are not found
This commit is contained in:
parent
87241a0279
commit
5759412f70
@ -14,7 +14,7 @@ namespace RoboidControl {
|
|||||||
/// <param name="parent">The parent thing</param>
|
/// <param name="parent">The parent thing</param>
|
||||||
public DifferentialDrive(Thing parent = default) : base(parent) {
|
public DifferentialDrive(Thing parent = default) : base(parent) {
|
||||||
this.type = Type.DifferentialDrive;
|
this.type = Type.DifferentialDrive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Configures the dimensions of the drive
|
/// @brief Configures the dimensions of the drive
|
||||||
/// @param wheelDiameter The diameter of the wheels in meters
|
/// @param wheelDiameter The diameter of the wheels in meters
|
||||||
@ -49,7 +49,7 @@ namespace RoboidControl {
|
|||||||
// this.leftWheel.position = new Spherical(distance, Direction.left);
|
// this.leftWheel.position = new Spherical(distance, Direction.left);
|
||||||
|
|
||||||
this.rightWheel = rightWheel;
|
this.rightWheel = rightWheel;
|
||||||
this.rightWheel.parent= this;
|
this.rightWheel.parent = this;
|
||||||
// if (this.rightWheel != null)
|
// if (this.rightWheel != null)
|
||||||
// this.rightWheel.position = new Spherical(distance, Direction.right);
|
// this.rightWheel.position = new Spherical(distance, Direction.right);
|
||||||
|
|
||||||
@ -139,8 +139,12 @@ namespace RoboidControl {
|
|||||||
byte ix = 0;
|
byte ix = 0;
|
||||||
byte leftWheelId = data[ix++];
|
byte leftWheelId = data[ix++];
|
||||||
this.leftWheel = this.owner.Get(leftWheelId) as Motor;
|
this.leftWheel = this.owner.Get(leftWheelId) as Motor;
|
||||||
|
this.leftWheel ??= new Motor(this) { id = leftWheelId };
|
||||||
|
|
||||||
byte rightWheelId = data[ix++];
|
byte rightWheelId = data[ix++];
|
||||||
this.rightWheel = this.owner.Get(rightWheelId) as Motor;
|
this.rightWheel = this.owner.Get(rightWheelId) as Motor;
|
||||||
|
this.rightWheel ??= new Motor(this) { id = rightWheelId };
|
||||||
|
|
||||||
this._wheelRadius = LowLevelMessages.ReceiveFloat16(data, ref ix);
|
this._wheelRadius = LowLevelMessages.ReceiveFloat16(data, ref ix);
|
||||||
//this._wheelSeparation = LowLevelMessages.ReceiveFloat16(data, ref ix);
|
//this._wheelSeparation = LowLevelMessages.ReceiveFloat16(data, ref ix);
|
||||||
this.updateQueue.Enqueue(new CoreEvent(BinaryMsg.Id));
|
this.updateQueue.Enqueue(new CoreEvent(BinaryMsg.Id));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user