Files
solver/GNN/OndselSolver/ScrewConstraintIJ.cpp
forbes-0023 98051ba0c9 feat: add Phase 1 constraint solver addon, move prior content to GNN/
- Move existing OndselSolver, GNN ML layer, and tooling into GNN/
  directory for integration in later phases
- Add Create addon scaffold: package.xml, Init.py
- Add expression DAG with eval, symbolic diff, simplification
- Add parameter table with fixed/free variable tracking
- Add quaternion rotation as polynomial Expr trees
- Add RigidBody entity (7 DOF: position + unit quaternion)
- Add constraint classes: Coincident, DistancePointPoint, Fixed
- Add Newton-Raphson solver with symbolic Jacobian + numpy lstsq
- Add pre-solve passes: substitution + single-equation
- Add DOF counting via Jacobian SVD rank
- Add KindredSolver IKCSolver bridge for kcsolve integration
- Add 82 unit tests covering all modules

Registers as 'kindred' solver via kcsolve.register_solver() when
loaded by Create's addon_loader.
2026-02-20 20:35:47 -06:00

115 lines
2.7 KiB
C++

/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <cmath>
#include "ScrewConstraintIJ.h"
#include "ScrewConstraintIqcJqc.h"
#include "EndFrameqc.h"
using namespace MbD;
MbD::ScrewConstraintIJ::ScrewConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : ConstraintIJ(frmi, frmj)
{
}
std::shared_ptr<ScrewConstraintIJ> MbD::ScrewConstraintIJ::With(EndFrmsptr frmi, EndFrmsptr frmj)
{
assert(frmi->isEndFrameqc());
assert(frmj->isEndFrameqc());
auto screwCon = std::make_shared<ScrewConstraintIqcJqc>(frmi, frmj);
screwCon->initzIeJeIe();
screwCon->initthezIeJe();
return screwCon;
}
void MbD::ScrewConstraintIJ::calcPostDynCorrectorIteration()
{
auto z = zIeJeIe->value();
auto thez = thezIeJe->thez;
aG = (2.0 * M_PI * z) - (pitch * thez) - aConstant;
}
void MbD::ScrewConstraintIJ::init_zthez()
{
throw SimulationStoppingError("To be implemented.");
}
void MbD::ScrewConstraintIJ::initzIeJeIe()
{
throw SimulationStoppingError("To be implemented.");
}
void MbD::ScrewConstraintIJ::initthezIeJe()
{
throw SimulationStoppingError("To be implemented.");
}
void MbD::ScrewConstraintIJ::initialize()
{
ConstraintIJ::initialize();
this->init_zthez();
}
void MbD::ScrewConstraintIJ::initializeGlobally()
{
zIeJeIe->initializeGlobally();
thezIeJe->initializeGlobally();
}
void MbD::ScrewConstraintIJ::initializeLocally()
{
zIeJeIe->initializeLocally();
thezIeJe->initializeLocally();
}
void MbD::ScrewConstraintIJ::postInput()
{
zIeJeIe->postInput();
thezIeJe->postInput();
if (aConstant == std::numeric_limits<double>::min()) {
aConstant = (2.0 * M_PI * zIeJeIe->value()) - (thezIeJe->value() * pitch);
}
ConstraintIJ::postInput();
}
void MbD::ScrewConstraintIJ::postPosICIteration()
{
zIeJeIe->postPosICIteration();
thezIeJe->postPosICIteration();
ConstraintIJ::postPosICIteration();
}
void MbD::ScrewConstraintIJ::preAccIC()
{
zIeJeIe->preAccIC();
thezIeJe->preAccIC();
ConstraintIJ::preAccIC();
}
void MbD::ScrewConstraintIJ::prePosIC()
{
zIeJeIe->prePosIC();
thezIeJe->prePosIC();
ConstraintIJ::prePosIC();
}
void MbD::ScrewConstraintIJ::preVelIC()
{
zIeJeIe->preVelIC();
thezIeJe->preVelIC();
ConstraintIJ::preVelIC();
}
void MbD::ScrewConstraintIJ::simUpdateAll()
{
zIeJeIe->simUpdateAll();
thezIeJe->simUpdateAll();
ConstraintIJ::simUpdateAll();
}