예제 #1
0
//---------------------------------------------------------------------------------
//  Time Slice all wheels
//---------------------------------------------------------------------------------
void CGroundSuspension::Timeslice (float dT)
{ nWonG = 0;      // No wheels on ground
  SumGearForces.x = SumGearMoments.x = 0.0;
  SumGearForces.y = SumGearMoments.y = 0.0;
  SumGearForces.z = SumGearMoments.z = 0.0;

  if (type == TRICYCLE) {;}
  else {;} // \todo different kind of train
  std::vector<CSuspension *>::const_iterator it_whel;
  for (it_whel = whl_susp.begin (); it_whel != whl_susp.end (); it_whel++) {
    // is it a steering wheel ?
    CSuspension *ssp = (CSuspension*)(*it_whel);
		SGearData   *gdt = ssp->GetGearData();
    if (ssp->IsSteerWheel ()) 	mveh->GetGearChannel(gdt);
    // is it a braking wheel ?
    /// \todo .../...
    // ... and finally timeslice
    ssp->Timeslice (dT);
    // sum all gear forces
    const SVector gf  = (*it_whel)->GetBodyForce_ISU  ();
    SumGearForces.x  += gf.x;
    SumGearForces.y  += gf.y;
    SumGearForces.z  += gf.z;
    // sum all gear moments
    const SVector gm  = (*it_whel)->GetBodyMoment_ISU ();
    SumGearMoments.x += gm.x;
    SumGearMoments.y += gm.y;
    SumGearMoments.z += gm.z;
    //--- update wheels on ground --------------------
    if (ssp->IsOnGround())  nWonG++;
  }
}
예제 #2
0
//------------------------------------------------------------------------
//  JS to LC: Removed brake force from wheel definition as it is
//          only used in Suspension TimeSlice. 
//-------------------------------------------------------------------------
void COpalGroundSuspension::Timeslice (float dT)
{
  /// very important ! be sure to compute only during
  /// engine & aerodynamics cycle
  if (!globals->simulation) return;
  nWonG   = 0;      // No wheels on ground
  SumGearMoments.x = 0.0;
  SumGearMoments.y = 0.0;
  SumGearMoments.z = 0.0;
  //--- Compute velocity in Miles per Hours ---------
  double vt = (mveh->GetBodyVelocityVector ())->z;
  double velocity = NMILE_PER_METRE_SEC(vt);
  float fstbl = mstbl->Lookup (velocity); // 1.0f;
  float fbtbl = mbtbl->Lookup (velocity); // 1.0f;

  std::vector<CSuspension *>::const_iterator it_whel;
  //-- Check for gear position ----------------------
  if (mveh->lod->AreGearRetracted())
  { max_wheel_height_backup = max_wheel_height;
    max_wheel_height = 0.0;
  }
  if (mveh->lod->AreGearDown())
  { max_wheel_height = max_wheel_height_backup;
  }
  //
  for (it_whel = whl_susp.begin (); it_whel != whl_susp.end (); it_whel++) {
    // is it a steering wheel ?
    CSuspension *ssp = (CSuspension*)(*it_whel);
		SGearData *gdt	= ssp->GetGearData();
		gdt->stbl				= fstbl;
		gdt->btbl				= fbtbl;
    if (mveh->lod->AreGearDown()) { /// this is the completely extended gear position
      if (ssp->IsSteerWheel ()) mveh->GetGearChannel(gdt);
      // ... and finally timeslice
      ssp->Timeslice (dT);
      if (ssp->IsOnGround()) nWonG++;
    }
  }

  /// All the computation below is LH
  // verify if this test is useful 
  //
  // add mass moment related to main gear
  // JS NOTE:  The main_pos is in fact the distance between the Cg and the steering
  //  wheel.   
  //  On a tricyle, the steering is in positive direction while on a Tail Dragger
  //  the steering is in negative direction.
  //  So I made the following modifications
  //  The steering distance (in meters) is computed in the 
  //  CGroundSuspension::InitJoint() when wheels positions are computed
  //  This vector is stored into mainVM and the massCF is the coeeficent
  //  that modulate the mass supported by the wheel.  
  //  Also, the mass_force is modified so that the force applied is in the
  //  vertical direction (Z) and is negative.
  //

  { 
    CVector mass_moment;
    CVector mass_force (0, 0, -mveh->GetMassInKgs() * GRAVITY_MTS * massCF);   //, 0.0);
    CVector mass_pos, main_gear;
    //  main_gear.Set (0.0, FeetToMetres (-max_wheel_height), FeetToMetres (max_gear));
    //  mass_pos = *mveh->svh->GetNewCG_ISU () - main_gear;
    //  VectorCrossProduct (mass_moment, mass_pos, mass_force);
    VectorCrossProduct (mass_moment, mainVM, mass_force);
    /// add gear moment to the CG moment
    SumGearMoments = VectorSum (SumGearMoments, mass_moment);

    #ifdef _DEBUG_suspension	
    {   FILE *fp_debug;
      if((fp_debug = fopen("__DDEBUG_suspension.txt", "a")) != NULL)
      {
            fprintf(fp_debug, "---------------------------------------------------------\n");
            fprintf(fp_debug, "COpalGroundSuspension::Timeslice nWOW=%d SumF(%f %f %f) SumM(%f %f %f)\n",
              nWOW,
              SumGearForces.x,  SumGearForces.y,  SumGearForces.z,
              SumGearMoments.x, SumGearMoments.y, SumGearMoments.z
             );
            fprintf(fp_debug, " cg(%f %f %f) mg(%f %f %f) mp(%f %f %f)\n mf(%f %f %f) mm(%f %f %f) (mwh%f Mg%f mg%f)\n",
              globals->sit->user->svh->GetNewCG_ISU ()->x,  globals->sit->user->svh->GetNewCG_ISU ()->y,  globals->sit->user->svh->GetNewCG_ISU ()->z,
              main_gear.x, main_gear.y, main_gear.z,
              mass_pos.x, mass_pos.y, mass_pos.z,
              mass_force.x, mass_force.y, mass_force.z,
              mass_moment.x, mass_moment.y, mass_moment.z,
              max_wheel_height, max_gear, min_gear
             );
            fprintf(fp_debug, "---------------------------------------------------------\n");
            fclose(fp_debug); 
    }    }
    #endif
  }
}