Skip to content

Commit

Permalink
Added configs for instability
Browse files Browse the repository at this point in the history
  • Loading branch information
millennIumAMbiguity committed May 24, 2024
1 parent 19dd06e commit 66b2cab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ object EurekaConfig {
@JsonSchema(description = "How fast a ship will stop. 1 = fast stop, 0 = slow stop")
var linearStabilizeMaxAntiVelocity = 1.0

// Instability scaled with mass and squared speed
@JsonSchema(description = "Stronger stabilization with higher mass, less at higher speeds.")
var scaledInstability = 1000.0

// Unscaled linear instability cased by speed
@JsonSchema(description = "Less stabilization at higher speed.")
var unscaledInstability = 0.271828

@JsonSchema(description = "How fast a ship will stop and accelerate.")
var linearMassScaling = 0.0002

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ fun stabilize(

val speed = ship.poseVel.vel.length()

val multiplierA = 1000f; // 1 kilo
val multiplierB = 0.271828; // e / 10

stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant / max(1.0, speed * speed * multiplierA / ship.inertia.shipMass + speed * multiplierB))
stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant / max(1.0, speed * speed * EurekaConfig.SERVER.scaledInstability / ship.inertia.shipMass + speed * EurekaConfig.SERVER.unscaledInstability))
forces.applyInvariantTorque(stabilizationTorque)

if (linear) {
Expand Down

0 comments on commit 66b2cab

Please sign in to comment.