Skip to content

Commit

Permalink
RackPinion, Screw, Planar
Browse files Browse the repository at this point in the history
  • Loading branch information
aiksiongkoh committed Nov 20, 2023
1 parent 1b9ba5a commit d609d3e
Show file tree
Hide file tree
Showing 116 changed files with 8,495 additions and 249 deletions.
50 changes: 50 additions & 0 deletions OndselSolver/ASMTAngleJoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>

#include "ASMTAngleJoint.h"
#include "AngleJoint.h"

using namespace MbD;

std::shared_ptr<Joint> MbD::ASMTAngleJoint::mbdClassNew()
{
return CREATE<AngleJoint>::With();
}

void MbD::ASMTAngleJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readTheIzJz(lines);
}

void MbD::ASMTAngleJoint::readTheIzJz(std::vector<std::string>& lines)
{
if (lines[0].find("theIzJz") == std::string::npos) {
theIzJz = 0.0;
}
else {
lines.erase(lines.begin());
theIzJz = readDouble(lines[0]);
lines.erase(lines.begin());
}
}

void MbD::ASMTAngleJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto angleJoint = std::static_pointer_cast<AngleJoint>(mbdObject);
angleJoint->theIzJz = theIzJz;
}

void MbD::ASMTAngleJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "theIzJz");
storeOnLevelDouble(os, level + 2, theIzJz);
}
27 changes: 27 additions & 0 deletions OndselSolver/ASMTAngleJoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/

#pragma once

#include "ASMTJoint.h"

namespace MbD {
class EXPORT ASMTAngleJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void parseASMT(std::vector<std::string>& lines) override;
void readTheIzJz(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void storeOnLevel(std::ofstream& os, int level) override;

double theIzJz = 0.0;
};
}

91 changes: 76 additions & 15 deletions OndselSolver/ASMTAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@
#include "ASMTItemIJ.h"
#include "ASMTKinematicIJ.h"
#include <iomanip>
#include "ASMTAngleJoint.h"
#include "ASMTConstantVelocityJoint.h"
#include "ASMTCylSphJoint.h"
#include "ASMTGearJoint.h"
#include "ASMTPointInLineJoint.h"
#include "ASMTRevCylJoint.h"
#include "ASMTSphSphJoint.h"
#include "ASMTLineInPlaneJoint.h"
#include "ASMTPlanarJoint.h"
#include "ASMTNoRotationJoint.h"
#include "ASMTParallelAxesJoint.h"
#include "ASMTPerpendicularJoint.h"
#include "ASMTRackPinionJoint.h"
#include "ASMTScrewJoint.h"

using namespace MbD;

