Fix #27891: IK stretch gives inaccurate results. Tweaked translation segment
convergence weight a bit to match angles better at typical scales.
This commit is contained in:
@@ -59,6 +59,7 @@ void IK_QJacobian::ArmMatrices(int dof, int task_size)
|
|||||||
|
|
||||||
m_d_theta.newsize(dof);
|
m_d_theta.newsize(dof);
|
||||||
m_d_theta_tmp.newsize(dof);
|
m_d_theta_tmp.newsize(dof);
|
||||||
|
m_d_norm_weight.newsize(dof);
|
||||||
|
|
||||||
m_norm.newsize(dof);
|
m_norm.newsize(dof);
|
||||||
m_norm = 0.0;
|
m_norm = 0.0;
|
||||||
@@ -111,11 +112,13 @@ void IK_QJacobian::SetBetas(int id, int, const MT_Vector3& v)
|
|||||||
m_beta[id+2] = v.z();
|
m_beta[id+2] = v.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IK_QJacobian::SetDerivatives(int id, int dof_id, const MT_Vector3& v)
|
void IK_QJacobian::SetDerivatives(int id, int dof_id, const MT_Vector3& v, MT_Scalar norm_weight)
|
||||||
{
|
{
|
||||||
m_jacobian[id][dof_id] = v.x()*m_weight_sqrt[dof_id];
|
m_jacobian[id][dof_id] = v.x()*m_weight_sqrt[dof_id];
|
||||||
m_jacobian[id+1][dof_id] = v.y()*m_weight_sqrt[dof_id];
|
m_jacobian[id+1][dof_id] = v.y()*m_weight_sqrt[dof_id];
|
||||||
m_jacobian[id+2][dof_id] = v.z()*m_weight_sqrt[dof_id];
|
m_jacobian[id+2][dof_id] = v.z()*m_weight_sqrt[dof_id];
|
||||||
|
|
||||||
|
m_d_norm_weight[dof_id] = norm_weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IK_QJacobian::Invert()
|
void IK_QJacobian::Invert()
|
||||||
@@ -429,7 +432,7 @@ MT_Scalar IK_QJacobian::AngleUpdateNorm() const
|
|||||||
MT_Scalar mx = 0.0, dtheta_abs;
|
MT_Scalar mx = 0.0, dtheta_abs;
|
||||||
|
|
||||||
for (i = 0; i < m_d_theta.size(); i++) {
|
for (i = 0; i < m_d_theta.size(); i++) {
|
||||||
dtheta_abs = MT_abs(m_d_theta[i]);
|
dtheta_abs = MT_abs(m_d_theta[i]*m_d_norm_weight[i]);
|
||||||
if (dtheta_abs > mx)
|
if (dtheta_abs > mx)
|
||||||
mx = dtheta_abs;
|
mx = dtheta_abs;
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
// Iteratively called
|
// Iteratively called
|
||||||
void SetBetas(int id, int size, const MT_Vector3& v);
|
void SetBetas(int id, int size, const MT_Vector3& v);
|
||||||
void SetDerivatives(int id, int dof_id, const MT_Vector3& v);
|
void SetDerivatives(int id, int dof_id, const MT_Vector3& v, MT_Scalar norm_weight);
|
||||||
|
|
||||||
void Invert();
|
void Invert();
|
||||||
|
|
||||||
@@ -89,6 +89,7 @@ private:
|
|||||||
|
|
||||||
/// the vector of computed angle changes
|
/// the vector of computed angle changes
|
||||||
TVector m_d_theta;
|
TVector m_d_theta;
|
||||||
|
TVector m_d_norm_weight;
|
||||||
|
|
||||||
/// space required for SVD computation
|
/// space required for SVD computation
|
||||||
|
|
||||||
|
@@ -95,10 +95,10 @@ void IK_QPositionTask::ComputeJacobian(IK_QJacobian& jacobian)
|
|||||||
MT_Vector3 axis = seg->Axis(i)*m_weight;
|
MT_Vector3 axis = seg->Axis(i)*m_weight;
|
||||||
|
|
||||||
if (seg->Translational())
|
if (seg->Translational())
|
||||||
jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis);
|
jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis, 1e2);
|
||||||
else {
|
else {
|
||||||
MT_Vector3 pa = p.cross(axis);
|
MT_Vector3 pa = p.cross(axis);
|
||||||
jacobian.SetDerivatives(m_id, seg->DoFId()+i, pa);
|
jacobian.SetDerivatives(m_id, seg->DoFId()+i, pa, 1e0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,10 +147,10 @@ void IK_QOrientationTask::ComputeJacobian(IK_QJacobian& jacobian)
|
|||||||
for (i = 0; i < seg->NumberOfDoF(); i++) {
|
for (i = 0; i < seg->NumberOfDoF(); i++) {
|
||||||
|
|
||||||
if (seg->Translational())
|
if (seg->Translational())
|
||||||
jacobian.SetDerivatives(m_id, seg->DoFId()+i, MT_Vector3(0, 0, 0));
|
jacobian.SetDerivatives(m_id, seg->DoFId()+i, MT_Vector3(0, 0, 0), 1e2);
|
||||||
else {
|
else {
|
||||||
MT_Vector3 axis = seg->Axis(i)*m_weight;
|
MT_Vector3 axis = seg->Axis(i)*m_weight;
|
||||||
jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis);
|
jacobian.SetDerivatives(m_id, seg->DoFId()+i, axis, 1e0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,10 +202,10 @@ void IK_QCenterOfMassTask::JacobianSegment(IK_QJacobian& jacobian, MT_Vector3& c
|
|||||||
axis *= /*segment->Mass()**/m_total_mass_inv;
|
axis *= /*segment->Mass()**/m_total_mass_inv;
|
||||||
|
|
||||||
if (segment->Translational())
|
if (segment->Translational())
|
||||||
jacobian.SetDerivatives(m_id, segment->DoFId()+i, axis);
|
jacobian.SetDerivatives(m_id, segment->DoFId()+i, axis, 1e2);
|
||||||
else {
|
else {
|
||||||
MT_Vector3 pa = axis.cross(p);
|
MT_Vector3 pa = axis.cross(p);
|
||||||
jacobian.SetDerivatives(m_id, segment->DoFId()+i, pa);
|
jacobian.SetDerivatives(m_id, segment->DoFId()+i, pa, 1e0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user