diff --git a/.gitignore b/.gitignore index fdeeb7b..774534a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ *.app .vs -x64/ \ No newline at end of file +x64/ +*.bak \ No newline at end of file diff --git a/MbDCode/AbsConstraint.cpp b/MbDCode/AbsConstraint.cpp index adb9408..030db5f 100644 --- a/MbDCode/AbsConstraint.cpp +++ b/MbDCode/AbsConstraint.cpp @@ -12,6 +12,11 @@ AbsConstraint::AbsConstraint(const char* str) : Constraint(str) initialize(); } +MbD::AbsConstraint::AbsConstraint(int i) +{ + axis = i; +} + void AbsConstraint::initialize() { axis = 0; diff --git a/MbDCode/AbsConstraint.h b/MbDCode/AbsConstraint.h index 001f811..29551c7 100644 --- a/MbDCode/AbsConstraint.h +++ b/MbDCode/AbsConstraint.h @@ -7,6 +7,7 @@ namespace MbD { public: AbsConstraint(); AbsConstraint(const char* str); + AbsConstraint(int axis); void initialize(); int axis; int iqXminusOnePlusAxis; diff --git a/MbDCode/BasicUserFunction.cpp b/MbDCode/BasicUserFunction.cpp new file mode 100644 index 0000000..febfc13 --- /dev/null +++ b/MbDCode/BasicUserFunction.cpp @@ -0,0 +1 @@ +#include "BasicUserFunction.h" diff --git a/MbDCode/BasicUserFunction.h b/MbDCode/BasicUserFunction.h new file mode 100644 index 0000000..17c4b7b --- /dev/null +++ b/MbDCode/BasicUserFunction.h @@ -0,0 +1,15 @@ +#pragma once +#include + +#include "UserFunction.h" + +namespace MbD { + class BasicUserFunction : public UserFunction + { + //funcText myUnit units + public: + std::string funcText; + double myUnit; + }; +} + diff --git a/MbDCode/CartesianFrame.cpp b/MbDCode/CartesianFrame.cpp index 6199931..8b1a632 100644 --- a/MbDCode/CartesianFrame.cpp +++ b/MbDCode/CartesianFrame.cpp @@ -12,4 +12,5 @@ CartesianFrame::CartesianFrame(const char* str) : Item(str) void CartesianFrame::initialize() { + Item::initialize(); } diff --git a/MbDCode/Constant.cpp b/MbDCode/Constant.cpp new file mode 100644 index 0000000..28a36f7 --- /dev/null +++ b/MbDCode/Constant.cpp @@ -0,0 +1,11 @@ +#include "Constant.h" + +using namespace MbD; + +Constant::Constant() +{ +} + +Constant::Constant(double val) : Variable(val) +{ +} diff --git a/MbDCode/Constant.h b/MbDCode/Constant.h new file mode 100644 index 0000000..b7f98b2 --- /dev/null +++ b/MbDCode/Constant.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Variable.h" + +namespace MbD { + class Constant : public Variable + { + public: + Constant(); + Constant(double val); + }; +} + diff --git a/MbDCode/Constraint.h b/MbDCode/Constraint.h index 71b89f2..eef8945 100644 --- a/MbDCode/Constraint.h +++ b/MbDCode/Constraint.h @@ -15,9 +15,9 @@ namespace MbD { Item* getOwner(); int iG; - double aG; //Constraint function - double lam; //Lambda is Lagrange Multiplier - Item* owner; //A Joint or PartFrame owns the constraint + double aG; //Constraint function + double lam; //Lambda is Lagrange Multiplier + Item* owner; //A Joint or PartFrame owns the constraint }; } diff --git a/MbDCode/ConstraintIJ.cpp b/MbDCode/ConstraintIJ.cpp new file mode 100644 index 0000000..f1a8c29 --- /dev/null +++ b/MbDCode/ConstraintIJ.cpp @@ -0,0 +1,9 @@ +#include "ConstraintIJ.h" +#include "EndFramec.h" + +using namespace MbD; + +MbD::ConstraintIJ::ConstraintIJ(std::shared_ptr frmi, std::shared_ptr frmj) : frmI(frmi), frmJ(frmj) +{ + aConstant = 0.0; +} diff --git a/MbDCode/ConstraintIJ.h b/MbDCode/ConstraintIJ.h new file mode 100644 index 0000000..cdff99a --- /dev/null +++ b/MbDCode/ConstraintIJ.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Constraint.h" +#include "EndFramec.h" + +namespace MbD { + class ConstraintIJ : public Constraint + { + //frmI frmJ aConstant + public: + ConstraintIJ(std::shared_ptr frmi, std::shared_ptr frmj); + + std::shared_ptr frmI, frmJ; + double aConstant; + }; +} + diff --git a/MbDCode/DirectionCosineConstraintIJ.cpp b/MbDCode/DirectionCosineConstraintIJ.cpp new file mode 100644 index 0000000..9d3c0dc --- /dev/null +++ b/MbDCode/DirectionCosineConstraintIJ.cpp @@ -0,0 +1,10 @@ +#include "DirectionCosineConstraintIJ.h" +#include "EndFramec.h" + +using namespace MbD; + +DirectionCosineConstraintIJ::DirectionCosineConstraintIJ(std::shared_ptr frmi, std::shared_ptr frmj, int axisi, int axisj) : + ConstraintIJ(frmI, frmJ), axisI(axisi), axisJ(axisj) +{ + aAijIeJe = std::make_shared(frmI, frmJ, axisI, axisJ); +} diff --git a/MbDCode/DirectionCosineConstraintIJ.h b/MbDCode/DirectionCosineConstraintIJ.h new file mode 100644 index 0000000..7a80d11 --- /dev/null +++ b/MbDCode/DirectionCosineConstraintIJ.h @@ -0,0 +1,18 @@ +#pragma once + +#include "ConstraintIJ.h" +#include "DirectionCosineIecJec.h" + +namespace MbD { + class DirectionCosineConstraintIJ : public ConstraintIJ + { + //axisI axisJ aAijIeJe + public: + // self owns : (MbDDirectionCosineConstraintIJ withFrmI : frmI frmJ : frmJ axisI : 2 axisJ : 1). + DirectionCosineConstraintIJ(std::shared_ptr frmI, std::shared_ptr frmJ, int axisI, int axisJ); + + int axisI, axisJ; + std::shared_ptr aAijIeJe; + }; +} + diff --git a/MbDCode/DirectionCosineIecJec.cpp b/MbDCode/DirectionCosineIecJec.cpp new file mode 100644 index 0000000..573218d --- /dev/null +++ b/MbDCode/DirectionCosineIecJec.cpp @@ -0,0 +1,18 @@ +#include + +#include "DirectionCosineIecJec.h" +#include "FullColumn.h" + +using namespace MbD; + +MbD::DirectionCosineIecJec::DirectionCosineIecJec() +{ +} + +MbD::DirectionCosineIecJec::DirectionCosineIecJec(std::shared_ptr frmi, std::shared_ptr frmj, int axisi, int axisj) : + KinematicIeJe(frmi, frmj), axisI(axisi), axisJ(axisj) +{ + aAijIeJe = 0.0; + aAjOIe = std::make_shared>(3); + aAjOJe = std::make_shared>(3); +} diff --git a/MbDCode/DirectionCosineIecJec.h b/MbDCode/DirectionCosineIecJec.h new file mode 100644 index 0000000..5a84bcb --- /dev/null +++ b/MbDCode/DirectionCosineIecJec.h @@ -0,0 +1,21 @@ +#pragma once +#include + +#include "KinematicIeJe.h" +//#include "EndFramec.h" +#include "FullColumn.h" + +namespace MbD { + class DirectionCosineIecJec : public KinematicIeJe + { + //aAijIeJe axisI axisJ aAjOIe aAjOJe + public: + DirectionCosineIecJec(); + DirectionCosineIecJec(std::shared_ptr frmI, std::shared_ptr frmJ, int axisI, int axisJ); + + int axisI, axisJ; + double aAijIeJe; + std::shared_ptr> aAjOIe, aAjOJe; + }; +} + diff --git a/MbDCode/DirectionCosineIeqcJec.cpp b/MbDCode/DirectionCosineIeqcJec.cpp new file mode 100644 index 0000000..ead28b8 --- /dev/null +++ b/MbDCode/DirectionCosineIeqcJec.cpp @@ -0,0 +1,14 @@ +#include "DirectionCosineIeqcJec.h" + +using namespace MbD; + +MbD::DirectionCosineIeqcJec::DirectionCosineIeqcJec() +{ + initialize(); +} + +void MbD::DirectionCosineIeqcJec::initialize() +{ + pAijIeJepEI = std::make_shared>(4); + ppAijIeJepEIpEI = std::make_shared>(4, 4); +} diff --git a/MbDCode/DirectionCosineIeqcJec.h b/MbDCode/DirectionCosineIeqcJec.h new file mode 100644 index 0000000..ae14cbc --- /dev/null +++ b/MbDCode/DirectionCosineIeqcJec.h @@ -0,0 +1,19 @@ +#pragma once + +#include "DirectionCosineIecJec.h" + +namespace MbD { + class DirectionCosineIeqcJec : public DirectionCosineIecJec + { + //pAijIeJepEI ppAijIeJepEIpEI pAjOIepEIT ppAjOIepEIpEI + public: + DirectionCosineIeqcJec(); + void initialize(); + + FRowDsptr pAijIeJepEI; + FMatDsptr ppAijIeJepEIpEI; + FMatDsptr pAjOIepEIT; + std::shared_ptr>> ppAjOIepEIpEI; + }; +} + diff --git a/MbDCode/DirectionCosineIeqcJeqc.cpp b/MbDCode/DirectionCosineIeqcJeqc.cpp new file mode 100644 index 0000000..ba59a9c --- /dev/null +++ b/MbDCode/DirectionCosineIeqcJeqc.cpp @@ -0,0 +1,15 @@ +#include "DirectionCosineIeqcJeqc.h" + +using namespace MbD; + +MbD::DirectionCosineIeqcJeqc::DirectionCosineIeqcJeqc() +{ + initialize(); +} + +void MbD::DirectionCosineIeqcJeqc::initialize() +{ + pAijIeJepEJ = std::make_shared>(4); + ppAijIeJepEIpEJ = std::make_shared>(4, 4); + ppAijIeJepEJpEJ = std::make_shared>(4, 4); +} diff --git a/MbDCode/DirectionCosineIeqcJeqc.h b/MbDCode/DirectionCosineIeqcJeqc.h new file mode 100644 index 0000000..c17e021 --- /dev/null +++ b/MbDCode/DirectionCosineIeqcJeqc.h @@ -0,0 +1,21 @@ +#pragma once + +#include "DirectionCosineIeqcJec.h" + +namespace MbD { + class DirectionCosineIeqcJeqc : public DirectionCosineIeqcJec + { + //pAijIeJepEJ ppAijIeJepEIpEJ ppAijIeJepEJpEJ pAjOJepEJT ppAjOJepEJpEJ + public: + DirectionCosineIeqcJeqc(); + void initialize(); + + FRowDsptr pAijIeJepEJ; + FMatDsptr ppAijIeJepEIpEJ; + FMatDsptr ppAijIeJepEJpEJ; + FMatDsptr pAjOJepEJT; + std::shared_ptr>> ppAjOJepEJpEJ; + + }; +} + diff --git a/MbDCode/DirectionCosineIeqctJeqc.cpp b/MbDCode/DirectionCosineIeqctJeqc.cpp new file mode 100644 index 0000000..de992ec --- /dev/null +++ b/MbDCode/DirectionCosineIeqctJeqc.cpp @@ -0,0 +1,14 @@ +#include "DirectionCosineIeqctJeqc.h" + +using namespace MbD; + +MbD::DirectionCosineIeqctJeqc::DirectionCosineIeqctJeqc() +{ + initialize(); +} + +void MbD::DirectionCosineIeqctJeqc::initialize() +{ + ppAijIeJepEIpt = std::make_shared>(4); + ppAijIeJepEJpt = std::make_shared>(4); +} diff --git a/MbDCode/DirectionCosineIeqctJeqc.h b/MbDCode/DirectionCosineIeqctJeqc.h new file mode 100644 index 0000000..c730035 --- /dev/null +++ b/MbDCode/DirectionCosineIeqctJeqc.h @@ -0,0 +1,19 @@ +#pragma once + +#include "DirectionCosineIeqcJeqc.h" + +namespace MbD { + class DirectionCosineIeqctJeqc : public DirectionCosineIeqcJeqc + { + //pAijIeJept ppAijIeJepEIpt ppAijIeJepEJpt ppAijIeJeptpt + public: + DirectionCosineIeqctJeqc(); + void initialize(); + + double pAijIeJept; + FRowDsptr ppAijIeJepEIpt; + FRowDsptr ppAijIeJepEJpt; + double ppAijIeJeptpt; + }; +} + diff --git a/MbDCode/EndFramec.cpp b/MbDCode/EndFramec.cpp index bffca47..dec4843 100644 --- a/MbDCode/EndFramec.cpp +++ b/MbDCode/EndFramec.cpp @@ -1,3 +1,5 @@ +#include + #include "EndFramec.h" using namespace MbD; @@ -12,9 +14,27 @@ EndFramec::EndFramec(const char* str) : CartesianFrame(str) { void EndFramec::initialize() { + CartesianFrame::initialize(); } void EndFramec::setMarkerFrame(MarkerFrame* markerFrm) { markerFrame = markerFrm; } + +MarkerFrame* EndFramec::getMarkerFrame() +{ + return markerFrame; +} + +void EndFramec::initializeLocally() +{ +} + +void EndFramec::initializeGlobally() +{ +} + +void MbD::EndFramec::EndFrameqctFrom(std::shared_ptr& newFrmI) +{ +} diff --git a/MbDCode/EndFramec.h b/MbDCode/EndFramec.h index 44f3623..f384de6 100644 --- a/MbDCode/EndFramec.h +++ b/MbDCode/EndFramec.h @@ -15,10 +15,14 @@ namespace MbD { EndFramec(const char* str); void initialize(); void setMarkerFrame(MarkerFrame* markerFrm); + MarkerFrame* getMarkerFrame(); + void initializeLocally() override; + void initializeGlobally() override; + virtual void EndFrameqctFrom(std::shared_ptr& frm); MarkerFrame* markerFrame; - FullColDptr rOeO = std::make_shared>(3); - FullMatDptr aAOe = std::make_shared>(3, 3); + FColDsptr rOeO = std::make_shared>(3); + FMatDsptr aAOe = std::make_shared>(3, 3); }; } diff --git a/MbDCode/EndFrameqc.cpp b/MbDCode/EndFrameqc.cpp index 4e8dab5..9be88f3 100644 --- a/MbDCode/EndFrameqc.cpp +++ b/MbDCode/EndFrameqc.cpp @@ -1,4 +1,7 @@ +#include + #include "EndFrameqc.h" +#include "EndFrameqct.h" using namespace MbD; @@ -12,4 +15,26 @@ EndFrameqc::EndFrameqc(const char* str) : EndFramec(str) { void EndFrameqc::initialize() { + EndFramec::initialize(); + prOeOpE = std::make_unique>(3, 4); + pprOeOpEpE = std::make_unique>>>(4, 4); + pAOepE = std::make_unique>>>(4); + ppAOepEpE = std::make_unique>>>(4, 4); +} + +void EndFrameqc::initializeLocally() +{ +} + +void EndFrameqc::initializeGlobally() +{ +} + +void MbD::EndFrameqc::EndFrameqctFrom(std::shared_ptr& frm) +{ + std::shared_ptr newFrm; + newFrm = std::make_shared(frm->getName().c_str()); + newFrm->setMarkerFrame(frm->getMarkerFrame()); + //frm.swap(newFrm); + std::swap(*(frm.get()), *(newFrm.get())); } diff --git a/MbDCode/EndFrameqc.h b/MbDCode/EndFrameqc.h index 524b2f5..a2e4680 100644 --- a/MbDCode/EndFrameqc.h +++ b/MbDCode/EndFrameqc.h @@ -13,13 +13,14 @@ namespace MbD { EndFrameqc(); EndFrameqc(const char* str); void initialize(); - FullMatDptr prOeOpE = std::make_shared>(3, 4); - //std::shared_ptr>>> pprOeOpEpE = std::make_shared>>>(3, 4); - std::shared_ptr>>> pAOepE = std::make_shared>>>(4); - //std::shared_ptr>>> ppAOepEpE = std::make_shared>>>(4, 4); - //FullMatrix>* pprOeOpEpE1 = new FullMatrix>(3, 4); - //FullColumn>* pAOepE1 = new FullColumn>(4); - //FullMatrix>* ppAOepEpE1 = new FullMatrix>(4, 4); + void initializeLocally() override; + void initializeGlobally() override; + void EndFrameqctFrom(std::shared_ptr& frm) override; + + FMatDuptr prOeOpE; + std::unique_ptr>>> pprOeOpEpE; + std::unique_ptr>>> pAOepE; + FMatFMatDuptr ppAOepEpE; }; } diff --git a/MbDCode/EndFrameqct.cpp b/MbDCode/EndFrameqct.cpp index 2398841..ee0a8b8 100644 --- a/MbDCode/EndFrameqct.cpp +++ b/MbDCode/EndFrameqct.cpp @@ -1 +1,45 @@ #include "EndFrameqct.h" + +using namespace MbD; + +EndFrameqct::EndFrameqct() { + initialize(); +} + +EndFrameqct::EndFrameqct(const char* str) : EndFrameqc(str) { + initialize(); +} + +void EndFrameqct::initialize() +{ + EndFrameqc::initialize(); + rmem = std::make_unique>(3); + prmempt = std::make_unique>(3); + pprmemptpt = std::make_unique>(3); + aAme = std::make_unique>(3, 3); + pAmept = std::make_unique>(3, 3); + ppAmeptpt = std::make_unique>(3, 3); + pprOeOpEpt = std::make_unique>(3, 4); + pprOeOptpt = std::make_unique>(3); + ppAOepEpt = std::make_unique>>(4); + ppAOeptpt = std::make_unique>(3, 3); +} + +void EndFrameqct::initializeLocally() +{ + //rmemBlks == nil + // ifTrue : + //[rmem zeroSelf. + // prmempt zeroSelf. + // pprmemptpt zeroSelf] . + // phiThePsiBlks == nil + // ifTrue : + //[aAme identity. + // pAmept zeroSelf. + // ppAmeptpt zeroSelf] +} + +void EndFrameqct::initializeGlobally() +{ + +} diff --git a/MbDCode/EndFrameqct.h b/MbDCode/EndFrameqct.h index 4f12da6..b1c9c30 100644 --- a/MbDCode/EndFrameqct.h +++ b/MbDCode/EndFrameqct.h @@ -1,15 +1,26 @@ #pragma once #include "EndFrameqc.h" +#include "Variable.h" namespace MbD { - class EndFrameqct : public EndFrameqc - { - //time rmemBlks prmemptBlks pprmemptptBlks phiThePsiBlks pPhiThePsiptBlks ppPhiThePsiptptBlks - //rmem prmempt pprmemptpt aAme pAmept ppAmeptpt prOeOpt pprOeOpEpt pprOeOptpt pAOept ppAOepEpt ppAOeptpt - public: - double time; - FullColDptr rmem, prmempt, pprmemptpt; - FullMatDptr aAme, pAmept, ppAmeptpt; - }; + class EndFrameqct : public EndFrameqc + { + //time rmemBlks prmemptBlks pprmemptptBlks phiThePsiBlks pPhiThePsiptBlks ppPhiThePsiptptBlks + //rmem prmempt pprmemptpt aAme pAmept ppAmeptpt prOeOpt pprOeOpEpt pprOeOptpt pAOept ppAOepEpt ppAOeptpt + public: + EndFrameqct(); + EndFrameqct(const char* str); + void initialize(); + void initializeLocally() override; + void initializeGlobally() override; + + double time; + std::shared_ptr>> rmemBlks; + std::shared_ptr>> phiThePsiBlks; + FColDuptr rmem, prmempt, pprmemptpt, pprOeOptpt; + FMatDuptr aAme, pAmept, ppAmeptpt, ppAOeptpt; + FMatDuptr pprOeOpEpt; + std::unique_ptr>> ppAOepEpt; + }; } diff --git a/MbDCode/EulerConstraint.cpp b/MbDCode/EulerConstraint.cpp index 9bc40c0..bbe18af 100644 --- a/MbDCode/EulerConstraint.cpp +++ b/MbDCode/EulerConstraint.cpp @@ -5,12 +5,14 @@ using namespace MbD; EulerConstraint::EulerConstraint() { + initialize(); } -MbD::EulerConstraint::EulerConstraint(const char* str) : Constraint(str) +EulerConstraint::EulerConstraint(const char* str) : Constraint(str) { } -void MbD::EulerConstraint::initialize() +void EulerConstraint::initialize() { + pGpE = std::make_shared>(4); } diff --git a/MbDCode/EulerConstraint.h b/MbDCode/EulerConstraint.h index a3e121a..5e3d167 100644 --- a/MbDCode/EulerConstraint.h +++ b/MbDCode/EulerConstraint.h @@ -14,7 +14,7 @@ namespace MbD { EulerConstraint(const char* str); void initialize(); - FullRowDptr pGpE = std::make_shared>(4); //partial derivative of G wrt pE + FRowDsptr pGpE;//partial derivative of G wrt pE int iqE = -1; }; } diff --git a/MbDCode/EulerParameters.cpp b/MbDCode/EulerParameters.cpp index dfac4f9..3f628bd 100644 --- a/MbDCode/EulerParameters.cpp +++ b/MbDCode/EulerParameters.cpp @@ -6,9 +6,7 @@ using namespace MbD; -//typedef std::shared_ptr>>> FMatFColDptr; - -std::shared_ptr>>> EulerParameters::ppApEpEtimesColumn(FullColDptr col) +std::unique_ptr>>> EulerParameters::ppApEpEtimesColumn(FColDsptr col) { double a2c1 = 2 * col->at(0); double a2c2 = 2 * col->at(1); @@ -26,23 +24,23 @@ std::shared_ptr>>> EulerParameters auto col33 = std::make_shared>(ListD{ m2c1, m2c2, a2c3 }); auto col34 = std::make_shared>(ListD{ m2c2, a2c1, 0 }); auto col44 = std::make_shared>(ListD{ a2c1, a2c2, a2c3 }); - auto answer = std::make_shared>>>(4, 4); + auto answer = std::make_unique>>>(4, 4); auto row1 = answer->at(0); row1->at(0) = col11; row1->at(1) = col12; row1->at(2) = col13; row1->at(3) = col14; - auto row2 = answer->at(0); + auto row2 = answer->at(1); row2->at(0) = col12; row2->at(1) = col22; row2->at(2) = col23; row2->at(3) = col24; - auto row3 = answer->at(0); + auto row3 = answer->at(2); row3->at(0) = col13; row3->at(1) = col23; row3->at(2) = col33; row3->at(3) = col34; - auto row4 = answer->at(0); + auto row4 = answer->at(3); row4->at(0) = col14; row4->at(1) = col24; row4->at(2) = col34; @@ -50,16 +48,16 @@ std::shared_ptr>>> EulerParameters return answer; } -std::shared_ptr>>> EulerParameters::ppApEpEtimesMatrix(FullMatDptr mat) +std::unique_ptr>>> EulerParameters::ppApEpEtimesMatrix(FMatDsptr mat) { - FullRowDptr a2m1 = mat->at(0)->times(2.0); - FullRowDptr a2m2 = mat->at(1)->times(2.0); - FullRowDptr a2m3 = mat->at(2)->times(2.0); - FullRowDptr m2m1 = a2m1->negated(); - FullRowDptr m2m2 = a2m2->negated(); - FullRowDptr m2m3 = a2m3->negated(); + FRowDsptr a2m1 = mat->at(0)->times(2.0); + FRowDsptr a2m2 = mat->at(1)->times(2.0); + FRowDsptr a2m3 = mat->at(2)->times(2.0); + FRowDsptr m2m1 = a2m1->negated(); + FRowDsptr m2m2 = a2m2->negated(); + FRowDsptr m2m3 = a2m3->negated(); auto aaaa = std::make_shared>(3, 0.0); - FullRowDptr zero = std::make_shared>(3, 0.0); + FRowDsptr zero = std::make_shared>(3, 0.0); auto mat11 = std::make_shared>(ListFRD{ a2m1, m2m2, m2m3 }); auto mat12 = std::make_shared>(ListFRD{ a2m2, a2m1, zero }); auto mat13 = std::make_shared>(ListFRD{ a2m3, zero, a2m1 }); @@ -70,7 +68,7 @@ std::shared_ptr>>> EulerParameters auto mat33 = std::make_shared>(ListFRD{ m2m1, m2m2, a2m3 }); auto mat34 = std::make_shared>(ListFRD{ m2m2, a2m1, zero }); auto mat44 = std::make_shared>(ListFRD{ a2m1, a2m2, a2m3 }); - auto answer = std::make_shared>>>(4, 4); + auto answer = std::make_unique>>>(4, 4); auto row1 = answer->at(0); row1->at(0) = mat11; row1->at(1) = mat12; diff --git a/MbDCode/EulerParameters.h b/MbDCode/EulerParameters.h index 65b25dc..d74eb09 100644 --- a/MbDCode/EulerParameters.h +++ b/MbDCode/EulerParameters.h @@ -8,11 +8,9 @@ namespace MbD { { //aA aB aC pApE public: - static std::shared_ptr>>> ppApEpEtimesColumn(FullColDptr col); - static std::shared_ptr>>> ppApEpEtimesMatrix(FullMatDptr col); + static std::unique_ptr>>> ppApEpEtimesColumn(FColDsptr col); + static std::unique_ptr>>> ppApEpEtimesMatrix(FMatDsptr col); }; - - //typedef std::shared_ptr>>> FMatFColDptr; } diff --git a/MbDCode/FullColumn.h b/MbDCode/FullColumn.h index cc548de..ce80fa9 100644 --- a/MbDCode/FullColumn.h +++ b/MbDCode/FullColumn.h @@ -26,7 +26,9 @@ namespace MbD { } }; - typedef std::shared_ptr> FullColDptr; - //typedef std::shared_ptr>>> FullColFMptr; + typedef std::shared_ptr> FColDsptr; + typedef std::unique_ptr> FColDuptr; + //typedef std::shared_ptr>>> FColFMatDsptr; + //typedef std::unique_ptr>>> FColFMatDuptr; } diff --git a/MbDCode/FullMatrix.h b/MbDCode/FullMatrix.h index 5be785b..846ffda 100644 --- a/MbDCode/FullMatrix.h +++ b/MbDCode/FullMatrix.h @@ -1,12 +1,11 @@ #pragma once #include -#include "RowTypeMatrix.h" #include "FullColumn.h" +#include "RowTypeMatrix.h" #include "FullRow.h" namespace MbD { - //class FullColumn; template class FullMatrix : public RowTypeMatrix>> @@ -35,10 +34,13 @@ namespace MbD { }; typedef std::initializer_list> ListListD; - typedef std::initializer_list ListFRD; - typedef std::shared_ptr> FullMatDptr; - //typedef std::shared_ptr>>> FMatFColDptr; - typedef std::shared_ptr>>> FMatFMatDptr; + typedef std::initializer_list ListFRD; + typedef std::shared_ptr> FMatDsptr; + typedef std::unique_ptr> FMatDuptr; + //typedef std::shared_ptr>>> FMatFColDsptr; + //typedef std::unique_ptr>>> FMatFColDuptr; + typedef std::shared_ptr>>> FMatFMatDsptr; + typedef std::unique_ptr>>> FMatFMatDuptr; } diff --git a/MbDCode/FullRow.h b/MbDCode/FullRow.h index 9204e7b..9b3a5cf 100644 --- a/MbDCode/FullRow.h +++ b/MbDCode/FullRow.h @@ -13,7 +13,7 @@ namespace MbD { std::shared_ptr> negated(); }; - typedef std::shared_ptr> FullRowDptr; + typedef std::shared_ptr> FRowDsptr; template inline std::shared_ptr> FullRow::times(double a) diff --git a/MbDCode/Item.cpp b/MbDCode/Item.cpp index b792fa1..79534ef 100644 --- a/MbDCode/Item.cpp +++ b/MbDCode/Item.cpp @@ -2,6 +2,19 @@ using namespace MbD; +Item::Item() { + initialize(); +} + +Item::Item(const char* str) : name(str) +{ + initialize(); +} + +void Item::initialize() +{ +} + void Item::setName(std::string& str) { name = str; @@ -11,3 +24,11 @@ const std::string& Item::getName() const { return name; } + +void Item::initializeLocally() +{ +} + +void Item::initializeGlobally() +{ +} diff --git a/MbDCode/Item.h b/MbDCode/Item.h index 473562a..9533f9c 100644 --- a/MbDCode/Item.h +++ b/MbDCode/Item.h @@ -6,10 +6,14 @@ namespace MbD { { //name public: - Item() {} - Item(const char* str) : name(str) {} + Item(); + Item(const char* str); + virtual void initialize(); + virtual void initializeLocally(); + virtual void initializeGlobally(); void setName(std::string& str); const std::string& getName() const; + private: std::string name; }; diff --git a/MbDCode/Joint.cpp b/MbDCode/Joint.cpp index b35cb7c..b5dec90 100644 --- a/MbDCode/Joint.cpp +++ b/MbDCode/Joint.cpp @@ -1,3 +1,5 @@ +#include + #include "Joint.h" using namespace MbD; @@ -23,8 +25,10 @@ void Joint::connectsItoJ(std::shared_ptr frmi, std::shared_ptrbegin(), constraints->end(), [](const auto& constraint) { constraint->initializeLocally(); }); } void Joint::initializeGlobally() { + std::for_each(constraints->begin(), constraints->end(), [](const auto& constraint) { constraint->initializeGlobally(); }); } diff --git a/MbDCode/Joint.h b/MbDCode/Joint.h index ef4b1a9..e9fc217 100644 --- a/MbDCode/Joint.h +++ b/MbDCode/Joint.h @@ -18,8 +18,8 @@ namespace MbD { Joint(const char* str); void initialize(); virtual void connectsItoJ(std::shared_ptr frmI, std::shared_ptr frmJ); - void initializeLocally(); - void initializeGlobally(); + void initializeLocally() override; + void initializeGlobally() override; std::shared_ptr frmI; std::shared_ptr frmJ; diff --git a/MbDCode/KinematicIeJe.cpp b/MbDCode/KinematicIeJe.cpp new file mode 100644 index 0000000..29f4d15 --- /dev/null +++ b/MbDCode/KinematicIeJe.cpp @@ -0,0 +1,11 @@ +#include "KinematicIeJe.h" + +using namespace MbD; + +MbD::KinematicIeJe::KinematicIeJe() +{ +} + +MbD::KinematicIeJe::KinematicIeJe(std::shared_ptr frmi, std::shared_ptr frmj) : frmI(frmi), frmJ(frmj) +{ +} diff --git a/MbDCode/KinematicIeJe.h b/MbDCode/KinematicIeJe.h new file mode 100644 index 0000000..0449b1b --- /dev/null +++ b/MbDCode/KinematicIeJe.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Item.h" +#include "EndFramec.h" + +namespace MbD { + class KinematicIeJe : public Item + { + //frmI frmJ + public: + KinematicIeJe(); + KinematicIeJe(std::shared_ptr frmi, std::shared_ptr frmj); + + std::shared_ptr frmI, frmJ; + }; +} + diff --git a/MbDCode/MarkerFrame.cpp b/MbDCode/MarkerFrame.cpp index bb0341a..8d103fc 100644 --- a/MbDCode/MarkerFrame.cpp +++ b/MbDCode/MarkerFrame.cpp @@ -1,7 +1,10 @@ +#include + #include "PartFrame.h" #include "MarkerFrame.h" #include "EndFramec.h" #include "EndFrameqc.h" +#include "EulerParameters.h" using namespace MbD; @@ -10,13 +13,17 @@ MarkerFrame::MarkerFrame() initialize(); } -MbD::MarkerFrame::MarkerFrame(const char* str) : CartesianFrame(str) { +MarkerFrame::MarkerFrame(const char* str) : CartesianFrame(str) { initialize(); } -void MbD::MarkerFrame::initialize() +void MarkerFrame::initialize() { - partFrame = nullptr; + //prOmOpE: = StMFullMatrix new : 3 by : 4. + //pAOmpE : = StMFullColumn new : 4. + //endFrames : = OrderedCollection new + prOmOpE = std::make_shared>(3, 4); + pAOmpE = std::make_unique>>(4); endFrames = std::make_unique>>(); auto endFrm = std::make_shared("EndFrame1"); this->addEndFrame(endFrm); @@ -31,12 +38,12 @@ PartFrame* MarkerFrame::getPartFrame() { return partFrame; } -void MarkerFrame::setrpmp(FullColDptr x) +void MarkerFrame::setrpmp(FColDsptr x) { rpmp->copy(x); } -void MarkerFrame::setaApm(FullMatDptr x) +void MarkerFrame::setaApm(FMatDsptr x) { aApm->copy(x); } @@ -45,3 +52,14 @@ void MarkerFrame::addEndFrame(std::shared_ptr endFrm) endFrm->setMarkerFrame(this); endFrames->push_back(endFrm); } + +void MarkerFrame::initializeLocally() +{ + pprOmOpEpE = EulerParameters::ppApEpEtimesColumn(rpmp); + ppAOmpEpE = EulerParameters::ppApEpEtimesMatrix(aApm); + std::for_each(endFrames->begin(), endFrames->end(), [](const auto& endFrame) { endFrame->initializeLocally(); }); +} + +void MarkerFrame::initializeGlobally() +{ +} diff --git a/MbDCode/MarkerFrame.h b/MbDCode/MarkerFrame.h index aac4d6b..6527d55 100644 --- a/MbDCode/MarkerFrame.h +++ b/MbDCode/MarkerFrame.h @@ -20,17 +20,21 @@ namespace MbD { void initialize(); void setPartFrame(PartFrame* partFrm); PartFrame* getPartFrame(); - void setrpmp(FullColDptr x); - void setaApm(FullMatDptr x); + void setrpmp(FColDsptr x); + void setaApm(FMatDsptr x); void addEndFrame(std::shared_ptr x); + void initializeLocally() override; + void initializeGlobally() override; PartFrame* partFrame; - FullColDptr rpmp = std::make_shared>(3); - FullMatDptr aApm = std::make_shared>(3, 3); - FullColDptr rOmO = std::make_shared>(3); - FullMatDptr aAOm = std::make_shared>(3, 3); - FullMatDptr prOmOpE = std::make_shared>(3, 4); - FullColumn>* pAOmpE = new FullColumn>(4); + FColDsptr rpmp = std::make_shared>(3); + FMatDsptr aApm = std::make_shared>(3, 3); + FColDsptr rOmO = std::make_shared>(3); + FMatDsptr aAOm = std::make_shared>(3, 3); + FMatDsptr prOmOpE; + std::unique_ptr>> pAOmpE; + std::unique_ptr>>> pprOmOpEpE; + FMatFMatDuptr ppAOmpEpE; std::unique_ptr>> endFrames; }; diff --git a/MbDCode/MbDCode.cpp b/MbDCode/MbDCode.cpp index f453f8d..d9bff74 100644 --- a/MbDCode/MbDCode.cpp +++ b/MbDCode/MbDCode.cpp @@ -24,14 +24,30 @@ int main() //System& TheSystem = System::getInstance(); System& TheSystem = System::getInstance("TheSystem"); std::cout << "TheSystem.getName() " << TheSystem.getName() << 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; + systemSolver->tend = 25.0; + systemSolver->hmin = 2.5e-8; + systemSolver->hmax = 25.0; + systemSolver->hout = 1.0; + 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 = 9.6058421285615e9; + systemSolver->rotationLimit = 0.5; + std::string str; - FullColDptr qX, qE; - FullColDptr rpmp; - FullMatDptr aApm; - FullRowDptr fullRow; - auto row = std::make_shared>(ListD{ 0.0, 0.0, 0.0, 1.0 }); - fullRow = std::make_shared>(4); - fullRow->copy(row); + FColDsptr qX, qE; + FColDsptr rpmp; + FMatDsptr aApm; + FRowDsptr fullRow; // auto assembly1 = std::make_shared("Assembly1"); std::cout << "assembly1->getName() " << assembly1->getName() << std::endl; @@ -66,15 +82,16 @@ int main() marker2->setaApm(aApm); partFrame->addMarkerFrame(marker2); } + assembly1->asFixed(); // - auto part1 = std::make_shared("Part1"); + auto crankPart1 = std::make_shared("Part1"); qX = std::make_shared>(ListD{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }); qE = std::make_shared>(ListD{ 0.0, 0.0, 1.4248456266393e-10, 1.0 }); - part1->setqX(qX); - part1->setqE(qE); - TheSystem.parts->push_back(part1); + crankPart1->setqX(qX); + crankPart1->setqE(qE); + TheSystem.parts->push_back(crankPart1); { - auto partFrame = part1->partFrame; + auto partFrame = crankPart1->partFrame; auto marker1 = std::make_shared("Marker1"); rpmp = std::make_shared>(ListD{ -0.38423368514246, -2.6661567755108e-17, 0.048029210642807 }); marker1->setrpmp(rpmp); @@ -98,14 +115,14 @@ int main() partFrame->addMarkerFrame(marker2); } // - auto part2 = std::make_shared("Part2"); + auto conrodPart2 = std::make_shared("Part2"); qX = std::make_shared>(ListD{ 0.38423366582893, 0.49215308269277, 0.048029210642807 }); qE = std::make_shared>(ListD{ 0.0, 0.0, 0.89871701272344, 0.4385290538168 }); - part2->setqX(qX); - part2->setqE(qE); - TheSystem.parts->push_back(part2); + conrodPart2->setqX(qX); + conrodPart2->setqE(qE); + TheSystem.parts->push_back(conrodPart2); { - auto partFrame = part2->partFrame; + auto partFrame = conrodPart2->partFrame; auto marker1 = std::make_shared("Marker1"); rpmp = std::make_shared>(ListD{ -0.6243797383565, 1.1997705489799e-16, -0.048029210642807 }); marker1->setrpmp(rpmp); @@ -129,14 +146,14 @@ int main() partFrame->addMarkerFrame(marker2); } // - auto part3 = std::make_shared("Part3"); + auto pistonPart3 = std::make_shared("Part3"); qX = std::make_shared>(ListD{ -1.284772285311e-18, 1.4645982581368, -4.788228906425e-17 }); qE = std::make_shared>(ListD{ 0.70710678118655, 0.70710678118655, 0.0, 0.0 }); - part3->setqX(qX); - part3->setqE(qE); - TheSystem.parts->push_back(part3); + pistonPart3->setqX(qX); + pistonPart3->setqE(qE); + TheSystem.parts->push_back(pistonPart3); { - auto partFrame = part3->partFrame; + auto partFrame = pistonPart3->partFrame; auto marker1 = std::make_shared("Marker1"); rpmp = std::make_shared>(ListD{ -0.48029210642807, 7.6201599718927e-18, -2.816737703896e-17 }); marker1->setrpmp(rpmp); @@ -161,23 +178,23 @@ int main() } // auto cylJoint4 = std::make_shared("CylJoint4"); - cylJoint4->connectsItoJ(part3->partFrame->endFrame("Marker2"), assembly1->partFrame->endFrame("Marker1")); + cylJoint4->connectsItoJ(pistonPart3->partFrame->endFrame("Marker2"), assembly1->partFrame->endFrame("Marker1")); TheSystem.jointsMotions->push_back(cylJoint4); auto revJoint3 = std::make_shared("RevJoint3"); - revJoint3->connectsItoJ(part2->partFrame->endFrame("Marker2"), part3->partFrame->endFrame("Marker1")); + revJoint3->connectsItoJ(conrodPart2->partFrame->endFrame("Marker2"), pistonPart3->partFrame->endFrame("Marker1")); TheSystem.jointsMotions->push_back(revJoint3); auto revJoint2 = std::make_shared("RevJoint2"); - revJoint2->connectsItoJ(part1->partFrame->endFrame("Marker2"), part2->partFrame->endFrame("Marker1")); + revJoint2->connectsItoJ(crankPart1->partFrame->endFrame("Marker2"), conrodPart2->partFrame->endFrame("Marker1")); TheSystem.jointsMotions->push_back(revJoint2); auto revJoint1 = std::make_shared("RevJoint1"); - revJoint1->connectsItoJ(assembly1->partFrame->endFrame("Marker2"), part1->partFrame->endFrame("Marker1")); + revJoint1->connectsItoJ(assembly1->partFrame->endFrame("Marker2"), crankPart1->partFrame->endFrame("Marker1")); TheSystem.jointsMotions->push_back(revJoint1); auto rotMotion1 = std::make_shared("RotMotion1"); - rotMotion1->connectsItoJ(assembly1->partFrame->endFrame("Marker2"), part1->partFrame->endFrame("Marker1")); + rotMotion1->connectsItoJ(assembly1->partFrame->endFrame("Marker2"), crankPart1->partFrame->endFrame("Marker1")); TheSystem.jointsMotions->push_back(rotMotion1); // TheSystem.runKINEMATICS(); diff --git a/MbDCode/MbDCode.vcxproj b/MbDCode/MbDCode.vcxproj index 5d578e7..ff40220 100644 --- a/MbDCode/MbDCode.vcxproj +++ b/MbDCode/MbDCode.vcxproj @@ -129,10 +129,18 @@ + + + + + + + + @@ -145,6 +153,7 @@ + @@ -161,8 +170,8 @@ - + @@ -170,10 +179,18 @@ + + + + + + + + @@ -186,6 +203,7 @@ + @@ -202,8 +220,8 @@ - + diff --git a/MbDCode/MbDCode.vcxproj.filters b/MbDCode/MbDCode.vcxproj.filters index 7fc0f3d..a092cda 100644 --- a/MbDCode/MbDCode.vcxproj.filters +++ b/MbDCode/MbDCode.vcxproj.filters @@ -129,7 +129,34 @@ Source Files - + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + Source Files @@ -248,7 +275,34 @@ Header Files - + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + Header Files diff --git a/MbDCode/Part.cpp b/MbDCode/Part.cpp index 0d60e8b..6dec654 100644 --- a/MbDCode/Part.cpp +++ b/MbDCode/Part.cpp @@ -16,21 +16,24 @@ void Part::initialize() { partFrame = std::make_shared(); partFrame->setPart(this); + pTpE = std::make_shared>(4); + ppTpEpE = std::make_shared>(4, 4); + ppTpEpEdot = std::make_shared>(4, 4); } -void Part::setqX(FullColDptr x) { +void Part::setqX(FColDsptr x) { partFrame->setqX(x); } -FullColDptr Part::getqX() { +FColDsptr Part::getqX() { return partFrame->getqX(); } -void Part::setqE(FullColDptr x) { +void Part::setqE(FColDsptr x) { partFrame->setqE(x); } -FullColDptr Part::getqE() { +FColDsptr Part::getqE() { return partFrame->getqE(); } @@ -39,8 +42,14 @@ void Part::setSystem(System& sys) //May be needed in the future } +void MbD::Part::asFixed() +{ + partFrame->asFixed(); +} + void Part::initializeLocally() { + partFrame->initializeLocally(); } void Part::initializeGlobally() diff --git a/MbDCode/Part.h b/MbDCode/Part.h index b150aef..bda1563 100644 --- a/MbDCode/Part.h +++ b/MbDCode/Part.h @@ -5,6 +5,7 @@ #include "System.h" #include "PartFrame.h" #include "FullColumn.h" +#include "DiagonalMatrix.h" namespace MbD { class System; @@ -17,15 +18,30 @@ namespace MbD { Part(); Part(const char* str); void initialize(); - void setqX(FullColDptr x); - FullColDptr getqX(); - void setqE(FullColDptr x); - FullColDptr getqE(); + void initializeLocally() override; + void initializeGlobally() override; + void setqX(FColDsptr x); + FColDsptr getqX(); + void setqE(FColDsptr x); + FColDsptr getqE(); void setSystem(System& sys); - void initializeLocally(); - void initializeGlobally(); + void asFixed(); + int ipX; + int ipE; + double m; + std::unique_ptr> aJ; std::shared_ptr partFrame; + FColDsptr pX; + FColDsptr pXdot; + FColDsptr pE; + FColDsptr pEdot; + std::unique_ptr> mX; + std::unique_ptr> mE; + FMatDsptr mEdot; + FColDsptr pTpE; + FMatDsptr ppTpEpE; + FMatDsptr ppTpEpEdot; }; } diff --git a/MbDCode/PartFrame.cpp b/MbDCode/PartFrame.cpp index e13094a..2e607c8 100644 --- a/MbDCode/PartFrame.cpp +++ b/MbDCode/PartFrame.cpp @@ -1,3 +1,5 @@ +#include + #include "Part.h" #include "PartFrame.h" #include "EulerConstraint.h" @@ -7,28 +9,30 @@ using namespace MbD; PartFrame::PartFrame() +{ + initialize(); +} +PartFrame::PartFrame(const char* str) : CartesianFrame(str) +{ + initialize(); +} +void PartFrame::initialize() { aGeu = std::make_shared("EulerCon"); aGeu->setOwner(this); aGabs = std::make_unique>>(); markerFrames = std::make_unique>>(); } -MbD::PartFrame::PartFrame(const char* str) : CartesianFrame(str) -{ -} -void MbD::PartFrame::initialize() -{ -} -void PartFrame::setqX(FullColDptr x) { +void PartFrame::setqX(FColDsptr x) { qX->copy(x); } -FullColDptr PartFrame::getqX() { +FColDsptr PartFrame::getqX() { return qX; } -void PartFrame::setqE(FullColDptr x) { +void PartFrame::setqE(FColDsptr x) { qE->copy(x); } -FullColDptr PartFrame::getqE() { +FColDsptr PartFrame::getqE() { return qE; } void PartFrame::setPart(Part* x) { @@ -49,3 +53,23 @@ std::shared_ptr PartFrame::endFrame(std::string name) auto match = std::find_if(markerFrames->begin(), markerFrames->end(), [&](auto mkr) {return mkr->getName() == name; }); return (*match)->endFrames->at(0); } + +void MbD::PartFrame::asFixed() +{ + for (int i = 0; i < 6; i++) { + auto con = std::make_shared(i); + con->setOwner(this); + aGabs->push_back(con); + } +} + +void PartFrame::initializeLocally() +{ + std::for_each(markerFrames->begin(), markerFrames->end(), [](const auto& markerFrame) { markerFrame->initializeLocally(); }); + aGeu->initializeLocally(); + std::for_each(aGabs->begin(), aGabs->end(), [](const auto& aGab) { aGab->initializeLocally(); }); +} + +void PartFrame::initializeGlobally() +{ +} diff --git a/MbDCode/PartFrame.h b/MbDCode/PartFrame.h index e7b3f26..dc9bbd1 100644 --- a/MbDCode/PartFrame.h +++ b/MbDCode/PartFrame.h @@ -22,11 +22,14 @@ namespace MbD { PartFrame(); PartFrame(const char* str); void initialize(); + void initializeLocally() override; + void initializeGlobally() override; + void asFixed(); - void setqX(FullColDptr x); - FullColDptr getqX(); - void setqE(FullColDptr x); - FullColDptr getqE(); + void setqX(FColDsptr x); + FColDsptr getqX(); + void setqE(FColDsptr x); + FColDsptr getqE(); void setPart(Part* x); Part* getPart(); void addMarkerFrame(std::shared_ptr x); @@ -34,8 +37,12 @@ namespace MbD { Part* part; int iqX, iqE; //Position index of frame variables qX and qE in system list of variables - FullColDptr qX = std::make_shared>(3); - FullColDptr qE = std::make_shared>(4); + FColDsptr qX = std::make_shared>(3); + FColDsptr qE = std::make_shared>(4); + FColDsptr qXdot = std::make_shared>(3); + FColDsptr qEdot = std::make_shared>(4); + FColDsptr qXddot = std::make_shared>(3); + FColDsptr qEddot = std::make_shared>(4); std::shared_ptr aGeu; std::unique_ptr>> aGabs; std::unique_ptr>> markerFrames; diff --git a/MbDCode/PrescribedMotion.cpp b/MbDCode/PrescribedMotion.cpp index c4782e1..fd11349 100644 --- a/MbDCode/PrescribedMotion.cpp +++ b/MbDCode/PrescribedMotion.cpp @@ -1,9 +1,11 @@ +#include #include #include #include #include "PrescribedMotion.h" #include "EndFrameqct.h" +#include "Constant.h" using namespace MbD; @@ -17,15 +19,36 @@ PrescribedMotion::PrescribedMotion(const char* str) : Joint(str) { void PrescribedMotion::initialize() { + xBlk = std::make_shared(0.0); + yBlk = std::make_shared(0.0); + zBlk = std::make_shared(0.0); + phiBlk = std::make_shared(0.0); + theBlk = std::make_shared(0.0); + psiBlk = std::make_shared(0.0); } void PrescribedMotion::connectsItoJ(std::shared_ptr frmi, std::shared_ptr frmj) { Joint::connectsItoJ(frmi, frmj); - if (typeid(frmI).name() != "EndFrameqct") { - std::shared_ptr newFrmI; - newFrmI = std::make_shared(); - std::swap(frmI, newFrmI); - assert(typeid(frmI).name() != "EndFrameqct"); - } + frmI->EndFrameqctFrom(frmI); } + +//void PrescribedMotion::connectsItoJ(std::shared_ptr frmi, std::shared_ptr frmj) +//{ +// Joint::connectsItoJ(frmi, frmj); +// frmI->EndFrameqctFrom(frmI); +// decltype(frmi) dddd; +// std::cout << "typeid(dddd).name() " << typeid(dddd).name() << std::endl; +// std::cout << "typeid(frmI).name() " << typeid(frmI).name() << std::endl; +// if (typeid(frmI).name() != "EndFrameqct") { +// std::shared_ptr newFrmI; +// newFrmI = std::make_shared(frmI->getName().c_str()); +// decltype(newFrmI) ffff; +// std::cout << "typeid(ffff).name() " << typeid(ffff).name() << std::endl; +// auto gggg = std::make_shared(frmI->getName().c_str()); +// std::cout << "typeid(gggg).name() " << typeid(gggg).name() << std::endl; +// std::cout << "typeid(newFrmI).name() " << typeid(newFrmI).name() << std::endl; +// std::swap(frmI, newFrmI); +// assert(typeid(frmI).name() != "EndFrameqct"); +// } +//} diff --git a/MbDCode/PrescribedMotion.h b/MbDCode/PrescribedMotion.h index cd866fc..301955d 100644 --- a/MbDCode/PrescribedMotion.h +++ b/MbDCode/PrescribedMotion.h @@ -10,6 +10,13 @@ namespace MbD { PrescribedMotion(const char* str); void initialize(); void connectsItoJ(std::shared_ptr frmI, std::shared_ptr frmJ) override; + + std::shared_ptr xBlk; + std::shared_ptr yBlk; + std::shared_ptr zBlk; + std::shared_ptr phiBlk; + std::shared_ptr theBlk; + std::shared_ptr psiBlk; }; } diff --git a/MbDCode/Solver.h b/MbDCode/Solver.h index 01e7b97..6e1ae32 100644 --- a/MbDCode/Solver.h +++ b/MbDCode/Solver.h @@ -2,6 +2,9 @@ namespace MbD { class Solver { + public: + virtual void initializeLocally() = 0; + virtual void initializeGlobally() = 0; }; } diff --git a/MbDCode/Symbolic.cpp b/MbDCode/Symbolic.cpp index 07d21ec..50e6dca 100644 --- a/MbDCode/Symbolic.cpp +++ b/MbDCode/Symbolic.cpp @@ -1 +1,12 @@ #include "Symbolic.h" + +using namespace MbD; + +Symbolic::Symbolic() +{ + initialize(); +} + +void Symbolic::initialize() +{ +} diff --git a/MbDCode/Symbolic.h b/MbDCode/Symbolic.h index d916207..981e451 100644 --- a/MbDCode/Symbolic.h +++ b/MbDCode/Symbolic.h @@ -2,6 +2,9 @@ namespace MbD { class Symbolic { + public: + Symbolic(); + void initialize(); }; } diff --git a/MbDCode/System.cpp b/MbDCode/System.cpp index 840fea9..db9f578 100644 --- a/MbDCode/System.cpp +++ b/MbDCode/System.cpp @@ -50,11 +50,11 @@ void System::runKINEMATICS() systemSolver->runBasicKinematic(); } -void System::initializeLocally() +void System::initializeLocally() { hasChanged = false; - timeValue = systemSolver->tstart; - std::for_each(parts->begin(), parts->end(), [](const auto& part) { part->initializeLocally(); }); + time->value = systemSolver->tstart; + std::for_each(parts->begin(), parts->end(), [](const auto& part) { part->initializeLocally(); }); std::for_each(jointsMotions->begin(), jointsMotions->end(), [](const auto& joint) { joint->initializeLocally(); }); systemSolver->initializeLocally(); } diff --git a/MbDCode/System.h b/MbDCode/System.h index 6fc7fa6..d08bd9f 100644 --- a/MbDCode/System.h +++ b/MbDCode/System.h @@ -35,16 +35,17 @@ namespace MbD { static System singleInstance(str); // Block-scoped static Singleton instance return singleInstance; }; + + std::unique_ptr>> parts; std::unique_ptr>> jointsMotions; bool hasChanged = false; std::shared_ptr systemSolver; void addPart(std::shared_ptr part); void runKINEMATICS(); - void initializeLocally(); - void initializeGlobally(); + void initializeLocally() override; + void initializeGlobally() override; - double timeValue; std::unique_ptr