[Edited] Questions about vehicles

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

[Edited] Questions about vehicles

Postby Crashy » Mon Mar 11, 2013 9:20 am

I edited this topic not to create a new one about the same thing;)

Hi, I encountered crashes using the new vehicle controller, and after a lot of debug to see where is the source of the crash, it seems that it's around these lines:
Code: Select all
for (int i = 0; i < jointCount; i ++) {
      VehicleJoint* const constraint = jointArray[i];
      int first = constraint->m_start;
      int count = constraint->m_count;
      for (int j = 0; j < count; j ++) {
         const VehicleJoint::JacobianColum* const col = &jacobianColumnArray[j + first];
         dFloat val = col->m_force;
         constraint->m_jointFeebackForce[j] = val;
      }
      constraint->UpdateSolverForces (jacobianArray);
   }

in CustomVehicleController::CalculateReactionsForces.

When debugging, the constraint->m_count value is set to 8, but the m_jointFeedbackForce array is sized to 6 only. So after passing through this code, the memory is corrupted as it writes values to bad memory locations.

At this point of the execution, the m_contactCount value of my vehicle controller is == 4, this explains the value of 8 constraints, but is it normal to have 4 contacts joints?

Thanks.

/Edit: When increasing the since of the array to 8 instead of 6, it works like a charm.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: [Edited] Questions about vehicles

Postby Crashy » Thu Mar 14, 2013 1:13 pm

OK now I have setup-ed my vehicle and that it globally works fine, there is another issue. I use the vehicle controller to handle the landing gear of an aircraft, but as soon as I add some engine force - the aircraft engine, not the controller one - the wheels are rolling super fast, and there are some strange behaviors.

I've looked a little bit in the vehicle controller code and my conclusion is that this controller is not thought to have any external force apart from the vehicle weight, and in the case there are other forces the calculations of the torque applied to the wheels are wrong, but I'm far to be sure as I don't understand everything in it.

If my conclusion is right, is there a way to enhance it to handle this special case?

Thanks in advance, and I must say that you've done an amazing work on the vehicles !
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: [Edited] Questions about vehicles

Postby Julio Jerez » Fri Mar 15, 2013 10:09 am

Ok I set teh array to 6 inteas of 6

on the secund question,
the vehicle is a body, therfore teh forec will be any force and trque set in teh force and torque callback, in teh demo it is just grabody, but it can be anything you want.
the vehicle solve the read that values and add the forces generated by engine and sunspasion.
you should be able to apply it to an airplane and teh force on eth plai will be the standrd gravity and aerodynamics,
then this function will proceese then
Code: Select all
void CustomVehicleController::ChassisBodyState::UpdateDynamicInputs()
{
   NewtonBody* const body = m_controller->GetBody();

   NewtonBodyGetMatrix (body, &m_matrix[0][0]);
   NewtonBodyGetVelocity (body, &m_veloc[0]);
   NewtonBodyGetOmega (body, &m_omega[0]);

   NewtonBodyGetForceAcc(body, &m_externalForce[0]);
   NewtonBodyGetTorqueAcc(body, &m_externalTorque[0]);

   m_globalCentreOfMass = m_matrix.TransformVector(m_localFrame.m_posit);

   UpdateInertia();
}


or and I getting this wrong?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Edited] Questions about vehicles

Postby Crashy » Fri Mar 15, 2013 11:24 am

Ok, so it should work and the problem is maybe on my side.

I haven't added any engine component on my vehicle. Could it generate a problem in the wheel rotation?

I've made some new tests since

Here is a link to a video showing the problem. As you'll see, at the beginning the aircraft is going backwards because of gravity and gear inclination, wheels are rolling properly and there is no engine thrust. After 4 seconds, I increase the thrust and wheels start rotating super fast as if the aircraft is going forward, even if it's still going backwards.

There is the same result if the vehicle is stuck by another object while going backwards: the vehicle is not moving but the wheels are rolling forward.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: [Edited] Questions about vehicles

Postby Julio Jerez » Sat Mar 16, 2013 10:13 am

Oh I see.
the vehicle hoint has the complenets that are use to controll teh vehicle.

Code: Select all
   BrakeComponent* GetBrakes() const;
   EngineComponent* GetEngine() const;
   BrakeComponent* GetHandBrakes() const;
   SteeringComponent* GetSteering() const;


