Skip to content

Commit

Permalink
fixed wheel bumps limits inverted
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJerez committed Jan 30, 2025
1 parent c22be29 commit d9b092a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 34 deletions.
24 changes: 12 additions & 12 deletions newton-4.00/applications/ndSandbox/demos/ndBasicVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class ndVehicleDectriptorJeep : public ndVehicleDectriptor
m_frontTire.m_springK = 800.0f;
m_frontTire.m_damperC = 50.0f;
m_frontTire.m_regularizer = 0.3f;
m_frontTire.m_upperStop = -0.05f;
m_frontTire.m_lowerStop = 0.4f;
m_frontTire.m_lowerStop = -0.05f;
m_frontTire.m_upperStop = 0.4f;
m_frontTire.m_brakeTorque = 1500.0f;
m_frontTire.m_handBrakeTorque = 0.0f;

Expand All @@ -97,8 +97,8 @@ class ndVehicleDectriptorJeep : public ndVehicleDectriptor
m_rearTire.m_springK = 800.0f;
m_rearTire.m_damperC = 50.0f;
m_rearTire.m_regularizer = 0.3f;
m_rearTire.m_upperStop = -0.05f;
m_rearTire.m_lowerStop = 0.4f;
m_rearTire.m_lowerStop = -0.05f;
m_rearTire.m_upperStop = 0.4f;
m_rearTire.m_brakeTorque = 3000.0f;
m_rearTire.m_handBrakeTorque = 100000.0f;
m_torsionBarType = m_fourWheelAxle;
Expand Down Expand Up @@ -137,8 +137,8 @@ class ndVehicleDectriptorMonsterTruck0: public ndVehicleDectriptor
m_frontTire.m_springK = 500.0f;
m_frontTire.m_damperC = 50.0f;
m_frontTire.m_regularizer = 0.2f;
m_frontTire.m_upperStop = -0.05f;
m_frontTire.m_lowerStop = 0.4f;
m_frontTire.m_lowerStop = -0.05f;
m_frontTire.m_upperStop = 0.4f;
m_frontTire.m_brakeTorque = 1000.0f;
m_frontTire.m_handBrakeTorque = 0.0f;

Expand All @@ -148,8 +148,8 @@ class ndVehicleDectriptorMonsterTruck0: public ndVehicleDectriptor
m_rearTire.m_springK = 500.0f;
m_rearTire.m_damperC = 50.0f;
m_rearTire.m_regularizer = 0.2f;
m_rearTire.m_upperStop = -0.05f;
m_rearTire.m_lowerStop = 0.4f;
m_rearTire.m_lowerStop = -0.05f;
m_rearTire.m_upperStop = 0.4f;
m_rearTire.m_brakeTorque = 5000.0f;
m_rearTire.m_handBrakeTorque = 1000000.0f;
m_torsionBarType = m_fourWheelAxle;
Expand Down Expand Up @@ -196,8 +196,8 @@ class ndVehicleDectriptorMonsterTruck1 : public ndVehicleDectriptor
m_frontTire.m_springK = 500.0f;
m_frontTire.m_damperC = 50.0f;
m_frontTire.m_regularizer = 0.2f;
m_frontTire.m_upperStop = -0.05f;
m_frontTire.m_lowerStop = 0.4f;
m_frontTire.m_lowerStop = -0.05f;
m_frontTire.m_upperStop = 0.4f;
m_frontTire.m_brakeTorque = 10000.0f;
m_frontTire.m_handBrakeTorque = 0.0f;

