-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modified AWSIM vehicle's turning behavior #176
base: main
Are you sure you want to change the base?
Changes from 1 commit
1d07172
428b21c
a9e499a
8dcbfa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,7 +208,9 @@ public class Axle | |
|
||
private float sleepTimer = 0.0f; ///Count the time until CanSleep is switched to true | ||
|
||
|
||
// Vehicle dynamics parameters used for calculating of front wheel angles. | ||
private float wheelBase = 2.787877f; | ||
private float tread = 1.8199022f; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wheelbase and tread could be calculated automatically from the positions of the front and rear wheels, I believe. Therefore, it is preferable not to provide these variables. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified to have wheelbase and tread calculated from the coordinates of each wheel. |
||
|
||
// Cache components. | ||
Wheel[] wheels; | ||
|
@@ -335,7 +337,7 @@ bool IsEachWheelGrounded() | |
// Is less than sleepVelocityThreshold ? | ||
bool IsCanSleepVelocity() | ||
{ | ||
if (Mathf.Abs(Velocity.z) < sleepVelocityThreshold) | ||
if (Mathf.Abs(LocalVelocity.z) < sleepVelocityThreshold) | ||
return true; | ||
else | ||
return false; | ||
|
@@ -424,8 +426,31 @@ void UpdateWheelsForce(float acceleration) | |
var perWheelAcceleration = acceleration / wheels.Length; | ||
|
||
// Update the acceleration output by each wheel. | ||
foreach (var wheel in wheels) | ||
wheel.UpdateWheelForce(perWheelAcceleration); | ||
var dif1 = Mathf.Sin(Mathf.Asin(1 / Mathf.Sqrt(Mathf.Pow((1 / Mathf.Tan(Mathf.Abs(SteerAngle) * Mathf.Deg2Rad) + tread / wheelBase), 2) + 1))) / Mathf.Sin(SteerAngle * Mathf.Deg2Rad); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to leave comments on the calculations and logic of dif1, dif2, dif3, etc. so that other developers can easily understand them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added some comments of dif1, dif2, dif3. |
||
var dif2 = (Mathf.Cos(Mathf.Asin(1 / Mathf.Sqrt(Mathf.Pow((1 / Mathf.Tan(Mathf.Abs(SteerAngle) * Mathf.Deg2Rad) + tread / wheelBase), 2) + 1))) + tread * Mathf.Sin(Mathf.Asin(1 / Mathf.Sqrt(Mathf.Pow((1 / Mathf.Tan(SteerAngle * Mathf.Deg2Rad) + tread / wheelBase), 2) + 1))) / wheelBase); | ||
var dif3 = Mathf.Cos(Mathf.Asin(1 / Mathf.Sqrt(Mathf.Pow((1 / Mathf.Tan(Mathf.Abs(SteerAngle) * Mathf.Deg2Rad) + tread / wheelBase), 2) + 1))); | ||
|
||
if (SteerAngle > 0.001) | ||
{ | ||
frontAxle.LeftWheel.UpdateWheelForce(perWheelAcceleration); | ||
frontAxle.RightWheel.UpdateWheelForce(perWheelAcceleration * dif1); | ||
rearAxle.LeftWheel.UpdateWheelForce(perWheelAcceleration * dif2); | ||
rearAxle.RightWheel.UpdateWheelForce(perWheelAcceleration * dif3); | ||
} | ||
|
||
else if (SteerAngle < -0.001) | ||
{ | ||
frontAxle.LeftWheel.UpdateWheelForce(perWheelAcceleration * dif1); | ||
frontAxle.RightWheel.UpdateWheelForce(perWheelAcceleration); | ||
rearAxle.LeftWheel.UpdateWheelForce(perWheelAcceleration * dif3); | ||
rearAxle.RightWheel.UpdateWheelForce(perWheelAcceleration * dif2); | ||
} | ||
|
||
else | ||
{ | ||
foreach (var wheel in wheels) | ||
wheel.UpdateWheelForce(perWheelAcceleration); | ||
} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should the Wheel class make changes? I think the Wheel class should just reflect the SteerAngle set from the Vehicle class, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this scene needs to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored the original value for
m_IndirectSpecularColor
.