you shoul use those. I think what you have to do is that when the vehicle is airbone you call call
GetBrake()->SetParam(dFloat param);

the parameter goes form zero (no brake) to one (full brake)
you can try few values and see how the tire stops.

also if teh wheel spin whneth vehicle in on teh groun, that mean they gorudn friction is zero. did you check that?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Edited] Questions about vehicles

Postby Crashy » Sat Mar 16, 2013 1:20 pm

you shoul use those. I think what you have to do is that when the vehicle is airbone you call call
GetBrake()->SetParam(dFloat param);


I tried to use the brakes, but there aren't braking at all, and in the CustomVehicleController::TireJoint::JacobianDerivative() there is this piece of code:
Code: Select all
   // check if the brakes are a applied
   if (tire->m_breakTorque > 1.0e-3f) {
      _ASSERTE (0);
   }

So I assumed they wern't implemented yet.

The default material frictions are 1.5f for static friction and 1.4f for dynamic friction.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: [Edited] Questions about vehicles

Postby Julio Jerez » Tue Mar 19, 2013 11:13 am

Ok the brake joint is operational now.

I will see if I have time thsi weekend to make teh vehicel drive around.

For personal reasons I have not have much time to do anything on the engine, this past month.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Edited] Questions about vehicles

Postby Crashy » Tue Mar 19, 2013 11:21 am

OK, thank you very much.

I understand you cannot work on newton all the time, and you have already done a lot!

For the moment I have made a workaround but I'll check the future updates :)

Thanks.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: [Edited] Questions about vehicles

Postby Julio Jerez » Thu Apr 04, 2013 2:22 pm

Ok I see if I can finaly complete the vehicle this weekened

I have a quetsion, I see in thsi video
that you are working on a flight simulation. and you are using the hevhicle joint to contol the wheels.
are the wheel retractables? if so how are you handling that?
also can you show a video that show more o fteh oatplain fliging? I'd like to see how is working.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: [Edited] Questions about vehicles

Postby Crashy » Mon Apr 08, 2013 5:33 am

are the wheel retractables? if so how are you handling that?


I added a bool "m_enabled" to tire state to disable tires on the custom joint, it was a fast fix so nothing "pretty".

And I modified this function:
Code: Select all
void CustomVehicleController::TireBodyState::Collide (CustomControllerFilterCastFilter& filter, dFloat timestepInv)
{
   if(m_enabled)
   {
      NewtonBody* const body = m_controller->GetBody();
      NewtonWorld* const world = NewtonBodyGetWorld(body);
      const dMatrix& controllerMatrix = m_controller->m_chassisState.m_matrix;

      dFloat posit0 = m_posit;
      m_posit = 0.0f;
      m_speed = 0.0f;
      dMatrix localMatrix (CustomVehicleController::TireBodyState::CalculateSteeringMatrix ());
      m_posit = m_suspensionlenght;

      dFloat hitParam;
      dMatrix tireMatrix (localMatrix * controllerMatrix);
      dVector rayDestination (tireMatrix.TransformVector(localMatrix.m_up.Scale(-m_suspensionlenght)));   

      m_contactJoint.m_contactCount = 0;
      NewtonCollisionSetScale (m_controller->m_tireCastShape, m_width, m_radio * 2.0f, m_radio * 2.0f);
      
      m_contactJoint.m_contactCount = NewtonWorldConvexCast (world, &tireMatrix[0][0], &rayDestination[0], m_controller->m_tireCastShape, &hitParam, &filter, CustomControllerFilterCastFilter::ConvexStaticCastPrefilter, m_contactJoint.m_contacts, sizeof (m_contactJoint.m_contacts) / sizeof (m_contactJoint.m_contacts[0]), 0);
      if (m_contactJoint.m_contactCount) {
         // this tire hit something generate contact point and normals,
         // do not forget to filter bad contacts
         m_posit = hitParam * m_suspensionlenght;
         m_speed = (posit0 - m_posit) * timestepInv;
      }
   }
   else
   {
      m_posit=m_suspensionlenght;
      m_speed=0.0;
   }
}
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: [Edited] Questions about vehicles

Postby Crashy » Mon Apr 08, 2013 5:34 am

also can you show a video that show more o fteh oatplain fliging? I'd like to see how is working.


We have a teaser trailer here :)
http://steamcommunity.com/sharedfiles/f ... =123905369
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 7 guests

cron