Skip to content

Commit

Permalink
- Implement toString() method for the QPInverseKinematics
Browse files Browse the repository at this point in the history
- the toString() method is now a virtual method of ILinearTaskSolver
  • Loading branch information
GiulioRomualdi committed Nov 18, 2021
1 parent 62fcb00 commit 47529c2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/IK/include/BipedalLocomotion/IK/QPInverseKinematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class QPInverseKinematics : public IntegrationBasedIK
* nullptr is returned.
*/
std::weak_ptr<Task> getTask(const std::string& name) const override;

/**
* Return the description of the InverseKinematics problem.
* @return a string containing the description of the solver.
*/
std::string toString() const override;
};
} // namespace IK
} // namespace BipedalLocomotion
Expand Down
18 changes: 18 additions & 0 deletions src/IK/src/QPInverseKinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,21 @@ bool QPInverseKinematics::initialize(std::weak_ptr<const ParametersHandler::IPar

return true;
}

std::string QPInverseKinematics::toString() const
{
std::ostringstream oss;

oss << "====== QPInverseKinematics class ======" << std::endl
<< "The optimization problem is composed by the following tasks:" << std::endl;
for (const auto& [name, task] : m_pimpl->tasks)
{
oss << "\t - " << name << ": " << task.task->getDescription()
<< " Priority: " << task.priority << "." << std::endl;
}
oss << "Note: The lower is the integer associated to the priority, the higher is the priority."
<< std::endl
<< "==========================" << std::endl;

return oss.str();
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ template <class _Task, class _State> class ILinearTaskSolver : public Source<_St
*/
virtual std::weak_ptr<Task> getTask(const std::string& name) const = 0;

/**
* Return the description of the solver problem.
* @return a string containing the description of the solver.
*/
virtual std::string toString() const = 0;

/**
* Destructor.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/TSID/include/BipedalLocomotion/TSID/QPTSID.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class QPTSID : public TaskSpaceInverseDynamics
/**
* Return the description of the TSID problem.
*/
std::string toString() const;
std::string toString() const override;
};

} // namespace TSID
Expand Down

0 comments on commit 47529c2

Please sign in to comment.