Expand All @@ -207,8 +207,8 @@ class ndVehicleDectriptorMonsterTruck1 : public ndVehicleDectriptor
m_rearTire.m_springK = 500.0f;
m_rearTire.m_damperC = 50.0f;
m_rearTire.m_regularizer = 0.2f;
m_rearTire.m_upperStop = -0.05f;
m_rearTire.m_lowerStop = 0.4f;
m_rearTire.m_lowerStop = -0.05f;
m_rearTire.m_upperStop = 0.4f;
m_rearTire.m_brakeTorque = 10000.0f;
m_rearTire.m_handBrakeTorque = 50000.0f;
m_torsionBarType = m_fourWheelAxle;
Expand Down
24 changes: 12 additions & 12 deletions newton-4.00/applications/ndSandbox/demos/ndHeavyVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class ndVehicleDectriptorLav25: public ndVehicleDectriptor
m_frontTire.m_springK = 500.0f;
m_frontTire.m_damperC = 50.0f;
m_frontTire.m_regularizer = 0.2f;
m_frontTire.m_upperStop = -0.05f;
m_frontTire.m_lowerStop = 0.4f;
m_frontTire.m_lowerStop = -0.05f;
m_frontTire.m_upperStop = 0.4f;
m_frontTire.m_verticalOffset = -0.1f;
m_frontTire.m_brakeTorque = 1000.0f;
m_frontTire.m_laterialStiffness = 20.0f * DEMO_GRAVITY;
Expand All @@ -67,8 +67,8 @@ class ndVehicleDectriptorLav25: public ndVehicleDectriptor
m_rearTire.m_springK = 500.0f;
m_rearTire.m_damperC = 50.0f;
m_rearTire.m_regularizer = 0.2f;
m_rearTire.m_upperStop = -0.05f;
m_rearTire.m_lowerStop = 0.4f;
m_rearTire.m_lowerStop = -0.05f;
m_rearTire.m_upperStop = 0.4f;
m_rearTire.m_verticalOffset = -0.1f;
m_rearTire.m_brakeTorque = 2500.0f;
m_rearTire.m_laterialStiffness = 20.0f * DEMO_GRAVITY;
Expand Down Expand Up @@ -116,8 +116,8 @@ class ndVehicleDectriptorTractor : public ndVehicleDectriptor
m_frontTire.m_springK = 1000.0f;
m_frontTire.m_damperC = 25.0f;
m_frontTire.m_regularizer = 0.01f;
m_frontTire.m_upperStop = -0.05f;
m_frontTire.m_lowerStop = 0.4f;
m_frontTire.m_lowerStop = -0.05f;
m_frontTire.m_upperStop = 0.4f;
m_frontTire.m_verticalOffset = -0.1f;
m_frontTire.m_brakeTorque = 1000.0f;
m_frontTire.m_laterialStiffness = 20.0f * DEMO_GRAVITY;
Expand All @@ -128,8 +128,8 @@ class ndVehicleDectriptorTractor : public ndVehicleDectriptor
m_rearTire.m_springK = 1000.0f;
m_rearTire.m_damperC = 25.0f;
m_rearTire.m_regularizer = 0.01f;
m_rearTire.m_upperStop = -0.05f;
m_rearTire.m_lowerStop = 0.4f;
m_rearTire.m_lowerStop = -0.05f;
m_rearTire.m_upperStop = 0.4f;
m_rearTire.m_verticalOffset = -0.1f;
m_rearTire.m_brakeTorque = 2500.0f;
m_rearTire.m_laterialStiffness = 20.0f * DEMO_GRAVITY;
Expand Down Expand Up @@ -174,8 +174,8 @@ class ndVehicleDectriptorBigRig : public ndVehicleDectriptor
m_frontTire.m_springK = 500.0f;
m_frontTire.m_damperC = 50.0f;
m_frontTire.m_regularizer = 0.2f;
m_frontTire.m_upperStop = -0.05f;
m_frontTire.m_lowerStop = 0.4f;
m_frontTire.m_lowerStop = -0.05f;
m_frontTire.m_upperStop = 0.4f;
m_frontTire.m_brakeTorque = 1000.0f;
m_frontTire.m_laterialStiffness = 20.0f * DEMO_GRAVITY;
m_frontTire.m_longitudinalStiffness = 10.0f * DEMO_GRAVITY;
Expand All @@ -186,8 +186,8 @@ class ndVehicleDectriptorBigRig : public ndVehicleDectriptor
m_rearTire.m_springK = 500.0f;
m_rearTire.m_damperC = 50.0f;
m_rearTire.m_regularizer = 0.2f;
m_rearTire.m_upperStop = -0.05f;
m_rearTire.m_lowerStop = 0.4f;
m_rearTire.m_lowerStop = -0.05f;
m_rearTire.m_upperStop = 0.4f;
m_rearTire.m_brakeTorque = 2500.0f;
m_rearTire.m_laterialStiffness = 20.0f * DEMO_GRAVITY;
m_rearTire.m_longitudinalStiffness = 10.0f * DEMO_GRAVITY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ ndVehicleDectriptor::ndVehicleDectriptor(const char* const fileName)
m_frontTire.m_springK = 1000.0f;
m_frontTire.m_damperC = 20.0f;
m_frontTire.m_regularizer = 0.1f;
m_frontTire.m_upperStop = -0.05f;
m_frontTire.m_lowerStop = 0.2f;
m_frontTire.m_lowerStop = -0.05f;
m_frontTire.m_upperStop = 0.2f;
m_frontTire.m_verticalOffset = 0.0f;
m_frontTire.m_brakeTorque = 1500.0f;
m_frontTire.m_handBrakeTorque = 1500.0f;
Expand All @@ -177,8 +177,8 @@ ndVehicleDectriptor::ndVehicleDectriptor(const char* const fileName)
m_rearTire.m_springK = 1000.0f;
m_rearTire.m_damperC = 20.0f;
m_rearTire.m_regularizer = 0.1f;
m_rearTire.m_upperStop = -0.05f;
m_rearTire.m_lowerStop = 0.2f;
m_rearTire.m_lowerStop = -0.05f;
m_rearTire.m_upperStop = 0.2f;
m_rearTire.m_steeringAngle = 0.0f;
m_rearTire.m_verticalOffset = 0.0f;
m_rearTire.m_brakeTorque = 1500.0f;
Expand Down
11 changes: 7 additions & 4 deletions newton-4.00/sdk/dNewton/dJoints/ndJointWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void ndJointWheel::UpdateTireSteeringAngleMatrix()

