mc_tasks::MetaTask Struct Referenceabstract

Represents a generic task. More...

#include <mc_tasks/MetaTask.h>

Inheritance diagram for mc_tasks::MetaTask:

Public Types

using Backend = mc_solver::QPSolver::Backend
 

Public Member Functions

 MetaTask ()
 
virtual ~MetaTask ()
 
const std::string & type () const
 
virtual void name (const std::string &name)
 
const std::string & name () const
 
virtual void reset ()=0
 Reset the task. More...
 
virtual void dimWeight (const Eigen::VectorXd &dimW)=0
 Set the task's dimension weight vector. More...
 
virtual Eigen::VectorXd dimWeight () const =0
 Get the current task's dim weight vector. More...
 
virtual void selectActiveJoints (mc_solver::QPSolver &solver, const std::vector< std::string > &activeJointsName, const std::map< std::string, std::vector< std::array< int, 2 >>> &activeDofs={})=0
 Setup an active joints selector. More...
 
virtual void selectUnactiveJoints (mc_solver::QPSolver &solver, const std::vector< std::string > &unactiveJointsName, const std::map< std::string, std::vector< std::array< int, 2 >>> &unactiveDofs={})=0
 Setup an unactive joints selector. More...
 
virtual void resetJointsSelector (mc_solver::QPSolver &solver)=0
 Reset active joints selection. More...
 
virtual Eigen::VectorXd eval () const =0
 Returns the task error. More...
 
virtual Eigen::VectorXd speed () const =0
 Returns the task velocity. More...
 
virtual void load (mc_solver::QPSolver &solver, const mc_rtc::Configuration &config)
 Load parameters from a Configuration object. More...
 
size_t iterInSolver () const noexcept
 Get the number of iterations since the task was added to the solver. More...
 
void resetIterInSolver () noexcept
 Set the number of iterations since the task was added to the solver to zero. More...
 
void incrementIterInSolver () noexcept
 Increment the number of iterations since the task was added to the solver. More...
 
Backend backend () const noexcept
 

Protected Member Functions

virtual void addToSolver (mc_solver::QPSolver &solver)=0
 Add the task to a solver. More...
 
virtual void removeFromSolver (mc_solver::QPSolver &solver)=0
 Remove the task from a solver. More...
 
virtual void update (mc_solver::QPSolver &solver)=0
 Update the task. More...
 
virtual void addToLogger (mc_rtc::Logger &)
 
virtual void removeFromLogger (mc_rtc::Logger &)
 
virtual void addToGUI (mc_rtc::gui::StateBuilder &)
 
virtual void removeFromGUI (mc_rtc::gui::StateBuilder &)
 
virtual std::function< bool(const mc_tasks::MetaTask &task, std::string &)> buildCompletionCriteria (double dt, const mc_rtc::Configuration &config) const
 

Static Protected Member Functions

static void addToSolver (MetaTask &t, mc_solver::QPSolver &solver)
 
static void removeFromSolver (MetaTask &t, mc_solver::QPSolver &solver)
 
static void update (MetaTask &t, mc_solver::QPSolver &solver)
 
static void addToLogger (MetaTask &t, mc_rtc::Logger &logger)
 
static void removeFromLogger (MetaTask &t, mc_rtc::Logger &logger)
 
static void addToGUI (MetaTask &t, mc_rtc::gui::StateBuilder &gui)
 
static void removeFromGUI (MetaTask &t, mc_rtc::gui::StateBuilder &gui)
 
static void ensureHasJoints (const mc_rbdyn::Robot &robot, const std::vector< std::string > &joints, const std::string &prefix)
 

Protected Attributes

Backend backend_
 
std::string type_
 
std::string name_
 
size_t iterInSolver_ = 0
 

Friends

struct mc_solver::QPSolver
 
struct mc_solver::TasksQPSolver
 
struct mc_solver::TVMQPSolver
 
struct mc_control::CompletionCriteria
 

Detailed Description

Represents a generic task.

A meta task may be composed of several tasks that work together to achieve a given goal

Member Typedef Documentation

◆ Backend

Shortcut for implementation

Constructor & Destructor Documentation

◆ MetaTask()

mc_tasks::MetaTask::MetaTask ( )
inline

◆ ~MetaTask()

virtual mc_tasks::MetaTask::~MetaTask ( )
virtual

Member Function Documentation

◆ addToGUI() [1/2]

◆ addToGUI() [2/2]

static void mc_tasks::MetaTask::addToGUI ( MetaTask t,
mc_rtc::gui::StateBuilder gui 
)
inlinestaticprotected

Helper function to add a task to the gui when using another MetaTask inside a MetaTask

◆ addToLogger() [1/2]

◆ addToLogger() [2/2]

static void mc_tasks::MetaTask::addToLogger ( MetaTask t,
mc_rtc::Logger logger 
)
inlinestaticprotected

