Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clearCalibrationMatrices #47

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/IK/include/BiomechanicalAnalysis/IK/InverseKinematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ class HumanIK
{
std::shared_ptr<BipedalLocomotion::IK::SO3Task> task;
int nodeNumber;
manif::SO3d IMU_R_link; // Rotation matrix from the IMU to related link, set through config
// file
manif::SO3d IMU_R_link; // Rotation matrix from the IMU to related link
manif::SO3d IMU_R_link_init; // Initial value of the rotation matrix from the IMU to related link, set through config
// file
manif::SO3d calibrationMatrix = manif::SO3d::Identity(); // Initialization (to Identity) of
// Rotation matrix from the World
// to the World of the IMU, which
Expand All @@ -151,7 +152,9 @@ class HumanIK
struct GravityTaskStruct
{
std::shared_ptr<BipedalLocomotion::IK::GravityTask> task;
manif::SO3d IMU_R_link;
manif::SO3d IMU_R_link; // Rotation matrix from the IMU to related link
manif::SO3d IMU_R_link_init; // Initial value of the rotation matrix from the IMU to related link, set through config
// file
manif::SO3d calibrationMatrix = manif::SO3d::Identity();
Eigen::Vector2d weight;
int nodeNumber;
Expand Down
15 changes: 8 additions & 7 deletions src/IK/src/InverseKinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,16 @@ bool HumanIK::clearCalibrationMatrices()
for (auto& [node, data] : m_OrientationTasks)
{
data.calibrationMatrix = manif::SO3d::Identity();
data.IMU_R_link = manif::SO3d::Identity();
data.IMU_R_link = m_OrientationTasks[node].IMU_R_link_init;
}
for (auto& [node, data] : m_GravityTasks)
{
data.calibrationMatrix = manif::SO3d::Identity();
data.IMU_R_link = manif::SO3d::Identity();
data.IMU_R_link = m_GravityTasks[node].IMU_R_link_init;
}
return true;
}


bool HumanIK::calibrateWorldYaw(std::unordered_map<int, nodeData> nodeStruct)
{
// reset the robot state
Expand Down Expand Up @@ -624,7 +623,7 @@ bool HumanIK::initializeOrientationTask(const std::string& taskName,
if (taskHandler->getParameter("rotation_matrix", rotation_matrix))
{
// Convert rotation matrix to ManifRot and assign it to IMU_R_link
m_OrientationTasks[nodeNumber].IMU_R_link
m_OrientationTasks[nodeNumber].IMU_R_link_init
= BipedalLocomotion::Conversions::toManifRot(Eigen::Map<Eigen::Matrix<double, 3, 3, Eigen::RowMajor>>(rotation_matrix.data()));
} else
{
Expand All @@ -637,8 +636,9 @@ bool HumanIK::initializeOrientationTask(const std::string& taskName,
logPrefix,
taskName,
frame_name);
m_OrientationTasks[nodeNumber].IMU_R_link.setIdentity();
m_OrientationTasks[nodeNumber].IMU_R_link_init.setIdentity();
}
m_OrientationTasks[nodeNumber].IMU_R_link = m_OrientationTasks[nodeNumber].IMU_R_link_init;
//*****************************************************************************************************

// Initialize the SO3Task object
Expand Down Expand Up @@ -714,7 +714,7 @@ bool HumanIK::initializeGravityTask(const std::string& taskName,
if (taskHandler->getParameter("rotation_matrix", rotation_matrix))
{
// Convert rotation matrix to ManifRot and assign it to IMU_R_link
m_GravityTasks[nodeNumber].IMU_R_link
m_GravityTasks[nodeNumber].IMU_R_link_init
= BipedalLocomotion::Conversions::toManifRot(Eigen::Map<Eigen::Matrix<double, 3, 3, Eigen::RowMajor>>(rotation_matrix.data()));
} else
{
Expand All @@ -727,8 +727,9 @@ bool HumanIK::initializeGravityTask(const std::string& taskName,
logPrefix,
taskName,
frame_name);
m_GravityTasks[nodeNumber].IMU_R_link.setIdentity();
m_GravityTasks[nodeNumber].IMU_R_link_init.setIdentity();
}
m_GravityTasks[nodeNumber].IMU_R_link = m_GravityTasks[nodeNumber].IMU_R_link_init;

//*****************************************************************************************************

Expand Down
Loading