Fix non-encoder BB2B
This commit is contained in:
parent
8c7e7e03f7
commit
ae1e43a332
@ -11,6 +11,7 @@ namespace RoboidControl {
|
|||||||
|
|
||||||
public BB2B(Participant owner) : base(owner) {
|
public BB2B(Participant owner) : base(owner) {
|
||||||
this.name = "BB2B";
|
this.name = "BB2B";
|
||||||
|
this.SetMotors(new Motor(this), new Motor(this));
|
||||||
this.SetDriveDimensions(0.064f, 0.128f);
|
this.SetDriveDimensions(0.064f, 0.128f);
|
||||||
|
|
||||||
// Is has a touch sensor at the front left of the roboid
|
// Is has a touch sensor at the front left of the roboid
|
||||||
|
@ -52,6 +52,14 @@ namespace RoboidControl.Unity {
|
|||||||
if (coreDrive.wheelRadius <= 0) // || coreDrive.wheelSeparation <= 0)
|
if (coreDrive.wheelRadius <= 0) // || coreDrive.wheelSeparation <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Destroy any (generic) thing with the same id
|
||||||
|
if (leftWheel == null) {
|
||||||
|
Thing[] things = FindObjectsOfType<Thing>();
|
||||||
|
foreach (Thing thing in things) {
|
||||||
|
if (thing.core.id == coreDrive.leftWheel.id)
|
||||||
|
Destroy(thing.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (leftWheel == null && coreDrive.leftWheel != null)
|
if (leftWheel == null && coreDrive.leftWheel != null)
|
||||||
leftWheel = Wheel.Create(this.transform, coreDrive.leftWheel.id);
|
leftWheel = Wheel.Create(this.transform, coreDrive.leftWheel.id);
|
||||||
if (leftWheel != null) {
|
if (leftWheel != null) {
|
||||||
@ -61,6 +69,14 @@ namespace RoboidControl.Unity {
|
|||||||
// leftWheelCollider.center = new Vector3(-coreDrive.wheelSeparation / 2, 0, 0);
|
// leftWheelCollider.center = new Vector3(-coreDrive.wheelSeparation / 2, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destroy any (generic) thing with the same id
|
||||||
|
if (rightWheel == null) {
|
||||||
|
Thing[] things = FindObjectsOfType<Thing>();
|
||||||
|
foreach (Thing thing in things) {
|
||||||
|
if (thing.core.id == coreDrive.rightWheel.id)
|
||||||
|
Destroy(thing.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (rightWheel == null && coreDrive.rightWheel != null)
|
if (rightWheel == null && coreDrive.rightWheel != null)
|
||||||
rightWheel = Wheel.Create(this.transform, coreDrive.rightWheel.id);
|
rightWheel = Wheel.Create(this.transform, coreDrive.rightWheel.id);
|
||||||
if (rightWheel != null) {
|
if (rightWheel != null) {
|
||||||
|
@ -23,14 +23,6 @@ namespace RoboidControl.Unity {
|
|||||||
GameObject gameObj = new(core.name);
|
GameObject gameObj = new(core.name);
|
||||||
Wheel component = gameObj.AddComponent<Wheel>();
|
Wheel component = gameObj.AddComponent<Wheel>();
|
||||||
component.Init(core);
|
component.Init(core);
|
||||||
// component.wheelCollider = gameObj.AddComponent<WheelCollider>();
|
|
||||||
// component.wheelCollider.mass = 0.1f;
|
|
||||||
// component.wheelCollider.suspensionDistance = 0.01f;
|
|
||||||
// component.wheelCollider.suspensionSpring = new JointSpring {
|
|
||||||
// spring = 100f, // Very high spring value to make it rigid
|
|
||||||
// damper = 10f, // Low damping (could be adjusted for slight 'bounciness')
|
|
||||||
// targetPosition = 0.5f // Neutral position (middle of the suspension travel)
|
|
||||||
// };
|
|
||||||
Debug.Log("Create " + core.name);
|
Debug.Log("Create " + core.name);
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
@ -61,14 +53,6 @@ namespace RoboidControl.Unity {
|
|||||||
SphereCollider collider = gameObj.AddComponent<SphereCollider>();
|
SphereCollider collider = gameObj.AddComponent<SphereCollider>();
|
||||||
collider.radius = 0.00001f;
|
collider.radius = 0.00001f;
|
||||||
collider.material = slidingWheel;
|
collider.material = slidingWheel;
|
||||||
// component.wheelCollider = gameObj.AddComponent<WheelCollider>();
|
|
||||||
// component.wheelCollider.mass = 0.1f;
|
|
||||||
// component.wheelCollider.suspensionDistance = 0.01f;
|
|
||||||
// component.wheelCollider.suspensionSpring = new JointSpring {
|
|
||||||
// spring = 100f, // Very high spring value to make it rigid
|
|
||||||
// damper = 10f, // Low damping (could be adjusted for slight 'bounciness')
|
|
||||||
// targetPosition = 0.5f // Neutral position (middle of the suspension travel)
|
|
||||||
// };
|
|
||||||
Debug.Log("Create placeholder Wheel ");
|
Debug.Log("Create placeholder Wheel ");
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user