Expand Down Expand Up @@ -528,24 +542,70 @@ void MbD::ASMTAssembly::readJoints(std::vector<std::string>& lines)
std::vector<std::string> jointsLines(lines.begin(), it);
std::shared_ptr<ASMTJoint> joint;
while (!jointsLines.empty()) {
if (jointsLines[0] == "\t\t\tRevoluteJoint") {
joint = CREATE<ASMTRevoluteJoint>::With();
if (jointsLines[0] == "\t\t\tAngleJoint") {
joint = CREATE<ASMTAngleJoint>::With();
}
else if (jointsLines[0] == "\t\t\tCylindricalJoint") {
joint = CREATE<ASMTCylindricalJoint>::With();
else if (jointsLines[0] == "\t\t\tGearJoint") {
joint = CREATE<ASMTGearJoint>::With();
}
else if (jointsLines[0] == "\t\t\tTranslationalJoint") {
joint = CREATE<ASMTTranslationalJoint>::With();
else if (jointsLines[0] == "\t\t\tNoRotationJoint") {
joint = CREATE<ASMTNoRotationJoint>::With();
}
else if (jointsLines[0] == "\t\t\tSphericalJoint") {
joint = CREATE<ASMTSphericalJoint>::With();
else if (jointsLines[0] == "\t\t\tParallelAxesJoint") {
joint = CREATE<ASMTParallelAxesJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPerpendicularJoint") {
joint = CREATE<ASMTPerpendicularJoint>::With();
}
else if (jointsLines[0] == "\t\t\tRackPinionJoint") {
joint = CREATE<ASMTRackPinionJoint>::With();
}
else if (jointsLines[0] == "\t\t\tScrewJoint") {
joint = CREATE<ASMTScrewJoint>::With();
}
//AtPointJoints
else if (jointsLines[0] == "\t\t\tConstantVelocityJoint") {
joint = CREATE<ASMTConstantVelocityJoint>::With();
}
else if (jointsLines[0] == "\t\t\tFixedJoint") {
joint = CREATE<ASMTFixedJoint>::With();
}
else if (jointsLines[0] == "\t\t\tRevoluteJoint") {
joint = CREATE<ASMTRevoluteJoint>::With();
}
else if (jointsLines[0] == "\t\t\tSphericalJoint") {
joint = CREATE<ASMTSphericalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tUniversalJoint") {
joint = CREATE<ASMTUniversalJoint>::With();
}
//CompoundJoints
else if (jointsLines[0] == "\t\t\tCylSphJoint") {
joint = CREATE<ASMTCylSphJoint>::With();
}
else if (jointsLines[0] == "\t\t\tRevCylJoint") {
joint = CREATE<ASMTRevCylJoint>::With();
}
else if (jointsLines[0] == "\t\t\tSphSphJoint") {
joint = CREATE<ASMTSphSphJoint>::With();
}
//InLineJoints
else if (jointsLines[0] == "\t\t\tCylindricalJoint") {
joint = CREATE<ASMTCylindricalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPointInLineJoint") {
joint = CREATE<ASMTPointInLineJoint>::With();
}
else if (jointsLines[0] == "\t\t\tTranslationalJoint") {
joint = CREATE<ASMTTranslationalJoint>::With();
}
//InPlaneJoints
else if (jointsLines[0] == "\t\t\tLineInPlaneJoint") {
joint = CREATE<ASMTLineInPlaneJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPlanarJoint") {
joint = CREATE<ASMTPlanarJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPointInPlaneJoint") {
joint = CREATE<ASMTPointInPlaneJoint>::With();
}
Expand Down Expand Up @@ -1072,8 +1132,9 @@ std::shared_ptr<ASMTTime> MbD::ASMTAssembly::geoTime()
void MbD::ASMTAssembly::updateFromMbD()
{
ASMTSpatialContainer::updateFromMbD();
times->push_back(asmtTime->getValue());
std::cout << "Time = " << asmtTime->getValue() << std::endl;
auto time = asmtTime->getValue();
times->push_back(time);
std::cout << "Time = " << time << std::endl;
for (auto& part : *parts) part->updateFromMbD();
for (auto& joint : *joints) joint->updateFromMbD();
for (auto& motion : *motions) motion->updateFromMbD();
Expand All @@ -1091,11 +1152,11 @@ void MbD::ASMTAssembly::compareResults(AnalysisType type)

void MbD::ASMTAssembly::outputResults(AnalysisType type)
{
ASMTSpatialContainer::outputResults(type);
for (auto& part : *parts) part->outputResults(type);
for (auto& joint : *joints) joint->outputResults(type);
for (auto& motion : *motions) motion->outputResults(type);
for (auto& forceTorque : *forcesTorques) forceTorque->outputResults(type);
//ASMTSpatialContainer::outputResults(type);
//for (auto& part : *parts) part->outputResults(type);
//for (auto& joint : *joints) joint->outputResults(type);
//for (auto& motion : *motions) motion->outputResults(type);
//for (auto& forceTorque : *forcesTorques) forceTorque->outputResults(type);
}

void MbD::ASMTAssembly::addPart(std::shared_ptr<ASMTPart> part)
Expand Down
1 change: 1 addition & 0 deletions OndselSolver/ASMTAtPointJoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "ASMTAtPointJoint.h"
20 changes: 20 additions & 0 deletions OndselSolver/ASMTAtPointJoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/

#pragma once

#include "ASMTJoint.h"

namespace MbD {
class EXPORT ASMTAtPointJoint : public ASMTJoint
{
//
public:

};
}
45 changes: 45 additions & 0 deletions OndselSolver/ASMTCompoundJoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>

#include "ASMTCompoundJoint.h"
#include "CompoundJoint.h"

using namespace MbD;

void MbD::ASMTCompoundJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readDistanceIJ(lines);
}

void MbD::ASMTCompoundJoint::readDistanceIJ(std::vector<std::string>& lines)
{
if (lines[0].find("distanceIJ") == std::string::npos) {
distanceIJ = 0.0;
}
else {
lines.erase(lines.begin());
distanceIJ = readDouble(lines[0]);
lines.erase(lines.begin());
}
}

void MbD::ASMTCompoundJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto compoundJoint = std::static_pointer_cast<CompoundJoint>(mbdObject);
compoundJoint->distanceIJ = distanceIJ;
}

void MbD::ASMTCompoundJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "distanceIJ");
storeOnLevelDouble(os, level + 2, distanceIJ);
}
27 changes: 27 additions & 0 deletions OndselSolver/ASMTCompoundJoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/

#pragma once

#include "ASMTJoint.h"

namespace MbD {
class EXPORT ASMTCompoundJoint : public ASMTJoint
{
//
public:
void parseASMT(std::vector<std::string>& lines) override;
void readDistanceIJ(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void storeOnLevel(std::ofstream& os, int level) override;

double distanceIJ = 0.0;

};
}

5 changes: 5 additions & 0 deletions OndselSolver/ASMTConstantGravity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ void MbD::ASMTConstantGravity::createMbD(std::shared_ptr<System> mbdSys, std::sh
mbdSys->addForceTorque(mbdGravity);
}

FColDsptr MbD::ASMTConstantGravity::getg()
{
return g;
}

void MbD::ASMTConstantGravity::setg(FColDsptr gravity)
{
g = gravity;
Expand Down
1 change: 1 addition & 0 deletions OndselSolver/ASMTConstantGravity.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace MbD {
public:
void parseASMT(std::vector<std::string>& lines) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
FColDsptr getg();
void setg(FColDsptr g);

void setg(double a, double b, double c);
Expand Down
18 changes: 18 additions & 0 deletions OndselSolver/ASMTConstantVelocityJoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>

#include "ASMTConstantVelocityJoint.h"
#include "ConstantVelocityJoint.h"

using namespace MbD;

std::shared_ptr<Joint> MbD::ASMTConstantVelocityJoint::mbdClassNew()
{
return CREATE<ConstantVelocityJoint>::With();
}
22 changes: 22 additions & 0 deletions OndselSolver/ASMTConstantVelocityJoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/

#pragma once

#include "ASMTAtPointJoint.h"

namespace MbD {
class EXPORT ASMTConstantVelocityJoint : public ASMTAtPointJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;

};
}

18 changes: 18 additions & 0 deletions OndselSolver/ASMTCylSphJoint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>

#include "ASMTCylSphJoint.h"
#include "CylSphJoint.h"

using namespace MbD;

std::shared_ptr<Joint> MbD::ASMTCylSphJoint::mbdClassNew()
{
return CREATE<CylSphJoint>::With();
}
Loading

0 comments on commit d609d3e

Please sign in to comment.