Improve external motor control

This commit is contained in:
Pascal Serrarens 2025-06-06 09:38:07 +02:00
parent d5c301fa86
commit ac11382479
3 changed files with 5 additions and 5 deletions

View File

@ -125,7 +125,6 @@ namespace RoboidControl.Unity {
// Use smoothing to emulate motor inertia
rb.velocity = 0.9f * rb.velocity + 0.1f * forwardSpeed * transform.forward;
Debug.Log(rb.velocity);
rb.angularVelocity = 0.9f * rb.angularVelocity + 0.1f * turningSpeed * Vector3.up;
}
}

View File

@ -107,7 +107,7 @@ namespace RoboidControl {
/// The interval in milliseconds for publishing (broadcasting) data on the local network
/// </summary>
public ulong publishIntervalMS = 3000; // = 3 seconds
public ulong sendUpdateIntervalMS = 100; // for object updates
public ulong sendUpdateIntervalMS = 100; // = 0.1 seconds for object updates
//public byte[] buffer = new byte[1024];
@ -219,8 +219,8 @@ namespace RoboidControl {
// this.Send(participant, poseMsg);
// BinaryMsg binaryMsg = new(thing.owner.networkId, thing);
// this.Send(participant, binaryMsg);
participant.Send(new PoseMsg(thing.owner.networkId, thing));
participant.Send(new BinaryMsg(thing.owner.networkId, thing));
// participant.Send(new PoseMsg(thing.owner.networkId, thing));
// participant.Send(new BinaryMsg(thing.owner.networkId, thing));
}
this.nextSendUpdate = currentTimeMS + this.sendUpdateIntervalMS;
}

View File

@ -40,7 +40,8 @@ namespace RoboidControl {
return data;
}
public override void ProcessBinary(byte[] data) {
this.targetSpeed = (float)(sbyte)data[0] / 127;
this._targetSpeed = (float)(sbyte)data[0] / 127;
updateQueue.Enqueue(new CoreEvent(BinaryMsg.Id));
}
}