[Newton 2.0] Raycast vehicle suspension problems

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

[Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Mon Dec 22, 2008 10:16 am

Hi guys,

I'm using Newton 2.0 and followed the example code of the raycast car to create the raycast suspension. I'm having problems with the spring joint as the spring sinks (fully compresses) when going over different angles in the terrain. One instant the chassis is fully supported by the spring, the next the chassis is touching the ground as if the tyre radius was set to 0. Not sure what is causing this?. It also seems to have a very small (minute) bounce. The vertical load being returned changes between 0 and around 300 newtons instead of it being constant so not sure why that is? I've posted the code for it below. The vertical load doesn't get changed by the tyreModel so its exactly as the spring calculates it. Is there anything I've missed in the translation?


Code: Select all
void Wheel::submitConstraint( Ogre::Real timeStep, int threadIndex )
{
   //Get the position and orientation of the mount point on the chassis
   m_body0->getPositionOrientation(mountPosition, mountOrientation);

   mount_up = mountOrientation * Ogre::Vector3(Ogre::Vector3::UNIT_Y);

   //Do the ray cast
   calculateRayCast();

   //Get the velocity of the mount point
   Vector3 mountPointVelocity (m_body0->getVelocity());

   //The wheel is touching a body
   if (hitBodyFriction > 0.0f)
   {
      //TODO: need to calculate the velocity if there is contact with a dynamic physics object
      Vector3 hitBodyVelocity (0, 0, 0);

      //Calculate the relative velocity in comparison to the body the ray cast hit
      Vector3 relativeVelocity (mountPointVelocity - hitBodyVelocity);

      //Calculate the speed to damp the spring
      float speed = -relativeVelocity.dotProduct(mount_up);

      //Calculate the load from the tyre using a spring joint
      verticalLoad = -OgreNewt::Springs::calculateSpringDamperAcceleration(timeStep, springRate, radius, springDamping, speed);

      //Restrict the vertical load
      if (verticalLoad <= 0.0f)
      {
         //The tyre is not a body; therefore it cannot pull the chassis
         verticalLoad = 0.0f;
      }
      
      //The vertical load is normalized; needs to be scaled by the mass of the vehicle
      verticalLoad *= vehicleParent->mass;

      //Set the vertical load in the tyre model and normalize by the number of wheels
      tyreModel->setVerticalLoad(verticalLoad);
   }
   else
   {
      //The wheel isn't in contact with any body; hence there is no friction
      verticalLoad = 0.0f;

      //Set the vertical load in the tyre model
      tyreModel->setVerticalLoad(verticalLoad);
   }

/*   // Simplified steering angle
//   Quaternion simplifiedSteeringAngle;
   if (axleParent)
   {
      if(axleParent->steerable)
         simplifiedSteeringAngle.FromAngleAxis(Degree(steerAngle), Vector3::UNIT_Y);
   }
   else
   {
      simplifiedSteeringAngle.FromAngleAxis(Degree(0), Vector3::UNIT_Y);
   }
   
   //Set the velocities of the tyre and multiply by inverse rotation matrix, tyre model needs locally oriented velocities
   tyreModel->setTyreVelocities( (simplifiedSteeringAngle * mountPointOrientation_global.Inverse()) * -mountPointVelocity, angularVelocity);
*/   
   //Set the velocities of the tyre and multiply by inverse rotation matrix, tyre model needs locally oriented velocities
   tyreModel->setTyreVelocities(mountOrientation.Inverse() * -mountPointVelocity, angularVelocity);
   
   //Set the effective rolling radius from the distance of the mount point to the ground, tyre reduces radius the smaller the distance
   tyreModel->setTyreEffectiveRollingRadius(distance);

   //Update the tyre
   tyreModel->updateTyre();

   //Get the forces from the current update
   force = tyreModel->getForces();
   
   //Apply the force to the chassis
   chassisNode->addLocalForce(force, forcePosition);
   }
}
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Julio Jerez » Mon Dec 22, 2008 11:54 am