CalculateGlobalMatrix(tireMatrix, chassisMatrix);
const ndVector localRelPosit(chassisMatrix.UntransformVector(tireMatrix.m_posit));
const ndFloat32 distance = ndClamp(localRelPosit.m_y, m_info.m_upperStop, m_info.m_lowerStop);
const ndFloat32 distance = ndClamp(localRelPosit.m_y, m_info.m_lowerStop, m_info.m_upperStop);

const ndFloat32 spinAngle = -CalculateAngle(tireMatrix.m_up, chassisMatrix.m_up, chassisMatrix.m_front);
ndMatrix newTireMatrix(ndPitchMatrix(spinAngle) * chassisMatrix);
Expand All @@ -97,7 +97,8 @@ ndMatrix ndJointWheel::CalculateBaseFrame() const
ndMatrix ndJointWheel::CalculateUpperBumperMatrix() const
{
ndMatrix matrix(m_localMatrix1 * m_body1->GetMatrix());
matrix.m_posit += matrix.m_up.Scale(m_info.m_lowerStop);
//matrix.m_posit += matrix.m_up.Scale(m_info.m_lowerStop);
matrix.m_posit += matrix.m_up.Scale(m_info.m_upperStop);
return matrix;
}

Expand Down Expand Up @@ -161,14 +162,16 @@ void ndJointWheel::JacobianDerivative(ndConstraintDescritor& desc)

// add suspension limits alone the vertical axis
const ndFloat32 x = m_posit + m_speed * desc.m_timestep;
if (x < m_info.m_upperStop)
//if (x < m_info.m_upperStop)
if (x >= m_info.m_upperStop)
{
AddLinearRowJacobian(desc, matrix0.m_posit, matrix1.m_posit, matrix1.m_up);
const ndFloat32 stopAccel = GetMotorZeroAcceleration(desc);
SetMotorAcceleration(desc, stopAccel);
SetLowerFriction(desc, ndFloat32(0.0f));
}
else if (x > m_info.m_lowerStop)
//else if (x > m_info.m_lowerStop)
else if (x <= m_info.m_lowerStop)
{
AddLinearRowJacobian(desc, matrix0.m_posit, matrix1.m_posit, matrix1.m_up);
const ndFloat32 stopAccel = GetMotorZeroAcceleration(desc);
Expand Down
4 changes: 2 additions & 2 deletions newton-4.00/sdk/dNewton/dJoints/ndJointWheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class ndWheelDescriptor
:m_radios(ndFloat32(0.5f))
,m_springK(ndFloat32(1.0f))
,m_damperC(ndFloat32(0.0f))
,m_upperStop(ndFloat32(-0.1f))
,m_lowerStop(ndFloat32(0.2f))
,m_upperStop(ndFloat32(0.2f))
,m_lowerStop(ndFloat32(-0.1f))
,m_regularizer(ndFloat32(0.1f))
,m_brakeTorque(ndFloat32(0.0f))
,m_steeringAngle(ndFloat32(0.0f))
Expand Down

0 comments on commit d9b092a

Please sign in to comment.