Skip to content

Commit

Permalink
Add integretor reset on calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
dariosortino committed Apr 30, 2024
1 parent 48d0147 commit 44ae3a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class hde::algorithms::DynamicalInverseKinematics

void clearProblem();

bool solve(const double dt);
bool solve(const double dt, bool* reset = nullptr);

double getTargetsMeanOrientationErrorNorm() const;
double getTargetsMeanPositionErrorNorm() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ bool DynamicalInverseKinematics::getBaseVelocitySolution(iDynTree::Vector3& line
return true;
}

bool DynamicalInverseKinematics::solve(const double dt)
bool DynamicalInverseKinematics::solve(const double dt, bool* reset)
{
return pImpl->solveProblem(dt);
}
Expand Down
9 changes: 8 additions & 1 deletion devices/HumanStateProvider/HumanStateProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,14 +1557,20 @@ void HumanStateProvider::impl::computeSecondaryCalibrationRotationsForChain(cons
{
// initialize vectors
iDynTree::VectorDynSize jointPos(jointConfigurationSolution);
jointPos.zero();
iDynTree::VectorDynSize jointVel(jointVelocitiesSolution);
jointVel.zero();
iDynTree::Twist baseVel;
baseVel.zero();

for (auto const& jointZeroIdx: jointZeroIndices) {
jointPos.setVal(jointZeroIdx, jointCalibrationSolution.getVal(jointZeroIdx));
std::cout << "jointPos: " << jointPos.getVal(jointZeroIdx) << std::endl;
}

std::lock_guard<std::mutex> lock(mutexFlagIntegrator);
resetIntegrator = true;

// TODO check which value to give to the base (before we were using the base target measurement)
kinDynComputations->setRobotState(iDynTree::Transform::Identity(), jointPos, baseVel, jointVel, worldGravity);

Expand Down Expand Up @@ -2334,7 +2340,8 @@ bool HumanStateProvider::impl::solveDynamicalInverseKinematics()
}
}

if (!dynamicalInverseKinematics.solve(dt))
std::lock_guard<std::mutex> lock(mutexFlagIntegrator);
if (!dynamicalInverseKinematics.solve(dt, &resetIntegrator))
return false;

dynamicalInverseKinematics.getConfigurationSolution(baseTransformSolution, jointConfigurationSolution);
Expand Down
2 changes: 2 additions & 0 deletions devices/HumanStateProvider/HumanStateProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class hde::devices::HumanStateProvider final
private:
class impl;
std::unique_ptr<impl> pImpl;
std::mutex mutexFlagIntegrator;
bool resetIntegrator = false;

public:
HumanStateProvider();
Expand Down

0 comments on commit 44ae3a3

Please sign in to comment.