in thsio funtion
verticalLoad = -OgreNewt::Springs::calculateSpringDamperAcceleration(timeStep, springRate, radius, springDamping, speed);

I asume that springRate is the spring constat, but you are passing radius as the spring displacemnt don't you have to pass the distance from the mount point to the ray intercetion minus the radius of the tire?
this is oho I do it the demo
Code: Select all
         dFloat speed;

         // calculate the linear velocity of the tire at the ground contact
         dVector tireAxelPosit (chassisMatrix.TransformVector(tire.m_harpoint - m_localFrame.m_up.Scale (tire.m_posit)));
         dVector localAxelPosit (tireAxelPosit - chassisMatrix.m_posit);
         dVector tireAxelVeloc (globalVeloc + globalOmega * localAxelPosit);       

         // TO DO: need to calculate the velocity if the other body at the point
         // for now assume the ground is a static body
         dVector hitBodyVeloc (0, 0, 0, 0);

         // calculate the relative velocity
         dVector relVeloc (tireAxelVeloc - hitBodyVeloc);
         speed = -(relVeloc % chassisMatrix.m_up);

         // now calculate the tire load at the contact point
         tire.m_tireLoad = - NewtonCalculateSpringDamperAcceleration (timestep, tire.m_springConst, tire.m_suspensionLength - tire.m_posit, tire.m_springDamper, speed);


"tire.m_suspensionLength - tire.m_posit"
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Mon Dec 22, 2008 11:08 pm

I've included a link to a video of the problem with the raycast suspension in the PM. It's as if the spring suddenly goes soft and nothing is pushing the chassis up. Also the only time the vertical load is consistently above 0 is when i apply a force pushing down on the chassis. The rest of the time its alternating between 0 and 300 which suggests the suspension is bouncing. The radius of the wheel being parsed to the springDamping is the distance from the mount point to the intersection point. This raycast is just simulating the tyre as a kart has no suspension. What else could be causing it?
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Julio Jerez » Mon Dec 22, 2008 11:22 pm

video? where?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Mon Dec 22, 2008 11:24 pm

I sent it in a PM
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Fri Dec 26, 2008 10:57 pm

I've sent a PM to you Julio with a link to the physics test
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Julio Jerez » Fri Dec 26, 2008 11:30 pm

yes I know you have to allow me some time to finish something I am doing know. I wil be long just wnat more day and I will post next Beta.
Next I will spend time with you, I know you have being waiting for help for a long time.
you see me answering some question but those are eassy and I can respond without coding.
yours seems to be more complex problem, by I think it is solvable.

Anyway I will try to do my best to help you out.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Fri Dec 26, 2008 11:36 pm

Thanks very much Julio. That's fine and we appreciate it a lot. Just wanted to check you had received the PM.
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Julio Jerez » Fri Dec 26, 2008 11:54 pm

Julio Jerez wrote:I wil be long just wnat more day and I will post next Beta.

opps, that came out wrong, :oops: me and my broken english.
I meant It will not be long, just two more days until a post the next beta.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Fri Jan 02, 2009 6:08 am

Sent you a PM Julio
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Julio Jerez » Fri Jan 02, 2009 4:17 pm

Oh a light switch just turned on in my heard.
I was going to get ready to work on a feature which is actually a mangled funtionality in 1.53 and all versions of 2.0.
I beleive that I know with almost 90% of certanty that this is your problem.
I will try it tonight to see if it is what I suspect.
But anyway I still like to see your implementation.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Fri Jan 02, 2009 7:43 pm

Implementation sent.
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am

Re: [Newton 2.0] Raycast vehicle suspension problems

Postby Zach Griffin » Thu Jan 29, 2009 7:37 am

I've had a look again and checked the chassis joints and it definitely seems to be a problem with the spring. Have you had a chance to fix the spring bug yet?
Zach Griffin
 
Posts: 13
Joined: Tue Oct 04, 2005 7:52 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 18 guests

cron