Commit 95d872b6 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

ENH: Finetune drag forces

parent 60662786
......@@ -111,13 +111,13 @@ LineToPointSetCD::computeNeedleMotionDirection()
if (m_needleInsersion == needleMotionState::insertion)
{
if (abs(dotVal) < 0.0001 && dotValNormalized < 0.05)
if (abs(dotVal) < 1.e-6 && dotValNormalized < 5.e-3)
{
m_needleInsersion = needleMotionState::noMovement;
return;
}
if (dotValNormalized < -0.9 && abs(dotVal) < 0.9)
if (dotValNormalized < -0.95 && abs(dotVal) < 0.95)
{
m_needleInsersion = needleMotionState::retraction;
return;
......@@ -126,13 +126,13 @@ LineToPointSetCD::computeNeedleMotionDirection()
if (m_needleInsersion == needleMotionState::retraction)
{
if (abs(dotVal) < 0.0001 && dotValNormalized > 0.05)
if (abs(dotVal) < 1.e-6 && dotValNormalized > 5.e-3)
{
m_needleInsersion = needleMotionState::noMovement;
return;
}
if (dotValNormalized > 0.8 && abs(dotVal) < 0.8)
if (dotValNormalized > 0.95 && abs(dotVal) < 0.95)
{
m_needleInsersion = needleMotionState::insertion;
return;
......@@ -141,54 +141,19 @@ LineToPointSetCD::computeNeedleMotionDirection()
if (m_needleInsersion == needleMotionState::noMovement)
{
if (abs(dotVal) > 0.4 && dotValNormalized > 0.7)
const double threshold = 0.3;
if (abs(dotVal) > threshold && dotValNormalized > threshold)
{
m_needleInsersion = needleMotionState::insertion;
return;
}
if (abs(dotVal) > 0.4 && dotValNormalized < -0.7)
if (abs(dotVal) > threshold && dotValNormalized < -threshold)
{
m_needleInsersion = needleMotionState::retraction;
return;
}
}
/*if (m_needleInsersion != needleMovementState::noMovement)
{
if (abs(movement.dot(m_needleAxis)) > 0.5)
{
if (dotVal > 0.6)
{
m_needleInsersion = needleMovementState::inserting;
}
if (dotVal < -0.6)
{
m_needleInsersion = needleMovementState::retracting;
}
}
}
else
{
if (abs(movement.dot(m_needleAxis)) > 0.4)
{
if (dotVal > 0.6)
{
m_needleInsersion = needleMovementState::inserting;
}
if (dotVal < -0.6)
{
m_needleInsersion = needleMovementState::retracting;
}
}
else
{
m_needleInsersion = needleMovementState::noMovement;
}
}*/
}
}
} // imstk
......@@ -62,6 +62,8 @@ NeedleTissueInteraction::computeContactForces()
m_projConstraints->push_back(s);
}
//std::cout << "State: " << m_needleMotionState << std::endl;
// compute forces
Vec3d force(0., 0., 0.);
for (auto& colData : m_colData.NeedleColData)
......@@ -74,8 +76,8 @@ NeedleTissueInteraction::computeContactForces()
// Drag force (from insertion and retraction)
if (!colData.isOnSurface || m_needleMotionState == 0) { continue;}
double sign = m_needleMotionState == 1 ? 1 : -1;
double randomFactor = 0.6 + 0.4*((double)(std::rand() % 100 + 1) / 100.); // random number 0.6 to 1
const double sign = m_needleMotionState == 1 ? 1 : -1;
const double randomFactor = 0.6 + 0.4*((double)(std::rand() % 100 + 1) / 100.); // random number 0.6 to 1
force -= m_needleAxis*sign*m_scalingFactorSliding*randomFactor;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment