Skip to content

Commit

Permalink
Add the possibility to enable/disable the SE3Task controller in IK co…
Browse files Browse the repository at this point in the history
…mponent
  • Loading branch information
GiulioRomualdi committed Apr 26, 2021
1 parent 738593b commit ccdc259
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/IK/include/BipedalLocomotion/IK/SE3Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class SE3Task : public System::LinearTask
std::shared_ptr<iDynTree::KinDynComputations> m_kinDyn; /**< Pointer to a KinDynComputations
object */

double m_kpLinear;
double m_kpAngular;

public:

/**
Expand Down Expand Up @@ -118,6 +121,10 @@ class SE3Task : public System::LinearTask
*/
bool setSetPoint(const manif::SE3d& I_H_F, const manif::SE3d::Tangent& mixedVelocity);

void enableControl();

void disableControl();

/**
* Get the size of the task. (I.e the number of rows of the vector b)
* @return the size of the task.
Expand Down
23 changes: 17 additions & 6 deletions src/IK/src/SE3Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ bool SE3Task::initialize(std::weak_ptr<ParametersHandler::IParametersHandler> pa
}

// set the gains for the controllers
double kpLinear;
double kpAngular;
if (!ptr->getParameter("kp_linear", kpLinear))

if (!ptr->getParameter("kp_linear", m_kpLinear))
{
log()->error("{}, [{} {}] Unable to get the proportional linear gain.",
errorPrefix,
Expand All @@ -134,7 +133,7 @@ bool SE3Task::initialize(std::weak_ptr<ParametersHandler::IParametersHandler> pa
return false;
}

if (!ptr->getParameter("kp_angular", kpAngular))
if (!ptr->getParameter("kp_angular", m_kpAngular))
{
log()->error("{}, [{} {}] Unable to get the proportional angular gain.",
errorPrefix,
Expand All @@ -143,8 +142,8 @@ bool SE3Task::initialize(std::weak_ptr<ParametersHandler::IParametersHandler> pa
return false;
}

m_R3Controller.setGains(kpLinear);
m_SO3Controller.setGains(kpAngular);
m_R3Controller.setGains(m_kpLinear);
m_SO3Controller.setGains(m_kpAngular);

// set the description
m_description = std::string(descriptionPrefix) + frameName + ".";
Expand Down Expand Up @@ -211,3 +210,15 @@ bool SE3Task::isValid() const
{
return m_isValid;
}

void SE3Task::enableControl()
{
m_R3Controller.setGains(m_kpLinear);
m_SO3Controller.setGains(m_kpAngular);
}

void SE3Task::disableControl()
{
m_R3Controller.setGains(0);
m_SO3Controller.setGains(0);
}

0 comments on commit ccdc259

Please sign in to comment.