Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(auto brake): reach deceleration rate target indicator unreliable,… #127

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void UpdateAutoBrake(float decelerationRate) {
else {
var targetDecelerationRate = GetTargetDecelerationRate();

var error = targetDecelerationRate - decelerationRate;
var error = decelerationRate - targetDecelerationRate;
_integral += error * Time.deltaTime;
var derivative = (error - _previousError) / Time.deltaTime;
brakeInput = Kp * error + Ki * _integral + Kd * derivative;
Expand Down Expand Up @@ -243,7 +243,7 @@ private float GetDecelerationRate() {
var velocity = _saccAirVehicle.CurrentVel;

var acceleration = (velocity - _lastVelocity) / Time.fixedDeltaTime;
var temp = Vector3.Project(acceleration, Vector3.forward);
var temp = _saccAirVehicle.transform.rotation * acceleration;

_lastVelocity = velocity;

Expand All @@ -264,10 +264,10 @@ private float GetTargetDecelerationRate() {
}

private bool IsReachDecelerationRateTarget(float decelerationRate) {
var targetDecelerationRate = GetTargetDecelerationRate() * 0.8f;

if (currentAutoBrakeMode == AutoBrakeMode.Max) return true;
return decelerationRate > targetDecelerationRate;

var targetDecelerationRate = GetTargetDecelerationRate() * 0.8f;
return decelerationRate < targetDecelerationRate;
}

public void Reset() {
Expand Down
Loading