Helper function to add a task to the logger when using another MetaTask inside a MetaTask

◆ addToSolver() [1/2]

virtual void mc_tasks::MetaTask::addToSolver ( mc_solver::QPSolver solver)
protectedpure virtual

◆ addToSolver() [2/2]

static void mc_tasks::MetaTask::addToSolver ( MetaTask t,
mc_solver::QPSolver solver 
)
inlinestaticprotected

Helper function when using another MetaTask inside a MetaTask as adding the task through the solver interface has important side-effects

◆ backend()

Backend mc_tasks::MetaTask::backend ( ) const
inlinenoexcept

◆ buildCompletionCriteria()

virtual std::function<bool(const mc_tasks::MetaTask & task, std::string &)> mc_tasks::MetaTask::buildCompletionCriteria ( double  dt,
const mc_rtc::Configuration config 
) const
protectedvirtual

Add additional completion criterias to mc_control::CompletionCriteria object

Based on the input data, this should return a function that operates on the task and return true and complete the output if the criteria has been reached. In this function parameter, the output string should be completed by the function and not overwritten. The task passed to this function is always of the MetaTask type you're implementing and thus can be safely casted.

The default implementation is a function that returns true whatever happens.

Parameters
dtTimestep of the completion criteria
configConfiguration for the CompletionCriteria

Reimplemented in mc_tasks::TrajectoryTaskGeneric, mc_tasks::TransformTask, mc_tasks::force::CoPTask, mc_tasks::SplineTrajectoryTask< Derived >, mc_tasks::SplineTrajectoryTask< ExactCubicTrajectoryTask >, and mc_tasks::SplineTrajectoryTask< BSplineTrajectoryTask >.

◆ dimWeight() [1/2]

virtual Eigen::VectorXd mc_tasks::MetaTask::dimWeight ( ) const
pure virtual

◆ dimWeight() [2/2]

virtual void mc_tasks::MetaTask::dimWeight ( const Eigen::VectorXd &  dimW)
pure virtual

Set the task's dimension weight vector.

It is the caller responsibility to ensure the dimensionality fits the underlying tasks' error function

Parameters
dimWThe new tasks's dimension weight vector

Implemented in mc_tasks::TrajectoryTaskGeneric, mc_tasks::force::ComplianceTask, mc_tasks::AddRemoveContactTask, mc_tasks::SplineTrajectoryTask< Derived >, mc_tasks::SplineTrajectoryTask< ExactCubicTrajectoryTask >, mc_tasks::SplineTrajectoryTask< BSplineTrajectoryTask >, mc_tasks::EndEffectorTask, and mc_tasks::PostureTask.

◆ ensureHasJoints()

static void mc_tasks::MetaTask::ensureHasJoints ( const mc_rbdyn::Robot robot,
const std::vector< std::string > &  joints,
const std::string &  prefix 
)
inlinestaticprotected

◆ eval()

virtual Eigen::VectorXd mc_tasks::MetaTask::eval ( ) const
pure virtual

◆ incrementIterInSolver()

void mc_tasks::MetaTask::incrementIterInSolver ( )
inlinenoexcept

Increment the number of iterations since the task was added to the solver.

◆ iterInSolver()

size_t mc_tasks::MetaTask::iterInSolver ( ) const
inlinenoexcept

Get the number of iterations since the task was added to the solver.

◆ load()

◆ name() [1/2]

const std::string& mc_tasks::MetaTask::name ( ) const
inline

Get the name of the task

◆ name() [2/2]

virtual void mc_tasks::MetaTask::name ( const std::string &  name)
inlinevirtual

Set a name for the task

This name will be used to identify the task in logs, GUI...

The name should be set before being added to the solver.

Reimplemented in mc_tasks::lipm_stabilizer::StabilizerTask, and mc_tasks::EndEffectorTask.

◆ removeFromGUI() [1/2]

virtual void mc_tasks::MetaTask::removeFromGUI ( mc_rtc::gui::StateBuilder )
protectedvirtual

Remove elements from the GUI through the helper

This will be called by the solver when the task is removed.

The default implementation removes the {"Tasks", name_} category.

Reimplemented in mc_tasks::lipm_stabilizer::StabilizerTask.

◆ removeFromGUI() [2/2]

static void mc_tasks::MetaTask::removeFromGUI ( MetaTask t,
mc_rtc::gui::StateBuilder gui 
)
inlinestaticprotected

Helper function to remove a task from the gui when using another MetaTask inside a MetaTask

◆ removeFromLogger() [1/2]

virtual void mc_tasks::MetaTask::removeFromLogger ( mc_rtc::Logger )
protectedvirtual

Remove entries from the logger

This will be called by the solver when the task is removed.

The default implementation removes everything registered with the MetaTask instance as a source, it is likely good enough

