added ASMT api example runSinglePendulum

This commit is contained in:
Aik-Siong Koh
2023-09-28 15:51:02 -06:00
parent 81513500ab
commit b53cdac5ca
37 changed files with 845 additions and 128 deletions

View File

@@ -49,6 +49,141 @@ void CADSystem::logString(double value)
{
}
void CADSystem::runOndselSinglePendulum()
{
//Double pendulum with easy input numbers for exact port from Smalltalk
//GEOAssembly calcCharacteristicDimensions must set mbdUnits to unity.
std::cout << "runOndselSinglePendulum" << std::endl;
auto& TheSystem = mbdSystem;
TheSystem->clear();
std::string name = "TheSystem";
TheSystem->name = name;
std::cout << "TheSystem->name " << TheSystem->name << std::endl;
auto& systemSolver = TheSystem->systemSolver;
systemSolver->errorTolPosKine = 1.0e-6;
systemSolver->errorTolAccKine = 1.0e-6;
systemSolver->iterMaxPosKine = 25;
systemSolver->iterMaxAccKine = 25;
systemSolver->tstart = 0.0;
systemSolver->tend = 0.04;
systemSolver->hmin = 1.0e-9;
systemSolver->hmax = 1.0;
systemSolver->hout = 0.04;
systemSolver->corAbsTol = 1.0e-6;
systemSolver->corRelTol = 1.0e-6;
systemSolver->intAbsTol = 1.0e-6;
systemSolver->intRelTol = 1.0e-6;
systemSolver->iterMaxDyn = 4;
systemSolver->orderMax = 5;
systemSolver->translationLimit = 1.0e10;
systemSolver->rotationLimit = 0.5;
std::string str;
FColDsptr qX, qE, qXdot, omeOpO, qXddot, alpOpO;
FColDsptr rpmp;
FMatDsptr aAap, aApm;
FRowDsptr fullRow;
//
auto assembly1 = CREATE<Part>::With("/Assembly1");
std::cout << "assembly1->name " << assembly1->name << std::endl;
assembly1->m = 0.0;
assembly1->aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 0, 0, 0 });
qX = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
aAap = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
assembly1->setqX(qX);
assembly1->setaAap(aAap);
qXdot = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
omeOpO = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
assembly1->setqXdot(qXdot);
assembly1->setomeOpO(omeOpO);
TheSystem->addPart(assembly1);
{
auto& partFrame = assembly1->partFrame;
auto marker2 = CREATE<MarkerFrame>::With("/Assembly1/Marker2");
rpmp = std::make_shared<FullColumn<double>>(ListD{ 0.0, 0.0, 0.0 });
marker2->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
marker2->setaApm(aApm);
partFrame->addMarkerFrame(marker2);
//
auto marker1 = CREATE<MarkerFrame>::With("/Assembly1/Marker1");
rpmp = std::make_shared<FullColumn<double>>(ListD{ 0.0, 3.0, 0.0 });
marker1->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 0, 1 },
{ 0, -1, 0 }
});
marker1->setaApm(aApm);
partFrame->addMarkerFrame(marker1);
}
assembly1->asFixed();
//
auto crankPart1 = CREATE<Part>::With("/Assembly1/Part1");
std::cout << "crankPart1->name " << crankPart1->name << std::endl;
crankPart1->m = 1.0;
crankPart1->aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 1, 1, 1 });
qX = std::make_shared<FullColumn<double>>(ListD{ 0.4, 0.0, -0.05 });
aAap = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
crankPart1->setqX(qX);
crankPart1->setaAap(aAap);
qXdot = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
omeOpO = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
crankPart1->setqXdot(qXdot);
crankPart1->setomeOpO(omeOpO);
TheSystem->addPart(crankPart1);
{
auto& partFrame = crankPart1->partFrame;
auto marker1 = CREATE<MarkerFrame>::With("/Assembly1/Part1/Marker1");
rpmp = std::make_shared<FullColumn<double>>(ListD{ -0.4, 0.0, 0.05 });
marker1->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
marker1->setaApm(aApm);
partFrame->addMarkerFrame(marker1);
//
auto marker2 = CREATE<MarkerFrame>::With("/Assembly1/Part1/Marker2");
rpmp = std::make_shared<FullColumn<double>>(ListD{ 0.4, 0.0, 0.05 });
marker2->setrpmp(rpmp);
aApm = std::make_shared<FullMatrix<double>>(ListListD{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
});
marker2->setaApm(aApm);
partFrame->addMarkerFrame(marker2);
}
//
auto revJoint1 = CREATE<RevoluteJoint>::With("/Assembly1/Joint1");
std::cout << "revJoint1->name " << revJoint1->name << std::endl;
revJoint1->connectsItoJ(assembly1->partFrame->endFrame("/Assembly1/Marker2"), crankPart1->partFrame->endFrame("/Assembly1/Part1/Marker1"));
TheSystem->addJoint(revJoint1);
//
auto rotMotion1 = CREATE<ZRotation>::With("/Assembly1/Motion1");
rotMotion1->connectsItoJ(assembly1->partFrame->endFrame("/Assembly1/Marker2"), crankPart1->partFrame->endFrame("/Assembly1/Part1/Marker1"));
std::cout << "rotMotion1->name " << rotMotion1->name << std::endl;
rotMotion1->phiBlk = std::make_shared<Constant>(1.0);
std::cout << "rotMotion1->phiBlk " << *(rotMotion1->phiBlk) << std::endl;
TheSystem->addJoint(rotMotion1);
//
TheSystem->runKINEMATIC(TheSystem);
}
void CADSystem::runOndselDoublePendulum()
{
//Double pendulum with easy input numbers for exact port from Smalltalk
@@ -65,7 +200,7 @@ void CADSystem::runOndselDoublePendulum()
systemSolver->iterMaxPosKine = 25;
systemSolver->iterMaxAccKine = 25;
systemSolver->tstart = 0.0;
systemSolver->tend = 0.0;
systemSolver->tend = 0.04;
systemSolver->hmin = 1.0e-9;
systemSolver->hmax = 1.0;
systemSolver->hout = 0.04;