00001 #include "SIGEL_Simulation/SIG_SimulationParameters.h"
00002
00003 #include "SIGEL_Tools/SIG_IO.h"
00004
00005 SIGEL_Simulation::SIG_SimulationParameters::SIG_SimulationParameters()
00006 : timeToSimulate(0,0,10),
00007 stepSize(0.02),
00008 maximalError(0.1),
00009 maximalIterations(100),
00010 maximalCollisionLoops(10),
00011 analytical(true),
00012 skipFrames(0),
00013 solveMode(smtConjugateGradient),
00014 integrator(itRungeKutta4),
00015 dynaMechsIntegrator( RungeKutta4 ),
00016 simulationLibrary( DynaMechs ),
00017 randomSeed(0),
00018 maximalSOLIDIterations(1),
00019 jointLimitsK_spring(50),
00020 jointLimitsB_damper(5),
00021 jointFrictionU_c(0.35)
00022 { };
00023
00024 SIGEL_Simulation::SIG_SimulationParameters::SIG_SimulationParameters(QTime timeToSimulate,
00025 double stepSize,
00026 double maximalError,
00027 int maximalIterations,
00028 int maximalCollisionLoops,
00029 bool analytical,
00030 int skipFrames,
00031 SolveModeType solveMode,
00032 IntegratorType integrator,
00033 DynaMechsIntegrator dynaMechsIntegrator,
00034 SimulationLibrary simulationLibrary,
00035 int maximalSOLIDIterations,
00036 int randomSeed = 0 )
00037 : timeToSimulate(timeToSimulate),
00038 stepSize(stepSize),
00039 maximalError(maximalError),
00040 randomSeed(randomSeed),
00041 maximalIterations(maximalIterations),
00042 maximalCollisionLoops(maximalCollisionLoops),
00043 analytical(analytical),
00044 skipFrames(skipFrames),
00045 solveMode(solveMode),
00046 integrator(integrator),
00047 dynaMechsIntegrator( dynaMechsIntegrator ),
00048 simulationLibrary( simulationLibrary ),
00049 maximalSOLIDIterations(maximalSOLIDIterations)
00050 { };
00051
00052 void SIGEL_Simulation::SIG_SimulationParameters::readFromFile(QTextStream& file)
00053 {
00054 QString s;
00055 s=file.readLine();
00056 s=file.readLine();
00057 int hour=s.toInt();
00058 s=file.readLine();
00059 int minute=s.toInt();
00060 s=file.readLine();
00061 int second=s.toInt();
00062 s=file.readLine();
00063 int msec=s.toInt();
00064 timeToSimulate.setHMS(hour,minute,second,msec);
00065 s=file.readLine();
00066 s=file.readLine();
00067 stepSize=s.toDouble();
00068 s=file.readLine();
00069 s=file.readLine();
00070 maximalError=s.toDouble();
00071 s=file.readLine();
00072 s=file.readLine();
00073 randomSeed=s.toInt();
00074 s=file.readLine();
00075 s=file.readLine();
00076 maximalIterations=s.toInt();
00077 s=file.readLine();
00078 s=file.readLine();
00079 skipFrames=s.toInt();
00080 s=file.readLine();
00081 s=file.readLine();
00082 int an=s.toInt();
00083 if (an==1)
00084 analytical=true;
00085 else
00086 analytical=false;
00087 s=file.readLine();
00088 s=file.readLine();
00089 maximalCollisionLoops=s.toInt();
00090 s=file.readLine();
00091 s=file.readLine();
00092 solveMode=static_cast<SolveModeType>(s.toInt());
00093 s=file.readLine();
00094 s=file.readLine();
00095 integrator=static_cast<IntegratorType>(s.toInt());
00096 s=file.readLine();
00097 s=file.readLine();
00098 dynaMechsIntegrator=static_cast<DynaMechsIntegrator>(s.toInt());
00099 s=file.readLine();
00100 s=file.readLine();
00101 simulationLibrary=static_cast<SimulationLibrary>(s.toInt());
00102 s=file.readLine();
00103 s=file.readLine();
00104 maximalSOLIDIterations=s.toInt();
00105 s=file.readLine();
00106 s=file.readLine();
00107 jointLimitsK_spring=s.toDouble();
00108 s=file.readLine();
00109 s=file.readLine();
00110 jointLimitsB_damper=s.toDouble();
00111 s=file.readLine();
00112 s=file.readLine();
00113 jointFrictionU_c=s.toDouble();
00114 };
00115
00116 SIGEL_Simulation::SIG_SimulationParameters::SIG_SimulationParameters(QTextStream& file)
00117 {
00118 readFromFile(file);
00119 };
00120
00121 void SIGEL_Simulation::SIG_SimulationParameters::writeToFile(QTextStream& file)
00122 {
00123 file << "TIMETOSIMULATE\n";
00124 file << timeToSimulate.hour() << "\n";
00125 file << timeToSimulate.minute() << "\n";
00126 file << timeToSimulate.second() << "\n";
00127 file << timeToSimulate.msec() << "\n";
00128 file << "STEPSIZE\n";
00129 file << stepSize << "\n";
00130 file << "MAXIMALERROR\n";
00131 file << maximalError << "\n";
00132 file << "RANDOMSEED\n";
00133 file << randomSeed << "\n";
00134 file << "MAXIMALITERATIONS\n";
00135 file << maximalIterations << "\n";
00136 file << "SKIPFRAMES\n";
00137 file << skipFrames << "\n";
00138 file << "ANALYTICAL\n";
00139 if (analytical)
00140 file << 1 << "\n";
00141 else
00142 file << 0 << "\n";
00143 file << "MAXIMALCOLLISIONLOOPS\n";
00144 file << maximalCollisionLoops << "\n";
00145 file << "SOLVEMODE\n";
00146 file << (static_cast<int>(solveMode)) << "\n";
00147 file << "INTEGRATOR\n";
00148 file << (static_cast<int>(integrator)) << "\n";
00149 file << "DYNAMECHSINTEGRATOR\n";
00150 file << (static_cast<int>(dynaMechsIntegrator)) << "\n";
00151 file << "SIMULATIONLIBRARY\n";
00152 file << (static_cast<int>(simulationLibrary)) << "\n";
00153 file << "MAXIMALSOLIDITERATIONS\n";
00154 file << maximalSOLIDIterations << "\n";
00155 file << "JOINTLIMITSK_SPRING\n";
00156 file << jointLimitsK_spring << "\n";
00157 file << "JOINTLIMITSB_DAMPER\n";
00158 file << jointLimitsB_damper << "\n";
00159 file << "JOINTFRICTIONU_C\n";
00160 file << jointFrictionU_c << "\n";
00161 };
00162
00163 void SIGEL_Simulation::SIG_SimulationParameters::setTimeToSimulate(QTime newTimeToSimulate)
00164 {
00165 timeToSimulate = newTimeToSimulate;
00166 };
00167
00168 QTime SIGEL_Simulation::SIG_SimulationParameters::getTimeToSimulate() const
00169 {
00170 return timeToSimulate;
00171 };
00172
00173 void SIGEL_Simulation::SIG_SimulationParameters::setStepSize(double newStepSize)
00174 {
00175 stepSize = newStepSize;
00176 }
00177
00178 double SIGEL_Simulation::SIG_SimulationParameters::getStepSize() const
00179 {
00180 return stepSize;
00181 };
00182
00183 void SIGEL_Simulation::SIG_SimulationParameters::setJointLimitsK_spring( double newValue )
00184 {
00185 jointLimitsK_spring = newValue;
00186 };
00187
00188 double SIGEL_Simulation::SIG_SimulationParameters::getJointLimitsK_spring() const
00189 {
00190 return jointLimitsK_spring;
00191 };
00192
00193 void SIGEL_Simulation::SIG_SimulationParameters::setJointLimitsB_damper( double newValue )
00194 {
00195 jointLimitsB_damper = newValue;
00196 };
00197
00198 double SIGEL_Simulation::SIG_SimulationParameters::getJointLimitsB_damper() const
00199 {
00200 return jointLimitsB_damper;
00201 };
00202
00203 void SIGEL_Simulation::SIG_SimulationParameters::setJointFrictionU_c( double newValue )
00204 {
00205 jointFrictionU_c = newValue;
00206 };
00207
00208 double SIGEL_Simulation::SIG_SimulationParameters::getJointFrictionU_c() const
00209 {
00210 return jointFrictionU_c;
00211 };
00212
00213 void SIGEL_Simulation::SIG_SimulationParameters::setMaximalError(double newMaximalError)
00214 {
00215 maximalError = newMaximalError;
00216 };
00217
00218 double SIGEL_Simulation::SIG_SimulationParameters::getMaximalError() const
00219 {
00220 return maximalError;
00221 };
00222
00223 void SIGEL_Simulation::SIG_SimulationParameters::setRandomSeed(int newRandomSeed)
00224 {
00225 randomSeed = newRandomSeed;
00226 };
00227
00228 int SIGEL_Simulation::SIG_SimulationParameters::getRandomSeed() const
00229 {
00230 return randomSeed;
00231 };
00232
00233 void SIGEL_Simulation::SIG_SimulationParameters::setAnalytical(bool newAnalytical)
00234 {
00235 analytical=newAnalytical;
00236 };
00237
00238 bool SIGEL_Simulation::SIG_SimulationParameters::getAnalytical() const
00239 {
00240 return analytical;
00241 };
00242
00243 void SIGEL_Simulation::SIG_SimulationParameters::setMaximalIterations(int newMaximalIterations)
00244 {
00245 maximalIterations=newMaximalIterations;
00246 };
00247
00248 int SIGEL_Simulation::SIG_SimulationParameters::getMaximalIterations() const
00249 {
00250 return maximalIterations;
00251 };
00252
00253 void SIGEL_Simulation::SIG_SimulationParameters::setSkipFrames(int newSkipFrames)
00254 {
00255 skipFrames=newSkipFrames;
00256 };
00257
00258 int SIGEL_Simulation::SIG_SimulationParameters::getSkipFrames() const
00259 {
00260 return skipFrames;
00261 };
00262
00263 void SIGEL_Simulation::SIG_SimulationParameters::setMaximalCollisionLoops(int newMaximalCollisionLoops)
00264 {
00265 maximalCollisionLoops=newMaximalCollisionLoops;
00266 };
00267
00268 int SIGEL_Simulation::SIG_SimulationParameters::getMaximalCollisionLoops() const
00269 {
00270 return maximalCollisionLoops;
00271 };
00272
00273 void SIGEL_Simulation::SIG_SimulationParameters::setSolveMode(SolveModeType newSolveMode)
00274 {
00275 solveMode=newSolveMode;
00276 };
00277
00278 SIGEL_Simulation::SIG_SimulationParameters::SolveModeType SIGEL_Simulation::SIG_SimulationParameters::getSolveMode() const
00279 {
00280 return solveMode;
00281 };
00282
00283 void SIGEL_Simulation::SIG_SimulationParameters::setIntegrator(IntegratorType newIntegrator)
00284 {
00285 integrator=newIntegrator;
00286 };
00287
00288 SIGEL_Simulation::SIG_SimulationParameters::IntegratorType SIGEL_Simulation::SIG_SimulationParameters::getIntegrator() const
00289 {
00290 return integrator;
00291 };
00292
00293 void SIGEL_Simulation::SIG_SimulationParameters::setDynaMechsIntegrator( DynaMechsIntegrator newDynaMechsIntegrator )
00294 {
00295 dynaMechsIntegrator = newDynaMechsIntegrator;
00296 };
00297
00298 SIGEL_Simulation::SIG_SimulationParameters::DynaMechsIntegrator SIGEL_Simulation::SIG_SimulationParameters::getDynaMechsIntegrator() const
00299 {
00300 return dynaMechsIntegrator;
00301 };
00302
00303 void SIGEL_Simulation::SIG_SimulationParameters::setSimulationLibrary( SimulationLibrary newSimulationLibrary )
00304 {
00305 simulationLibrary = newSimulationLibrary;
00306 };
00307
00308 SIGEL_Simulation::SIG_SimulationParameters::SimulationLibrary SIGEL_Simulation::SIG_SimulationParameters::getSimulationLibrary() const
00309 {
00310 return simulationLibrary;
00311 };
00312
00313 void SIGEL_Simulation::SIG_SimulationParameters::setMaximalSOLIDIterations(int newMaximalSOLIDIterations)
00314 {
00315 maximalSOLIDIterations=newMaximalSOLIDIterations;
00316 };
00317
00318 int SIGEL_Simulation::SIG_SimulationParameters::getMaximalSOLIDIterations() const
00319 {
00320 return maximalSOLIDIterations;
00321 };
00322