Simplify syntax.
This commit is contained in:
@@ -43,6 +43,100 @@
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
|
||||
void MbD::ASMTAssembly::runSinglePendulumSimplified()
|
||||
{
|
||||
auto assembly = CREATE<ASMTAssembly>::With();
|
||||
|
||||
assembly->setNotes("");
|
||||
assembly->setName("Assembly1");
|
||||
assembly->setPosition3D(0, 0, 0);
|
||||
assembly->setRotationMatrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1);
|
||||
assembly->setVelocity3D(0, 0, 0);
|
||||
assembly->setOmega3D(0, 0, 0);
|
||||
|
||||
auto massMarker = CREATE<ASMTPrincipalMassMarker>::With();
|
||||
massMarker->setMass(0.0);
|
||||
massMarker->setDensity(0.0);
|
||||
massMarker->setMomentOfInertias(0, 0, 0);
|
||||
massMarker->setPosition3D(0, 0, 0);
|
||||
massMarker->setRotationMatrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1);
|
||||
assembly->setPrincipalMassMarker(massMarker);
|
||||
|
||||
auto mkr = CREATE<ASMTMarker>::With();
|
||||
mkr->setName("Marker1");
|
||||
mkr->setPosition3D(0, 0, 0);
|
||||
massMarker->setRotationMatrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1);
|
||||
assembly->addMarker(mkr);
|
||||
|
||||
auto part = CREATE<ASMTPart>::With();
|
||||
part->setName("Part1");
|
||||
part->setPosition3D(-0.1, -0.1, -0.1);
|
||||
part->setRotationMatrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1);
|
||||
part->setVelocity3D(0, 0, 0);
|
||||
part->setOmega3D(0, 0, 0);
|
||||
assembly->addPart(part);
|
||||
|
||||
massMarker = CREATE<ASMTPrincipalMassMarker>::With();
|
||||
massMarker->setMass(0.2);
|
||||
massMarker->setDensity(10.0);
|
||||
massMarker->setMomentOfInertias(8.3333333333333e-4, 0.016833333333333, 0.017333333333333);
|
||||
massMarker->setPosition3D(0.5, 0.1, 0.05);
|
||||
massMarker->setRotationMatrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1);
|
||||
part->setPrincipalMassMarker(massMarker);
|
||||
|
||||
mkr = CREATE<ASMTMarker>::With();
|
||||
mkr->setName("Marker1");
|
||||
mkr->setPosition3D(0.1, 0.1, 0.1);
|
||||
mkr->setRotationMatrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1);
|
||||
part->addMarker(mkr);
|
||||
|
||||
auto joint = CREATE<ASMTRevoluteJoint>::With();
|
||||
joint->setName("Joint1");
|
||||
joint->setMarkerI("/Assembly1/Marker1");
|
||||
joint->setMarkerJ("/Assembly1/Part1/Marker1");
|
||||
assembly->addJoint(joint);
|
||||
|
||||
auto motion = CREATE<ASMTRotationalMotion>::With();
|
||||
motion->setName("Motion1");
|
||||
motion->setMotionJoint("/Assembly1/Joint1");
|
||||
motion->setRotationZ("0.0");
|
||||
assembly->addMotion(motion);
|
||||
|
||||
auto constantGravity = CREATE<ASMTConstantGravity>::With();
|
||||
constantGravity->setg(0.0, 0.0, 0.0);
|
||||
assembly->setConstantGravity(constantGravity);
|
||||
|
||||
auto simulationParameters = CREATE<ASMTSimulationParameters>::With();
|
||||
simulationParameters->settstart(0.0);
|
||||
simulationParameters->settend(0.0); //tstart == tend Initial Conditions only.
|
||||
simulationParameters->sethmin(1.0e-9);
|
||||
simulationParameters->sethmax(1.0);
|
||||
simulationParameters->sethout(0.04);
|
||||
simulationParameters->seterrorTol(1.0e-6);
|
||||
assembly->setSimulationParameters(simulationParameters);
|
||||
|
||||
assembly->runKINEMATIC();
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::runSinglePendulum()
|
||||
{
|
||||
auto assembly = CREATE<ASMTAssembly>::With();
|
||||
@@ -205,7 +299,7 @@ ASMTAssembly* MbD::ASMTAssembly::root()
|
||||
return this;
|
||||
}
|
||||
|
||||
void MbD::ASMTAssembly::setNotes(std::string& str)
|
||||
void MbD::ASMTAssembly::setNotes(std::string str)
|
||||
{
|
||||
notes = str;
|
||||
}
|
||||
|
||||
@@ -35,11 +35,12 @@ namespace MbD {
|
||||
{
|
||||
//
|
||||
public:
|
||||
static void runSinglePendulumSimplified();
|
||||
static void runSinglePendulum();
|
||||
static void runFile(const char* chars);
|
||||
void initialize() override;
|
||||
ASMTAssembly* root() override;
|
||||
void setNotes(std::string& str);
|
||||
void setNotes(std::string str);
|
||||
void parseASMT(std::vector<std::string>& lines) override;
|
||||
void readNotes(std::vector<std::string>& lines);
|
||||
void readParts(std::vector<std::string>& lines);
|
||||
|
||||
@@ -33,3 +33,8 @@ void MbD::ASMTConstantGravity::setg(FColDsptr gravity)
|
||||
{
|
||||
g = gravity;
|
||||
}
|
||||
|
||||
void MbD::ASMTConstantGravity::setg(double a, double b, double c)
|
||||
{
|
||||
g = std::make_shared<FullColumn<double>>(ListD{ a, b, c });
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace MbD {
|
||||
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
|
||||
void setg(FColDsptr g);
|
||||
|
||||
void setg(double a, double b, double c);
|
||||
|
||||
FColDsptr g;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void MbD::ASMTItem::initialize()
|
||||
{
|
||||
}
|
||||
|
||||
void MbD::ASMTItem::setName(std::string& str)
|
||||
void MbD::ASMTItem::setName(std::string str)
|
||||
{
|
||||
name = str;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace MbD {
|
||||
virtual std::shared_ptr<ASMTSpatialContainer> part();
|
||||
|
||||
virtual void initialize();
|
||||
void setName(std::string& str);
|
||||
void setName(std::string str);
|
||||
virtual void parseASMT(std::vector<std::string>& lines);
|
||||
FRowDsptr readRowOfDoubles(std::string& line);
|
||||
FColDsptr readColumnOfDoubles(std::string& line);
|
||||
|
||||
@@ -18,12 +18,12 @@ void MbD::ASMTItemIJ::initialize()
|
||||
tzs = std::make_shared<FullRow<double>>();
|
||||
}
|
||||
|
||||
void MbD::ASMTItemIJ::setMarkerI(std::string& mkrI)
|
||||
void MbD::ASMTItemIJ::setMarkerI(std::string mkrI)
|
||||
{
|
||||
markerI = mkrI;
|
||||
}
|
||||
|
||||
void MbD::ASMTItemIJ::setMarkerJ(std::string& mkrJ)
|
||||
void MbD::ASMTItemIJ::setMarkerJ(std::string mkrJ)
|
||||
{
|
||||
markerJ = mkrJ;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace MbD {
|
||||
//
|
||||
public:
|
||||
void initialize() override;
|
||||
void setMarkerI(std::string& mkrI);
|
||||
void setMarkerJ(std::string& mkrJ);
|
||||
void setMarkerI(std::string mkrI);
|
||||
void setMarkerJ(std::string mkrJ);
|
||||
void readMarkerI(std::vector<std::string>& lines);
|
||||
void readMarkerJ(std::vector<std::string>& lines);
|
||||
void readFXonIs(std::vector<std::string>& lines);
|
||||
|
||||
@@ -66,3 +66,9 @@ void MbD::ASMTPrincipalMassMarker::setMomentOfInertias(DiagMatDsptr mat)
|
||||
{
|
||||
momentOfInertias = mat;
|
||||
}
|
||||
|
||||
// Overloads to simplify syntax.
|
||||
void MbD::ASMTPrincipalMassMarker::setMomentOfInertias(double a, double b, double c)
|
||||
{
|
||||
momentOfInertias = std::make_shared<DiagonalMatrix<double>>(ListD{ a, b, c });
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ namespace MbD {
|
||||
void setDensity(double density);
|
||||
void setMomentOfInertias(DiagMatDsptr momentOfInertias);
|
||||
|
||||
// Overloads to simplify syntax.
|
||||
void setMomentOfInertias(double a, double b, double c);
|
||||
|
||||
double mass, density;
|
||||
DiagMatDsptr momentOfInertias;
|
||||
|
||||
|
||||
@@ -67,12 +67,12 @@ std::shared_ptr<Joint> MbD::ASMTRotationalMotion::mbdClassNew()
|
||||
return CREATE<ZRotation>::With();
|
||||
}
|
||||
|
||||
void MbD::ASMTRotationalMotion::setMotionJoint(std::string& str)
|
||||
void MbD::ASMTRotationalMotion::setMotionJoint(std::string str)
|
||||
{
|
||||
motionJoint = str;
|
||||
}
|
||||
|
||||
void MbD::ASMTRotationalMotion::setRotationZ(std::string& rotZ)
|
||||
void MbD::ASMTRotationalMotion::setRotationZ(std::string rotZ)
|
||||
{
|
||||
rotationZ = rotZ;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace MbD {
|
||||
void initMarkers() override;
|
||||
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
|
||||
std::shared_ptr<Joint> mbdClassNew() override;
|
||||
void setMotionJoint(std::string& motionJoint);
|
||||
void setRotationZ(std::string& rotZ);
|
||||
void setMotionJoint(std::string motionJoint);
|
||||
void setRotationZ(std::string rotZ);
|
||||
|
||||
std::string motionJoint, rotationZ;
|
||||
};
|
||||
|
||||
@@ -85,3 +85,31 @@ void MbD::ASMTSpatialItem::readOmega3D(std::vector<std::string>& lines)
|
||||
}
|
||||
lines.erase(lines.begin());
|
||||
}
|
||||
|
||||
|
||||
// Overloads to simplify syntax.
|
||||
void MbD::ASMTSpatialItem::setPosition3D(double a, double b, double c)
|
||||
{
|
||||
position3D = std::make_shared<FullColumn<double>>(ListD{ a, b, c });
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialItem::setVelocity3D(double a, double b, double c)
|
||||
{
|
||||
velocity3D = std::make_shared<FullColumn<double>>(ListD{ a, b, c });
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialItem::setOmega3D(double a, double b, double c)
|
||||
{
|
||||
omega3D = std::make_shared<FullColumn<double>>(ListD{ a, b, c });
|
||||
}
|
||||
|
||||
void MbD::ASMTSpatialItem::setRotationMatrix(double v11, double v12, double v13,
|
||||
double v21, double v22, double v23,
|
||||
double v31, double v32, double v33)
|
||||
{
|
||||
rotationMatrix = std::make_shared<FullMatrix<double>>(ListListD{
|
||||
{ v11, v12, v13 },
|
||||
{ v21, v22, v23 },
|
||||
{ v31, v32, v33 }
|
||||
});
|
||||
}
|
||||
@@ -33,6 +33,13 @@ namespace MbD {
|
||||
{ 0, 0, 1 }
|
||||
});
|
||||
|
||||
// Overloads to simplify syntax.
|
||||
void setPosition3D(double a, double b, double c);
|
||||
void setVelocity3D(double a, double b, double c);
|
||||
void setOmega3D(double a, double b, double c);
|
||||
void setRotationMatrix(double v11, double v12, double v13,
|
||||
double v21, double v22, double v23,
|
||||
double v31, double v32, double v33);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user