Reimplemented in mc_tasks::EndEffectorTask, and mc_tasks::lipm_stabilizer::StabilizerTask.

◆ removeFromLogger() [2/2]

static void mc_tasks::MetaTask::removeFromLogger ( MetaTask t,
mc_rtc::Logger logger 
)
inlinestaticprotected

Helper function to remove a task from the logger when using another MetaTask inside a MetaTask

◆ removeFromSolver() [1/2]

virtual void mc_tasks::MetaTask::removeFromSolver ( mc_solver::QPSolver solver)
protectedpure virtual

Remove the task from a solver.

Parameters
solverSolver from which to remove the task

Implemented in mc_tasks::lipm_stabilizer::StabilizerTask, mc_tasks::TrajectoryTaskGeneric, mc_tasks::PostureTask, and mc_tasks::EndEffectorTask.

◆ removeFromSolver() [2/2]

static void mc_tasks::MetaTask::removeFromSolver ( MetaTask t,
mc_solver::QPSolver solver 
)
inlinestaticprotected

Helper function when using another MetaTask inside a MetaTask as removing the task through the solver interface has important side-effects

◆ reset()

◆ resetIterInSolver()

void mc_tasks::MetaTask::resetIterInSolver ( )
inlinenoexcept

Set the number of iterations since the task was added to the solver to zero.

◆ resetJointsSelector()

virtual void mc_tasks::MetaTask::resetJointsSelector ( mc_solver::QPSolver solver)
pure virtual

Reset active joints selection.

Parameters
solverSolver where the task is involved

Implemented in mc_tasks::TrajectoryTaskGeneric, mc_tasks::force::ComplianceTask, mc_tasks::EndEffectorTask, and mc_tasks::PostureTask.

◆ selectActiveJoints()

virtual void mc_tasks::MetaTask::selectActiveJoints ( mc_solver::QPSolver solver,
const std::vector< std::string > &  activeJointsName,
const std::map< std::string, std::vector< std::array< int, 2 >>> &  activeDofs = {} 
)
pure virtual

Setup an active joints selector.

This function setups a tasks::qp;:JointsSelector for the task. Only the provided joints will be used to solve the task.

Note
Calling this method or the related selectUnactiveJoints should reset the current joints' selection
Parameters
solverSolver where the task is involved
activeJointsNameActive joints in the task
activeDofsAllow to select only part of the dofs of a joint

Implemented in mc_tasks::TrajectoryTaskGeneric, mc_tasks::force::ComplianceTask, mc_tasks::EndEffectorTask, and mc_tasks::PostureTask.

◆ selectUnactiveJoints()

virtual void mc_tasks::MetaTask::selectUnactiveJoints ( mc_solver::QPSolver solver,
const std::vector< std::string > &  unactiveJointsName,
const std::map< std::string, std::vector< std::array< int, 2 >>> &  unactiveDofs = {} 
)
pure virtual

Setup an unactive joints selector.

This function setups a tasks::qp;:JointsSelector for the task. All joints will be used to realize the task except those provided here.

Note
Calling this method or the related selectActiveJoints should reset the current joints' selection
Parameters
solverSolver where the task is involved
unactiveJointsNameActive joints in the task
unactiveDofsAllow to select only part of the dofs of a joint

Implemented in mc_tasks::TrajectoryTaskGeneric, mc_tasks::force::ComplianceTask, mc_tasks::EndEffectorTask, and mc_tasks::PostureTask.

◆ speed()

virtual Eigen::VectorXd mc_tasks::MetaTask::speed ( ) const
pure virtual

◆ type()

const std::string& mc_tasks::MetaTask::type ( ) const
inline

Get the type of the task

◆ update() [1/2]

virtual void mc_tasks::MetaTask::update ( mc_solver::QPSolver solver)
protectedpure virtual

◆ update() [2/2]

static void mc_tasks::MetaTask::update ( MetaTask t,
mc_solver::QPSolver solver 
)
inlinestaticprotected

Helper function when using another MetaTask inside a MetaTask

Friends And Related Function Documentation

◆ mc_control::CompletionCriteria

friend struct mc_control::CompletionCriteria
friend

◆ mc_solver::QPSolver

friend struct mc_solver::QPSolver
friend

◆ mc_solver::TasksQPSolver

friend struct mc_solver::TasksQPSolver
friend

◆ mc_solver::TVMQPSolver

friend struct mc_solver::TVMQPSolver
friend

Member Data Documentation

◆ backend_

Backend mc_tasks::MetaTask::backend_
protected

QPSolver backend at creation time

◆ iterInSolver_

size_t mc_tasks::MetaTask::iterInSolver_ = 0
protected

◆ name_

std::string mc_tasks::MetaTask::name_
protected

◆ type_

std::string mc_tasks::MetaTask::type_
protected

The documentation for this struct was generated from the following file: