Removing unnecessary comments
This commit is contained in:
parent
8cc6f132fc
commit
c82f9ffc9f
|
@ -14,7 +14,7 @@
|
|||
FAckermannController::~FAckermannController() {}
|
||||
|
||||
// =============================================================================
|
||||
// -- FAckermannController --------------------------------------------------------------
|
||||
// -- FAckermannController -----------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
FAckermannControllerSettings FAckermannController::GetSettings() const {
|
||||
|
@ -59,25 +59,18 @@ void FAckermannController::Reset() {
|
|||
// Reset control parameters
|
||||
Steer = 0.0f;
|
||||
|
||||
//SpeedControlActivation = 0;
|
||||
|
||||
SpeedControlAccelDelta = 0.0f;
|
||||
SpeedControlAccelTarget = 0.0f;
|
||||
|
||||
AccelControlPedalDelta = 0.0f;
|
||||
AccelControlPedalTarget = 0.0f;
|
||||
|
||||
//ThrottleLowerBorder = 0.0f;
|
||||
//BrakeUpperBorder = 0.0f;
|
||||
|
||||
// Reset vehicle state
|
||||
VehicleSpeed = 0.0f;
|
||||
VehicleAcceleration = 0.0f;
|
||||
//VehiclePitch = 0.0f;
|
||||
|
||||
LastVehicleSpeed = 0.0f;
|
||||
LastVehicleAcceleration = 0.0f;
|
||||
//LastVehiclePitch = 0.0f;
|
||||
}
|
||||
|
||||
void FAckermannController::RunLoop(FVehicleControl& Control) {
|
||||
|
@ -172,36 +165,20 @@ void FAckermannController::RunControlReverse() {
|
|||
|
||||
|
||||
void FAckermannController::RunControlSpeed() {
|
||||
SpeedController.SetTargetPoint(TargetSpeed);
|
||||
SpeedControlAccelDelta = SpeedController.Run(VehicleSpeed, DeltaTime);
|
||||
|
||||
// TODO(joel): Minimum acceleration 1.0f
|
||||
//if (FMath::Abs(TargetAcceleration) < 1.0f) {
|
||||
// SpeedControlActivation = (SpeedControlActivation < 5) ? SpeedControlActivation + 1 : SpeedControlActivation;
|
||||
//} else {
|
||||
// SpeedControlActivation = (SpeedControlActivation > 0) ? SpeedControlActivation - 1 : SpeedControlActivation;
|
||||
//}
|
||||
|
||||
//if (SpeedControlActivation >= 5) {
|
||||
//SpeedController.SetTargetPoint(FMath::Abs(TargetSpeed));
|
||||
//SpeedControlAccelDelta = SpeedController.Run(FMath::Abs(VehicleSpeed), DeltaTime);
|
||||
SpeedController.SetTargetPoint(TargetSpeed);
|
||||
SpeedControlAccelDelta = SpeedController.Run(VehicleSpeed, DeltaTime);
|
||||
|
||||
// Clipping borders
|
||||
float ClippingLowerBorder = -FMath::Abs(TargetAcceleration);
|
||||
float ClippingUpperBorder = FMath::Abs(TargetAcceleration);
|
||||
if (FMath::Abs(TargetAcceleration) < 0.0001f) {
|
||||
// Per definition of AckermannDrive: if zero, then use max value
|
||||
ClippingLowerBorder = -MaxDecel;
|
||||
ClippingUpperBorder = MaxAccel;
|
||||
}
|
||||
SpeedControlAccelTarget += SpeedControlAccelDelta;
|
||||
SpeedControlAccelTarget = FMath::Clamp(SpeedControlAccelTarget,
|
||||
ClippingLowerBorder, ClippingUpperBorder);
|
||||
|
||||
//} else {
|
||||
// SpeedControlAccelDelta = 0.0f;
|
||||
// SpeedControlAccelTarget = TargetAcceleration;
|
||||
//}
|
||||
// Clipping borders
|
||||
float ClippingLowerBorder = -FMath::Abs(TargetAcceleration);
|
||||
float ClippingUpperBorder = FMath::Abs(TargetAcceleration);
|
||||
if (FMath::Abs(TargetAcceleration) < 0.0001f) {
|
||||
// Per definition of AckermannDrive: if zero, then use max value
|
||||
ClippingLowerBorder = -MaxDecel;
|
||||
ClippingUpperBorder = MaxAccel;
|
||||
}
|
||||
SpeedControlAccelTarget += SpeedControlAccelDelta;
|
||||
SpeedControlAccelTarget = FMath::Clamp(SpeedControlAccelTarget,
|
||||
ClippingLowerBorder, ClippingUpperBorder);
|
||||
}
|
||||
|
||||
void FAckermannController::RunControlAcceleration() {
|
||||
|
@ -210,86 +187,44 @@ void FAckermannController::RunControlAcceleration() {
|
|||
|
||||
// Clipping borders
|
||||
AccelControlPedalTarget += AccelControlPedalDelta;
|
||||
//AccelControlPedalTarget = FMath::Clamp(AccelControlPedalTarget, -MaxPedal, MaxPedal);
|
||||
AccelControlPedalTarget = FMath::Clamp(AccelControlPedalTarget, -1.0f, 1.0f);
|
||||
|
||||
}
|
||||
|
||||
void FAckermannController::UpdateVehicleControlCommand() {
|
||||
|
||||
if (AccelControlPedalTarget < 0.0f) {
|
||||
if (bReverse) {
|
||||
Throttle = FMath::Abs(AccelControlPedalTarget);
|
||||
Brake = 0.0f;
|
||||
} else {
|
||||
Throttle = 0.0f;
|
||||
Brake = FMath::Abs(AccelControlPedalTarget);
|
||||
}
|
||||
if (AccelControlPedalTarget < 0.0f) {
|
||||
if (bReverse) {
|
||||
Throttle = FMath::Abs(AccelControlPedalTarget);
|
||||
Brake = 0.0f;
|
||||
} else {
|
||||
if (bReverse) {
|
||||
Throttle = 0.0f;
|
||||
Brake = FMath::Abs(AccelControlPedalTarget);
|
||||
} else {
|
||||
Throttle = FMath::Abs(AccelControlPedalTarget);
|
||||
Brake = 0.0f;
|
||||
}
|
||||
Throttle = 0.0f;
|
||||
Brake = FMath::Abs(AccelControlPedalTarget);
|
||||
}
|
||||
|
||||
// ThrottleLowerBorder = GetVehicleDrivingImpedanceAcceleration();
|
||||
// BrakeUpperBorder = ThrottleLowerBorder + GetVehicleLayOffEngineAcceleration();
|
||||
|
||||
// if (AccelControlPedalTarget > ThrottleLowerBorder) {
|
||||
// // Accelerating
|
||||
// Throttle = (AccelControlPedalTarget - ThrottleLowerBorder) / MaxPedal;
|
||||
// Brake = 0.0f;
|
||||
|
||||
// } else if (AccelControlPedalTarget > BrakeUpperBorder) {
|
||||
// // Coasting
|
||||
// Throttle = 0.0f;
|
||||
// Brake = 0.0f;
|
||||
// } else {
|
||||
// // Braking
|
||||
// Throttle = 0.0f;
|
||||
// Brake = (BrakeUpperBorder - AccelControlPedalTarget) / MaxPedal;
|
||||
// }
|
||||
} else {
|
||||
if (bReverse) {
|
||||
Throttle = 0.0f;
|
||||
Brake = FMath::Abs(AccelControlPedalTarget);
|
||||
} else {
|
||||
Throttle = FMath::Abs(AccelControlPedalTarget);
|
||||
Brake = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// float FAckermannController::GetVehicleLayOffEngineAcceleration() {
|
||||
// float EngineBrakeForce = 500.0f; // [N]
|
||||
// return -EngineBrakeForce / VehicleMass;
|
||||
// }
|
||||
|
||||
// float FAckermannController::GetVehicleDrivingImpedanceAcceleration() {
|
||||
// float RollingResistanceForce = 0.01 * 9.81f * VehicleMass;
|
||||
// float AirDensity = 1.25f;
|
||||
// float AerodynamicDragForce = 0.5f * AirDensity * VehicleDragCoefficient * VehicleDragArea * (VehicleSpeed * VehicleSpeed);
|
||||
// //float SlopeForce = 9.81f * VehicleMass * FMath::Sin(VehiclePitch);
|
||||
// float SlopeForce = 0.0f;
|
||||
|
||||
// return -(RollingResistanceForce + AerodynamicDragForce + SlopeForce) / VehicleMass;
|
||||
// }
|
||||
|
||||
void FAckermannController::UpdateVehicleState(const ACarlaWheeledVehicle* Vehicle) {
|
||||
TRACE_CPUPROFILER_EVENT_SCOPE_STR(__FUNCTION__);
|
||||
|
||||
LastVehicleSpeed = VehicleSpeed;
|
||||
LastVehicleAcceleration = VehicleAcceleration;
|
||||
//LastVehiclePitch = VehiclePitch;
|
||||
|
||||
|
||||
// Update simulation state
|
||||
DeltaTime = Vehicle->GetWorld()->GetDeltaSeconds();
|
||||
|
||||
// Update Vehicle state
|
||||
//VehicleSpeed = FMath::RoundToFloat((Vehicle->GetVehicleForwardSpeed() / 100.0f) * 10.0f) / 10.0f; // From cm/s to m/s
|
||||
VehicleSpeed = Vehicle->GetVehicleForwardSpeed() / 100.0f; // From cm/s to m/s
|
||||
//VehicleSpeed = (4.0f*LastVehicleSpeed + CurrentSpeed) / 5.0f;
|
||||
|
||||
float CurrentAcceleration = (VehicleSpeed - LastVehicleSpeed) / DeltaTime;
|
||||
//CurrentAcceleration = FMath::RoundToFloat(CurrentAcceleration * 10.0f) / 10.0f;
|
||||
VehicleAcceleration = (4.0f*LastVehicleAcceleration + CurrentAcceleration) / 5.0f;
|
||||
//VehiclePitch = FMath::DegreesToRadians(
|
||||
// Vehicle->GetVehicleTransform().GetRotation().Rotator().Pitch
|
||||
//);
|
||||
}
|
||||
|
||||
void FAckermannController::UpdateVehiclePhysics(const ACarlaWheeledVehicle* Vehicle) {
|
||||
|
@ -298,8 +233,5 @@ void FAckermannController::UpdateVehiclePhysics(const ACarlaWheeledVehicle* Vehi
|
|||
check(Vehicle4W != nullptr);
|
||||
|
||||
// Update vehicle physics
|
||||
//VehicleMass = Vehicle4W->Mass;
|
||||
//VehicleDragArea = Vehicle4W->DragArea / (100.0f * 100.0f); // From cm2 to m2
|
||||
//VehicleDragCoefficient = Vehicle4W->DragCoefficient;
|
||||
VehicleMaxSteering = FMath::DegreesToRadians(Vehicle->GetMaximumSteerAngle());
|
||||
}
|
|
@ -110,9 +110,6 @@ private:
|
|||
void RunControlAcceleration();
|
||||
void UpdateVehicleControlCommand();
|
||||
|
||||
//float GetVehicleDrivingImpedanceAcceleration();
|
||||
//float GetVehicleLayOffEngineAcceleration();
|
||||
|
||||
private:
|
||||
|
||||
PID SpeedController = PID(0.15f, 0.0f, 0.25f);
|
||||
|
@ -130,8 +127,6 @@ private:
|
|||
float MaxAccel = 3.0f; // [m/s2]
|
||||
float MaxDecel = 8.0f; // [m/s2]
|
||||
|
||||
//float MaxPedal = 3.0f; // min(MaxAccel, MaxDecel)
|
||||
|
||||
// Control parameters
|
||||
float Steer = 0.0f;
|
||||
float Throttle = 0.0f;
|
||||
|
@ -149,16 +144,11 @@ private:
|
|||
float DeltaTime = 0.0f; // [s]
|
||||
|
||||
// Vehicle state
|
||||
//float VehicleMass = 0.0f; // [Kg]
|
||||
float VehicleMaxSteering = 0.0f; // [rad]
|
||||
//float VehicleDragArea = 0.0f; // [m2]
|
||||
//float VehicleDragCoefficient = 0.0f; // [?]
|
||||
|
||||
float VehicleSpeed = 0.0f; // [m/s]
|
||||
float VehicleAcceleration = 0.0f; // [m/s2]
|
||||
//float VehiclePitch = 0.0f; // [rad]
|
||||
|
||||
float LastVehicleSpeed = 0.0f; // [m/s]
|
||||
float LastVehicleAcceleration = 0.0f; // [m/s2]
|
||||
//float LastVehiclePitch = 0.0f; // [rad]
|
||||
};
|
Loading…
Reference in New Issue