00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <cob_undercarriage_ctrl/UndercarriageCtrlGeom.h>
00019
00020
00021 UndercarriageCtrlGeom::UndercarriageCtrlGeom(std::string sIniDirectory)
00022 {
00023 m_sIniDirectory = sIniDirectory;
00024
00025
00026 m_bEMStopActive = false;
00027
00028 IniFile iniFile;
00029 iniFile.SetFileName(m_sIniDirectory + "Platform.ini", "UnderCarriageCtrlGeom.cpp");
00030 iniFile.GetKeyInt("Config", "NumberOfWheels", &m_iNumberOfDrives, true);
00031
00032
00033 m_vdVelGearDriveRadS.assign(4,0);
00034 m_vdVelGearSteerRadS.assign(4,0);
00035 m_vdDltAngGearDriveRad.assign(4,0);
00036 m_vdAngGearSteerRad.assign(4,0);
00037
00038
00039
00040
00041
00042 m_vdVelGearDriveCmdRadS.assign(4,0);
00043 m_vdVelGearSteerCmdRadS.assign(4,0);
00044 m_vdAngGearSteerCmdRad.assign(4,0);
00045
00046 m_vdWheelXPosMM.assign(4,0);
00047 m_vdWheelYPosMM.assign(4,0);
00048 m_vdWheelDistMM.assign(4,0);
00049 m_vdWheelAngRad.assign(4,0);
00050
00051 m_vdExWheelXPosMM.assign(4,0);
00052 m_vdExWheelYPosMM.assign(4,0);
00053 m_vdExWheelDistMM.assign(4,0);
00054 m_vdExWheelAngRad.assign(4,0);
00055
00056 m_vdAngGearSteerTarget1Rad.assign(4,0);
00057 m_vdVelGearDriveTarget1RadS.assign(4,0);
00058 m_vdAngGearSteerTarget2Rad.assign(4,0);
00059 m_vdVelGearDriveTarget2RadS.assign(4,0);
00060 m_vdAngGearSteerTargetRad.assign(4,0);
00061 m_vdVelGearDriveTargetRadS.assign(4,0);
00062
00063 m_dCmdVelLongMMS = 0;
00064 m_dCmdVelLatMMS = 0;
00065 m_dCmdRotRobRadS = 0;
00066 m_dCmdRotVelRadS = 0;
00067
00068 m_UnderCarriagePrms.WheelNeutralPos.assign(4,0);
00069 m_UnderCarriagePrms.vdSteerDriveCoupling.assign(4,0);
00070 m_UnderCarriagePrms.vdFactorVel.assign(4,0);
00071
00072 m_vdCtrlVal.assign( 4, std::vector<double> (2,0.0) );
00073
00074
00075
00076
00077
00078 m_dSpring = 10.0;
00079 m_dDamp = 2.5;
00080 m_dVirtM = 0.1;
00081 m_dDPhiMax = 12.0;
00082 m_dDDPhiMax = 100.0;
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 }
00101
00102
00103 UndercarriageCtrlGeom::~UndercarriageCtrlGeom(void)
00104 {
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 }
00118
00119
00120 void UndercarriageCtrlGeom::InitUndercarriageCtrl(void)
00121 {
00122
00123
00124 IniFile iniFile;
00125
00126 iniFile.SetFileName(m_sIniDirectory + "Platform.ini", "UnderCarriageCtrlGeom.cpp");
00127 iniFile.GetKeyInt("Geom", "DistWheels", &m_UnderCarriagePrms.iDistWheels, true);
00128 iniFile.GetKeyInt("Geom", "RadiusWheel", &m_UnderCarriagePrms.iRadiusWheelMM, true);
00129 iniFile.GetKeyInt("Geom", "DistSteerAxisToDriveWheelCenter", &m_UnderCarriagePrms.iDistSteerAxisToDriveWheelMM, true);
00130
00131 iniFile.GetKeyDouble("Geom", "Wheel1XPos", &m_vdWheelXPosMM[0], true);
00132 iniFile.GetKeyDouble("Geom", "Wheel1YPos", &m_vdWheelYPosMM[0], true);
00133 iniFile.GetKeyDouble("Geom", "Wheel2XPos", &m_vdWheelXPosMM[1], true);
00134 iniFile.GetKeyDouble("Geom", "Wheel2YPos", &m_vdWheelYPosMM[1], true);
00135 iniFile.GetKeyDouble("Geom", "Wheel3XPos", &m_vdWheelXPosMM[2], true);
00136 iniFile.GetKeyDouble("Geom", "Wheel3YPos", &m_vdWheelYPosMM[2], true);
00137 iniFile.GetKeyDouble("Geom", "Wheel4XPos", &m_vdWheelXPosMM[3], true);
00138 iniFile.GetKeyDouble("Geom", "Wheel4YPos", &m_vdWheelYPosMM[3], true);
00139
00140 iniFile.GetKeyDouble("DrivePrms", "MaxDriveRate", &m_UnderCarriagePrms.dMaxDriveRateRadpS, true);
00141 iniFile.GetKeyDouble("DrivePrms", "MaxSteerRate", &m_UnderCarriagePrms.dMaxSteerRateRadpS, true);
00142
00143 iniFile.GetKeyDouble("DrivePrms", "Wheel1SteerDriveCoupling", &m_UnderCarriagePrms.vdSteerDriveCoupling[0], true);
00144 iniFile.GetKeyDouble("DrivePrms", "Wheel2SteerDriveCoupling", &m_UnderCarriagePrms.vdSteerDriveCoupling[1], true);
00145 iniFile.GetKeyDouble("DrivePrms", "Wheel3SteerDriveCoupling", &m_UnderCarriagePrms.vdSteerDriveCoupling[2], true);
00146 iniFile.GetKeyDouble("DrivePrms", "Wheel4SteerDriveCoupling", &m_UnderCarriagePrms.vdSteerDriveCoupling[3], true);
00147
00148 iniFile.GetKeyDouble("DrivePrms", "Wheel1NeutralPosition", &m_UnderCarriagePrms.WheelNeutralPos[0], true);
00149 iniFile.GetKeyDouble("DrivePrms", "Wheel2NeutralPosition", &m_UnderCarriagePrms.WheelNeutralPos[1], true);
00150 iniFile.GetKeyDouble("DrivePrms", "Wheel3NeutralPosition", &m_UnderCarriagePrms.WheelNeutralPos[2], true);
00151 iniFile.GetKeyDouble("DrivePrms", "Wheel4NeutralPosition", &m_UnderCarriagePrms.WheelNeutralPos[3], true);
00152
00153 for(int i = 0; i<4; i++)
00154 {
00155 m_UnderCarriagePrms.WheelNeutralPos[i] = MathSup::convDegToRad(m_UnderCarriagePrms.WheelNeutralPos[i]);
00156
00157 m_vdAngGearSteerCmdRad[i] = m_UnderCarriagePrms.WheelNeutralPos[i];
00158
00159
00160
00161 m_vdAngGearSteerTargetRad[i] = m_UnderCarriagePrms.WheelNeutralPos[i];
00162 }
00163
00164 iniFile.GetKeyDouble("Thread", "ThrUCarrCycleTimeS", &m_UnderCarriagePrms.dCmdRateS, true);
00165
00166
00167 iniFile.SetFileName(m_sIniDirectory + "MotionCtrl.ini", "PltfHardwareCoB3.h");
00168
00169 iniFile.GetKeyDouble("SteerCtrl", "Spring", &m_dSpring, true);
00170 iniFile.GetKeyDouble("SteerCtrl", "Damp", &m_dDamp, true);
00171 iniFile.GetKeyDouble("SteerCtrl", "VirtMass", &m_dVirtM, true);
00172 iniFile.GetKeyDouble("SteerCtrl", "DPhiMax", &m_dDPhiMax, true);
00173 iniFile.GetKeyDouble("SteerCtrl", "DDPhiMax", &m_dDDPhiMax, true);
00174
00175
00176 for(int i=0; i<4; i++)
00177 {
00178 m_vdWheelDistMM[i] = sqrt( (m_vdWheelXPosMM[i] * m_vdWheelXPosMM[i]) + (m_vdWheelYPosMM[i] * m_vdWheelYPosMM[i]) );
00179 m_vdWheelAngRad[i] = MathSup::atan4quad(m_vdWheelXPosMM[i], m_vdWheelYPosMM[i]);
00180 }
00181
00182
00183 CalcExWheelPos();
00184
00185
00186 for(int i = 0; i<4; i++)
00187 {
00188 m_UnderCarriagePrms.vdFactorVel[i] = - m_UnderCarriagePrms.vdSteerDriveCoupling[i]
00189 +(double(m_UnderCarriagePrms.iDistSteerAxisToDriveWheelMM) / double(m_UnderCarriagePrms.iRadiusWheelMM));
00190 }
00191
00192 }
00193
00194
00195 void UndercarriageCtrlGeom::SetDesiredPltfVelocity(double dCmdVelLongMMS, double dCmdVelLatMMS, double dCmdRotRobRadS, double dCmdRotVelRadS)
00196 {
00197
00198 double dCurrentPosWheelRAD;
00199 double dtempDeltaPhi1RAD, dtempDeltaPhi2RAD;
00200 double dtempDeltaPhiCmd1RAD, dtempDeltaPhiCmd2RAD;
00201 double dtempWeightedDelta1RAD, dtempWeightedDelta2RAD;
00202
00203
00204 m_dCmdVelLongMMS = dCmdVelLongMMS;
00205 m_dCmdVelLatMMS = dCmdVelLatMMS;
00206 m_dCmdRotRobRadS = dCmdRotRobRadS;
00207 m_dCmdRotVelRadS = dCmdRotVelRadS;
00208
00209 CalcInverse();
00210
00211
00212 for (int i = 0; i<4; i++)
00213 {
00214
00215 dCurrentPosWheelRAD = m_vdAngGearSteerRad[i];
00216 MathSup::normalizePi(dCurrentPosWheelRAD);
00217
00218
00219 dtempDeltaPhi1RAD = m_vdAngGearSteerTarget1Rad[i] - dCurrentPosWheelRAD;
00220 dtempDeltaPhi2RAD = m_vdAngGearSteerTarget2Rad[i] - dCurrentPosWheelRAD;
00221 MathSup::normalizePi(dtempDeltaPhi1RAD);
00222 MathSup::normalizePi(dtempDeltaPhi2RAD);
00223
00224 dtempDeltaPhiCmd1RAD = m_vdAngGearSteerTarget1Rad[i] - m_vdAngGearSteerTargetRad[i];
00225 dtempDeltaPhiCmd2RAD = m_vdAngGearSteerTarget2Rad[i] - m_vdAngGearSteerTargetRad[i];
00226 MathSup::normalizePi(dtempDeltaPhiCmd1RAD);
00227 MathSup::normalizePi(dtempDeltaPhiCmd2RAD);
00228
00229
00230
00231
00232
00233
00234
00235 dtempWeightedDelta1RAD = 0.6*fabs(dtempDeltaPhi1RAD) + 0.4*fabs(dtempDeltaPhiCmd1RAD);
00236 dtempWeightedDelta2RAD = 0.6*fabs(dtempDeltaPhi2RAD) + 0.4*fabs(dtempDeltaPhiCmd2RAD);
00237
00238
00239 if (dtempWeightedDelta1RAD <= dtempWeightedDelta2RAD)
00240 {
00241
00242 m_vdVelGearDriveTargetRadS[i] = m_vdVelGearDriveTarget1RadS[i];
00243 m_vdAngGearSteerTargetRad[i] = m_vdAngGearSteerTarget1Rad[i];
00244 }
00245 else
00246 {
00247
00248 m_vdVelGearDriveTargetRadS[i] = m_vdVelGearDriveTarget2RadS[i];
00249 m_vdAngGearSteerTargetRad[i] = m_vdAngGearSteerTarget2Rad[i];
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 }
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 }
00298
00299
00300 void UndercarriageCtrlGeom::SetActualWheelValues(std::vector<double> vdVelGearDriveRadS, std::vector<double> vdVelGearSteerRadS, std::vector<double> vdDltAngGearDriveRad, std::vector<double> vdAngGearSteerRad)
00301 {
00302
00303
00304 m_vdVelGearDriveRadS = vdVelGearDriveRadS;
00305 m_vdVelGearSteerRadS = vdVelGearSteerRadS;
00306 m_vdDltAngGearDriveRad = vdDltAngGearDriveRad;
00307 m_vdAngGearSteerRad = vdAngGearSteerRad;
00308
00309
00310 CalcExWheelPos();
00311
00312
00313 CalcDirect();
00314 }
00315
00316
00317 void UndercarriageCtrlGeom::GetSteerDriveSetValues(std::vector<double> & vdVelGearDriveRadS, std::vector<double> & vdAngGearSteerRad)
00318 {
00319
00320
00321 CalcInverse();
00322
00323 vdVelGearDriveRadS = m_vdVelGearDriveTarget1RadS;
00324 vdAngGearSteerRad = m_vdAngGearSteerTarget1Rad;
00325 }
00326
00327
00328 void UndercarriageCtrlGeom::GetNewCtrlStateSteerDriveSetValues(std::vector<double> & vdVelGearDriveRadS, std::vector<double> & vdVelGearSteerRadS, std::vector<double> & vdAngGearSteerRad,
00329 double & dVelLongMMS, double & dVelLatMMS, double & dRotRobRadS, double & dRotVelRadS)
00330 {
00331
00332 if(m_bEMStopActive == false)
00333 {
00334
00335 CalcControlStep();
00336 }
00337
00338 vdVelGearDriveRadS = m_vdVelGearDriveCmdRadS;
00339 vdVelGearSteerRadS = m_vdVelGearSteerCmdRadS;
00340 vdAngGearSteerRad = m_vdAngGearSteerCmdRad;
00341
00342 dVelLongMMS = m_dCmdVelLongMMS;
00343 dVelLatMMS = m_dCmdVelLatMMS;
00344 dRotRobRadS = m_dCmdRotRobRadS;
00345 dRotVelRadS = m_dCmdRotVelRadS;
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 }
00356
00357
00358 void UndercarriageCtrlGeom::GetActualPltfVelocity(double & dDeltaLongMM, double & dDeltaLatMM, double & dDeltaRotRobRad, double & dDeltaRotVelRad,
00359 double & dVelLongMMS, double & dVelLatMMS, double & dRotRobRadS, double & dRotVelRadS)
00360 {
00361 dVelLongMMS = m_dVelLongMMS;
00362 dVelLatMMS = m_dVelLatMMS;
00363 dRotRobRadS = m_dRotRobRadS;
00364 dRotVelRadS = m_dRotVelRadS;
00365
00366
00367
00368
00369 dDeltaLongMM = dVelLongMMS * m_UnderCarriagePrms.dCmdRateS;
00370 dDeltaLatMM = dVelLatMMS * m_UnderCarriagePrms.dCmdRateS;
00371 dDeltaRotRobRad = dRotRobRadS * m_UnderCarriagePrms.dCmdRateS;
00372 dDeltaRotVelRad = dRotVelRadS * m_UnderCarriagePrms.dCmdRateS;
00373 }
00374
00375
00376 void UndercarriageCtrlGeom::CalcInverse(void)
00377 {
00378
00379 double dtempAxVelXRobMMS, dtempAxVelYRobMMS;
00380
00381
00382 if((m_dCmdVelLongMMS == 0) && (m_dCmdVelLatMMS == 0) && (m_dCmdRotRobRadS == 0) && (m_dCmdRotVelRadS == 0))
00383 {
00384 for(int i = 0; i<4; i++)
00385 {
00386 m_vdAngGearSteerTarget1Rad[i] = m_vdAngGearSteerRad[i];
00387 m_vdVelGearDriveTarget1RadS[i] = 0.0;
00388 m_vdAngGearSteerTarget2Rad[i] = m_vdAngGearSteerRad[i];
00389 m_vdVelGearDriveTarget2RadS[i] = 0.0;
00390 }
00391 return;
00392 }
00393
00394
00395 for (int i = 0; i<4; i++)
00396 {
00397
00398
00399 dtempAxVelXRobMMS = m_dCmdVelLongMMS;
00400 dtempAxVelYRobMMS = m_dCmdVelLatMMS;
00401
00402 dtempAxVelXRobMMS += m_dCmdRotRobRadS * m_vdExWheelDistMM[i] * -sin(m_vdExWheelAngRad[i]);
00403 dtempAxVelYRobMMS += m_dCmdRotRobRadS * m_vdExWheelDistMM[i] * cos(m_vdExWheelAngRad[i]);
00404
00405
00406
00407 m_vdAngGearSteerTarget1Rad[i] = MathSup::atan4quad(dtempAxVelYRobMMS, dtempAxVelXRobMMS);
00408
00409 m_vdAngGearSteerTarget2Rad[i] = m_vdAngGearSteerTarget1Rad[i] + MathSup::PI;
00410 MathSup::normalizePi(m_vdAngGearSteerTarget2Rad[i]);
00411
00412
00413 m_vdVelGearDriveTarget1RadS[i] = sqrt( (dtempAxVelXRobMMS * dtempAxVelXRobMMS) +
00414 (dtempAxVelYRobMMS * dtempAxVelYRobMMS) ) / (double)m_UnderCarriagePrms.iRadiusWheelMM;
00415
00416 m_vdVelGearDriveTarget2RadS[i] = - m_vdVelGearDriveTarget1RadS[i];
00417 }
00418 }
00419
00420
00421 void UndercarriageCtrlGeom::CalcDirect(void)
00422 {
00423
00424 double dtempVelXRobMMS;
00425 double dtempVelYRobMMS;
00426 double dtempRotRobRADPS;
00427 double dtempDiffXMM;
00428 double dtempDiffYMM;
00429 double dtempRelPhiWheelsRAD;
00430 double dtempRelDistWheelsMM;
00431 double dtempRelPhiWheel1RAD;
00432 double dtempRelPhiWheel2RAD;
00433 std::vector<double> vdtempVelWheelMMS(4);
00434
00435
00436 dtempVelXRobMMS = 0;
00437 dtempVelYRobMMS = 0;
00438 dtempRotRobRADPS = 0;
00439
00440
00441
00442
00443 for(int i = 0; i<m_iNumberOfDrives; i++)
00444 {
00445
00446 vdtempVelWheelMMS[i] = m_UnderCarriagePrms.iRadiusWheelMM * (m_vdVelGearDriveRadS[i] - m_UnderCarriagePrms.vdFactorVel[i]* m_vdVelGearSteerRadS[i]);
00447 }
00448
00449
00450 for(int i = 0; i< (m_iNumberOfDrives-1) ; i++)
00451 {
00452
00453 dtempDiffXMM = m_vdExWheelXPosMM[i+1] - m_vdExWheelXPosMM[i];
00454 dtempDiffYMM = m_vdExWheelYPosMM[i+1] - m_vdExWheelYPosMM[i];
00455 dtempRelDistWheelsMM = sqrt( dtempDiffXMM*dtempDiffXMM + dtempDiffYMM*dtempDiffYMM );
00456 dtempRelPhiWheelsRAD = MathSup::atan4quad( dtempDiffYMM, dtempDiffXMM );
00457
00458
00459 dtempRelPhiWheel1RAD = m_vdAngGearSteerRad[i] - dtempRelPhiWheelsRAD;
00460 dtempRelPhiWheel2RAD = m_vdAngGearSteerRad[i+1] - dtempRelPhiWheelsRAD;
00461
00462 dtempRotRobRADPS += (vdtempVelWheelMMS[i+1] * sin(dtempRelPhiWheel2RAD) - vdtempVelWheelMMS[i] * sin(dtempRelPhiWheel1RAD))/dtempRelDistWheelsMM;
00463 }
00464
00465
00466
00467 dtempDiffXMM = m_vdExWheelXPosMM[0] - m_vdExWheelXPosMM[m_iNumberOfDrives-1];
00468 dtempDiffYMM = m_vdExWheelYPosMM[0] - m_vdExWheelYPosMM[m_iNumberOfDrives-1];
00469 dtempRelDistWheelsMM = sqrt( dtempDiffXMM*dtempDiffXMM + dtempDiffYMM*dtempDiffYMM );
00470 dtempRelPhiWheelsRAD = MathSup::atan4quad( dtempDiffYMM, dtempDiffXMM );
00471
00472
00473 dtempRelPhiWheel1RAD = m_vdAngGearSteerRad[m_iNumberOfDrives-1] - dtempRelPhiWheelsRAD;
00474 dtempRelPhiWheel2RAD = m_vdAngGearSteerRad[0] - dtempRelPhiWheelsRAD;
00475
00476
00477 dtempRotRobRADPS += (vdtempVelWheelMMS[0]*sin(dtempRelPhiWheel2RAD) - vdtempVelWheelMMS[m_iNumberOfDrives-1]*sin(dtempRelPhiWheel1RAD))/dtempRelDistWheelsMM;
00478
00479
00480 for(int i = 0; i<m_iNumberOfDrives; i++)
00481 {
00482 dtempVelXRobMMS += vdtempVelWheelMMS[i]*cos(m_vdAngGearSteerRad[i]);
00483 dtempVelYRobMMS += vdtempVelWheelMMS[i]*sin(m_vdAngGearSteerRad[i]);
00484 }
00485
00486
00487 m_dRotRobRadS = dtempRotRobRADPS/m_iNumberOfDrives;
00488 m_dRotVelRadS = 0;
00489
00490
00491 m_dVelLongMMS = dtempVelXRobMMS/m_iNumberOfDrives;
00492 m_dVelLatMMS = dtempVelYRobMMS/m_iNumberOfDrives;
00493
00494
00495
00496 }
00497
00498
00499 void UndercarriageCtrlGeom::CalcExWheelPos(void)
00500 {
00501
00502 for(int i = 0; i<4; i++)
00503 {
00504
00505 m_vdExWheelXPosMM[i] = m_vdWheelXPosMM[i] + m_UnderCarriagePrms.iDistSteerAxisToDriveWheelMM * sin(m_vdAngGearSteerRad[i]);
00506 m_vdExWheelYPosMM[i] = m_vdWheelYPosMM[i] - m_UnderCarriagePrms.iDistSteerAxisToDriveWheelMM * cos(m_vdAngGearSteerRad[i]);
00507
00508
00509 m_vdExWheelDistMM[i] = sqrt( (m_vdExWheelXPosMM[i] * m_vdExWheelXPosMM[i]) + (m_vdExWheelYPosMM[i] * m_vdExWheelYPosMM[i]) );
00510
00511
00512 m_vdExWheelAngRad[i] = MathSup::atan4quad( m_vdExWheelYPosMM[i], m_vdExWheelXPosMM[i]);
00513 }
00514 }
00515
00516
00517 void UndercarriageCtrlGeom::CalcControlStep(void)
00518 {
00519
00520 if ((m_dCmdVelLongMMS == 0) && (m_dCmdVelLatMMS == 0) && (m_dCmdRotRobRadS == 0) && (m_dCmdRotVelRadS == 0))
00521 {
00522 m_vdVelGearDriveCmdRadS.assign(4,0.0);
00523 m_vdVelGearSteerCmdRadS.assign(4,0.0);
00524
00525
00526 for(int i=0; i<4; i++)
00527 {
00528 m_vdCtrlVal[i][0] = 0.0;
00529 m_vdCtrlVal[i][1] = 0.0;
00530 }
00531 return;
00532 }
00533
00534
00535 double dCurrentPosWheelRAD;
00536 double dDeltaPhi;
00537 double dForceDamp, dForceProp, dAccCmd, dVelCmdInt;
00538
00539 for (int i=0; i<4; i++)
00540 {
00541
00542 m_vdVelGearDriveCmdRadS[i] = m_vdVelGearDriveTargetRadS[i];
00543 m_vdAngGearSteerCmdRad[i] = m_vdAngGearSteerTargetRad[i];
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555 }
00556
00557
00558 for (int i = 0; i<4; i++)
00559 {
00560
00561 dCurrentPosWheelRAD = m_vdAngGearSteerRad[i];
00562 MathSup::normalizePi(dCurrentPosWheelRAD);
00563 dDeltaPhi = m_vdAngGearSteerCmdRad[i] - dCurrentPosWheelRAD;
00564 MathSup::normalizePi(dDeltaPhi);
00565
00566
00567
00568
00569 dForceDamp = - m_dDamp * m_vdCtrlVal[i][1];
00570 dForceProp = m_dSpring * dDeltaPhi;
00571 dAccCmd = (dForceDamp + dForceProp) / m_dVirtM;
00572 if (dAccCmd > m_dDDPhiMax)
00573 {
00574 dAccCmd = m_dDDPhiMax;
00575 }
00576 else if (dAccCmd < -m_dDDPhiMax)
00577 {
00578 dAccCmd = -m_dDDPhiMax;
00579 }
00580 dVelCmdInt = m_vdCtrlVal[i][1] + m_UnderCarriagePrms.dCmdRateS * dAccCmd;
00581 if (dVelCmdInt > m_dDPhiMax)
00582 {
00583 dVelCmdInt = m_dDPhiMax;
00584 }
00585 else if (dVelCmdInt < -m_dDPhiMax)
00586 {
00587 dVelCmdInt = -m_dDPhiMax;
00588 }
00589
00590 m_vdCtrlVal[i][0] = dDeltaPhi;
00591 m_vdCtrlVal[i][1] = dVelCmdInt;
00592
00593 m_vdVelGearSteerCmdRadS[i] = dVelCmdInt;
00594
00595
00596 if(fabs(m_vdVelGearSteerCmdRadS[i]) > m_UnderCarriagePrms.dMaxSteerRateRadpS)
00597 {
00598 if (m_vdVelGearSteerCmdRadS[i] > 0)
00599 m_vdVelGearSteerCmdRadS[i] = m_UnderCarriagePrms.dMaxSteerRateRadpS;
00600 else
00601 m_vdVelGearSteerCmdRadS[i] = -m_UnderCarriagePrms.dMaxSteerRateRadpS;
00602 }
00603 }
00604
00605
00606 for (int i = 0; i<4; i++)
00607 {
00608 m_vdVelGearDriveCmdRadS[i] += m_vdVelGearSteerCmdRadS[i] * m_UnderCarriagePrms.vdFactorVel[i];
00609 }
00610
00611 }
00612
00613
00614 void UndercarriageCtrlGeom::operator=(const UndercarriageCtrlGeom & GeomCtrl)
00615 {
00616
00617 m_dVelLongMMS = GeomCtrl.m_dVelLongMMS;
00618 m_dVelLatMMS = GeomCtrl.m_dVelLatMMS;
00619 m_dRotRobRadS = GeomCtrl.m_dRotRobRadS;
00620 m_dRotVelRadS = GeomCtrl.m_dRotVelRadS;
00621
00622
00623 m_vdVelGearDriveRadS = GeomCtrl.m_vdVelGearDriveRadS;
00624 m_vdVelGearSteerRadS = GeomCtrl.m_vdVelGearSteerRadS;
00625 m_vdDltAngGearDriveRad = GeomCtrl.m_vdDltAngGearDriveRad;
00626 m_vdAngGearSteerRad = GeomCtrl.m_vdAngGearSteerRad;
00627
00628
00629 m_dCmdVelLongMMS = GeomCtrl.m_dCmdVelLongMMS;
00630 m_dCmdVelLatMMS = GeomCtrl.m_dCmdVelLatMMS;
00631 m_dCmdRotRobRadS = GeomCtrl.m_dCmdRotRobRadS;
00632 m_dCmdRotVelRadS = GeomCtrl.m_dCmdRotVelRadS;
00633
00634
00635 m_vdVelGearDriveCmdRadS = GeomCtrl.m_vdVelGearDriveCmdRadS;
00636 m_vdVelGearSteerCmdRadS = GeomCtrl.m_vdVelGearSteerCmdRadS;
00637 m_vdAngGearSteerCmdRad = GeomCtrl.m_vdAngGearSteerCmdRad;
00638
00639
00640
00641 m_vdAngGearSteerTarget1Rad = GeomCtrl.m_vdAngGearSteerTarget1Rad;
00642 m_vdVelGearDriveTarget1RadS = GeomCtrl.m_vdVelGearDriveTarget1RadS;
00643
00644 m_vdAngGearSteerTarget2Rad = GeomCtrl.m_vdAngGearSteerTarget2Rad;
00645 m_vdVelGearDriveTarget2RadS = GeomCtrl.m_vdVelGearDriveTarget2RadS;
00646
00647
00648 m_vdWheelXPosMM = GeomCtrl.m_vdWheelXPosMM;
00649 m_vdWheelYPosMM = GeomCtrl.m_vdWheelYPosMM;
00650 m_vdWheelDistMM = GeomCtrl.m_vdWheelDistMM;
00651 m_vdWheelAngRad = GeomCtrl.m_vdWheelAngRad;
00652
00653
00654 m_vdExWheelXPosMM = GeomCtrl.m_vdExWheelXPosMM;
00655 m_vdExWheelYPosMM = GeomCtrl.m_vdExWheelYPosMM;
00656 m_vdExWheelDistMM = GeomCtrl.m_vdExWheelDistMM;
00657 m_vdExWheelAngRad = GeomCtrl.m_vdExWheelAngRad;
00658
00659
00660 m_UnderCarriagePrms = GeomCtrl.m_UnderCarriagePrms;
00661
00662
00663
00664 m_dSpring = GeomCtrl.m_dSpring;
00665 m_dDamp = GeomCtrl.m_dDamp;
00666 m_dVirtM = GeomCtrl.m_dDPhiMax;
00667 m_dDPhiMax = GeomCtrl.m_dDPhiMax;
00668 m_dDDPhiMax = GeomCtrl.m_dDDPhiMax;
00669
00670 m_vdCtrlVal = GeomCtrl.m_vdCtrlVal;
00671 }
00672
00673
00674 void UndercarriageCtrlGeom::setEMStopActive(bool bEMStopActive)
00675 {
00676 m_bEMStopActive = bEMStopActive;
00677
00678
00679 if(m_bEMStopActive)
00680 {
00681
00682 for(int i=0; i<4; i++)
00683 {
00684 for(int j=0; j< 2; j++)
00685 {
00686 m_vdCtrlVal[i][j] = 0.0;
00687 }
00688 }
00689
00690 for(int i=0; i<4; i++)
00691 {
00692 m_vdVelGearDriveCmdRadS[i] = 0.0;
00693 m_vdVelGearSteerCmdRadS[i] = 0.0;
00694 }
00695 }
00696
00697 }