Commit 41f00312 authored by andreadelprete's avatar andreadelprete
Browse files

[tsid-formulations] Add method to change the weight of a task.

parent 837ab1e3
......@@ -109,6 +109,9 @@ namespace tsid
unsigned int priorityLevel,
double transition_duration=0.0);
bool updateTaskWeight(const std::string & task_name,
double weight);
bool addRigidContact(ContactBase & contact);
bool removeTask(const std::string & taskName,
......
......@@ -46,6 +46,7 @@ namespace tsid
typedef tasks::TaskMotion TaskMotion;
typedef tasks::TaskContactForce TaskContactForce;
typedef tasks::TaskActuation TaskActuation;
typedef tasks::TaskBase TaskBase;
typedef contacts::ContactBase ContactBase;
typedef solvers::HQPData HQPData;
typedef solvers::HQPOutput HQPOutput;
......@@ -77,6 +78,9 @@ namespace tsid
unsigned int priorityLevel,
double transition_duration=0.0) = 0;
virtual bool updateTaskWeight(const std::string & task_name,
double weight) = 0;
virtual bool addRigidContact(ContactBase & contact) = 0;
virtual bool removeTask(const std::string & taskName,
......
......@@ -181,6 +181,37 @@ bool InverseDynamicsFormulationAccForce::addTorqueTask(TaskActuation & task,
return true;
}
bool InverseDynamicsFormulationAccForce::updateTaskWeight(const std::string & task_name,
double weight)
{
std::vector<TaskLevel*>::iterator it;
for(it=m_taskMotions.begin(); it!=m_taskMotions.end(); it++)
{
if((*it)->task.name()==task_name)
{
(*it)->weight = weight;
return true;
}
}
for(it=m_taskContactForces.begin(); it!=m_taskContactForces.end(); it++)
{
if((*it)->task.name()==task_name)
{
(*it)->weight = weight;
return true;
}
}
for(it=m_taskActuations.begin(); it!=m_taskActuations.end(); it++)
{
if((*it)->task.name()==task_name)
{
(*it)->weight = weight;
return true;
}
}
return false;
}
bool InverseDynamicsFormulationAccForce::addRigidContact(ContactBase & contact)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment