Skip to content

Commit

Permalink
Fixed a sign mistake in GravityTask.
Browse files Browse the repository at this point in the history
This might have been the reason why the IK was failing before
  • Loading branch information
S-Dafarra committed Aug 3, 2023
1 parent a6078ce commit a3baa19
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/IK/include/BipedalLocomotion/IK/GravityTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace IK
* \begin{bmatrix}
* 1 & 0 & 0 \\
* 0 & 1 & 0
* \end{bmatrix} J_\omega \nu = k \begin{bmatrix}
* \end{bmatrix} J_\omega \nu = -k \begin{bmatrix}
* 0 &-1 & 0 \\
* 1 & 0 & 0
* \end{bmatrix} {} ^ W R_f {} ^ f g ^ * + {} ^ W R_f {} ^ f \omega_{ff}
Expand Down
2 changes: 1 addition & 1 deletion src/IK/src/GravityTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ bool GravityTask::update()
}

toEigen(this->subA(m_robotVelocityVariable)) = m_Am * m_jacobian.bottomRows<3>();
m_b = m_kp * m_bm * desiredZDirectionAbsolute + feedforwardAbsolute.topRows<2>();
m_b = -m_kp * m_bm * desiredZDirectionAbsolute + feedforwardAbsolute.topRows<2>();

m_isValid = true;
return m_isValid;
Expand Down
4 changes: 2 additions & 2 deletions src/IK/tests/GravityTaskTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ TEST_CASE("Distance task")
Eigen::Vector3d axisAbsolute, feedforwardAbsolute;
axisAbsolute = targetRotation * desiredDirection;
feedforwardAbsolute = targetRotation * feedforward;
expectedB(0) = -kp * axisAbsolute(1) + feedforwardAbsolute(0);
expectedB(1) = kp * axisAbsolute(0) + feedforwardAbsolute(1);
expectedB(0) = kp * axisAbsolute(1) + feedforwardAbsolute(0);
expectedB(1) = -kp * axisAbsolute(0) + feedforwardAbsolute(1);
REQUIRE(b.isApprox(expectedB));
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/IK/tests/QPInverseKinematicsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ std::shared_ptr<IParametersHandler> createParameterHandler()
auto distanceTaskHandler = std::make_shared<StdImplementation>();
distanceTaskHandler->setParameter("robot_velocity_variable_name", robotVelocity);
distanceTaskHandler->setParameter("type", "DistanceTask");
distanceTaskHandler->setParameter("priority", 1);
distanceTaskHandler->setParameter("priority", 0);
distanceTaskHandler->setParameter("kp", gain);
Eigen::VectorXd distanceWeight(1);
distanceWeight << additionalTasksWeight;
Expand All @@ -142,7 +142,7 @@ std::shared_ptr<IParametersHandler> createParameterHandler()
auto gravityTaskHandler = std::make_shared<StdImplementation>();
gravityTaskHandler->setParameter("robot_velocity_variable_name", robotVelocity);
gravityTaskHandler->setParameter("type", "GravityTask");
gravityTaskHandler->setParameter("priority", 1);
gravityTaskHandler->setParameter("priority", 0);
gravityTaskHandler->setParameter("kp", gain);
const Eigen::Vector2d gravityWeight = additionalTasksWeight * Eigen::Vector2d::Ones();
gravityTaskHandler->setParameter("weight", gravityWeight);
Expand Down Expand Up @@ -233,13 +233,13 @@ InverseKinematicsAndTasks createIK(std::shared_ptr<IParametersHandler> handler,
REQUIRE(out.distanceTask->setKinDyn(kinDyn));
REQUIRE(out.distanceTask->initialize(handler->getGroup("DISTANCE_TASK")));
REQUIRE(handler->getGroup("DISTANCE_TASK").lock()->getParameter("weight", distanceWeight));
REQUIRE(out.ik->addTask(out.distanceTask, "distance_task", lowPriority, distanceWeight));
REQUIRE(out.ik->addTask(out.distanceTask, "distance_task", highPriority, distanceWeight));

out.gravityTask = std::make_shared<GravityTask>();
REQUIRE(out.gravityTask->setKinDyn(kinDyn));
REQUIRE(out.gravityTask->initialize(handler->getGroup("GRAVITY_TASK")));
REQUIRE(handler->getGroup("GRAVITY_TASK").lock()->getParameter("weight", gravityWeight));
REQUIRE(out.ik->addTask(out.gravityTask, "gravity_task", lowPriority, gravityWeight));
REQUIRE(out.ik->addTask(out.gravityTask, "gravity_task", highPriority, gravityWeight));

REQUIRE(out.ik->finalize(variables));

Expand Down

0 comments on commit a3baa19

Please sign in to comment.