Skip to content
Snippets Groups Projects
Commit 2284f5e7 authored by Sonja Marahrens's avatar Sonja Marahrens
Browse files

fixed nullspace calculation

parent 0ea5207b
No related branches found
No related tags found
No related merge requests found
......@@ -58,21 +58,21 @@ Eigen::VectorXf CartesianVelocityController::calculate(const Eigen::VectorXf& ca
inv = ik->computePseudoInverseJacobianMatrix(jacobi, ik->getJacobiRegularization(mode));
// ARMARX_IMPORTANT << "nullspaceVel " << nullspaceVel.transpose();
// Eigen::FullPivLU<Eigen::MatrixXf> lu_decomp(jacobi);
Eigen::FullPivLU<Eigen::MatrixXf> lu_decomp(jacobi);
//ARMARX_IMPORTANT << "The rank of the jacobi is " << lu_decomp.rank();
//ARMARX_IMPORTANT << "Null space: " << lu_decomp.kernel();
// Eigen::MatrixXf nullspace = lu_decomp.kernel();
Eigen::MatrixXf nullspace = lu_decomp.kernel();
Eigen::MatrixXf nullspace = Eigen::MatrixXf::Identity(jacobi.cols(), jacobi.cols()) - inv * jacobi;
// Eigen::MatrixXf nullspace = Eigen::MatrixXf::Identity(jacobi.cols(), jacobi.cols()) - inv * jacobi;
// Eigen::VectorXf nsv = Eigen::VectorXf::Zero(nullspace.rows());
// for (int i = 0; i < nullspace.cols(); i++)
// {
// nsv += nullspace.col(i) * nullspace.col(i).dot(nullspaceVel) / nullspace.col(i).squaredNorm();
// }
Eigen::VectorXf nsv = Eigen::VectorXf::Zero(nullspace.rows());
for (int i = 0; i < nullspace.cols(); i++)
{
nsv += nullspace.col(i) * nullspace.col(i).dot(nullspaceVel) / nullspace.col(i).squaredNorm();
}
Eigen::VectorXf nsv = nullspace * nullspaceVel;
// Eigen::VectorXf nsv = nullspace * nullspaceVel;
//nsv /= kernel.cols();
......
......@@ -45,22 +45,13 @@ void CartesianVelocityControllerWithRamp::setCurrentJointVelocity(const Eigen::V
Eigen::MatrixXf nullspace = lu_decomp.kernel();
Eigen::VectorXf nsv = Eigen::VectorXf::Zero(nullspace.rows());
// int r = lu_decomp.rank();
// Eigen::MatrixXf nullspace = Eigen::MatrixXf::Zero(r, V.cols());
// Eigen::VectorXf nsv = Eigen::VectorXf::Zero(nullspace.rows());
// for (int i = 0; i < nullspace.cols(); i++)
// {
// nsv += nullspace.col(i) * nullspace.col(i).dot(currentJointVelocity) / nullspace.col(i).squaredNorm();
// }
for (int i = 0; i < nullspace.cols(); i++)
{
nsv += nullspace.col(i) * nullspace.col(i).dot(currentJointVelocity) / nullspace.col(i).squaredNorm();
}
cartesianVelocityRamp.setState(jacobi * currentJointVelocity, mode);
// nullSpaceVelocityRamp.setState(nsv);
nullSpaceVelocityRamp.setState(currentJointVelocity - inv * jacobi * currentJointVelocity);
// ARMARX_IMPORTANT << "nsv " << currentJointVelocity - inv* jacobi* currentJointVelocity;
nullSpaceVelocityRamp.setState(nsv);
}
Eigen::VectorXf CartesianVelocityControllerWithRamp::calculate(const Eigen::VectorXf& cartesianVel, float jointLimitAvoidanceScale, float dt)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment