mc_control::fsm::MetaTasksState Struct Reference

#include <mc_control/fsm/states/MetaTasks.h>

Inheritance diagram for mc_control::fsm::MetaTasksState:
Collaboration diagram for mc_control::fsm::MetaTasksState:

Classes

struct  TaskCriteria
 

Public Member Functions

void configure (const mc_rtc::Configuration &config) override
 
void start (Controller &) override
 
bool run (Controller &) override
 
void teardown (Controller &) override
 
- Public Member Functions inherited from mc_control::fsm::State
virtual ~State ()
 
void configure_ (const mc_rtc::Configuration &config)
 
void start_ (Controller &ctl)
 
void teardown_ (Controller &ctl)
 
virtual void stop (Controller &)
 
virtual bool read_msg (std::string &)
 
virtual bool read_write_msg (std::string &, std::string &)
 
const std::string & output () const noexcept
 
const std::string & name ()
 
void name (const std::string &n)
 

Protected Attributes

std::vector< std::string > outputCrit_
 
std::map< std::string, TaskCriteriacriterias_
 
bool finished_first_ = false
 
- Protected Attributes inherited from mc_control::fsm::State
mc_rtc::Configuration add_contacts_config_
 
mc_rtc::Configuration remove_contacts_config_
 
mc_rtc::Configuration add_contacts_after_config_
 
mc_rtc::Configuration remove_contacts_after_config_
 
mc_rtc::Configuration add_collisions_config_
 
mc_rtc::Configuration remove_collisions_config_
 
mc_rtc::Configuration add_collisions_after_config_
 
mc_rtc::Configuration remove_collisions_after_config_
 
mc_rtc::Configuration constraints_config_
 
mc_rtc::Configuration tasks_config_
 
mc_rtc::Configuration remove_posture_task_
 
mc_rtc::Configuration config_
 
std::vector< mc_solver::ConstraintSetPtrconstraints_
 
std::vector< std::pair< mc_tasks::MetaTaskPtr, mc_rtc::Configuration > > tasks_
 
std::vector< mc_tasks::PostureTaskPtrpostures_
 

Additional Inherited Members

- Protected Member Functions inherited from mc_control::fsm::State
void output (const std::string &o)
 

Detailed Description

Implements a generic tasks state

This tasks creates an arbitrary number of MetaTasks and executes them until completion criteria are fullfiled for each tasks.

The tasks in the state are configured through the "tasks" entry which a JSON object.

The keys are the name of the tasks and values are MetaTask objects as expected by MetaTaskLoader plus an optional "completion" criteria that represents one or more completion criteria.

The names of the tasks are only relevant for the state. You can override the actual task's name using the name entry in the Task's configuration.

If the "completion" entry is absent and if there is no existing completion entry for the related task then this task is added but not considered as part of the completion criteria (e.g. you can add a CoMTask and an EndEffectorTask but only care for the completion of the later).

When the "tasks" entry is read multiple times, the following ensues:

  • if a new tasks appears then it is added
  • if an existing task is not repeated, nothing happens for this task
  • if a task already exists, existing configuration entries are overwriten by the new entry, non-existing configuration entries are simply added to the existing configuration Example:
# First pass, we simplify task entries for the sake of the example
{
"tasks":
{
"t1":
{
"objectiveA": 0.5,
"objectiveB": 1.0,
"completion": { "timeout": 5.0 }
}
}
}
# After this pass, one task is considered
# Second pass
{
"tasks":
{
"t1":
{
"objectiveA": 1.0,
"completion": { "eval": 1e-6 }
},
"t2":
{
"objective": 0.5
}
}
}
# We now have two tasks, and:
# - t1's objectiveA is changed to 1.0, objectiveB is the same
# - t1 completion criteria is replaced
# Third pass
{
"tasks":
{
"t1":
{
"completion": {}
},
"t2":
{
"completion": { "eval": 1e-6 }
}
}
}
# We still have two tasks, objectives are unchanged but:
- t1 has no more completion criteria
- t2 has a completion criteria

Member Function Documentation

◆ configure()

void mc_control::fsm::MetaTasksState::configure ( const mc_rtc::Configuration config)
overridevirtual

Called to configure the state.

This is called multiple times:

  • once for every level of state inheritance
  • once with the executor configuration, this is the FSM global executor, the Meta state executor, the Parallel state or any state that handle other states

The default implementation simply loads the provided configuration into the config_ protected members. You can override this behavior to implement a more complex loading logic.

You can access this configuration either via the config_ variable

Reimplemented from mc_control::fsm::State.

◆ run()

bool mc_control::fsm::MetaTasksState::run ( Controller ctl)
overridevirtual

Called every iteration until it returns true

Implements mc_control::fsm::State.

◆ start()

void mc_control::fsm::MetaTasksState::start ( Controller ctl)
overridevirtual

Called before the state starts being run

This will be called only once with the state fully configured.

Implements mc_control::fsm::State.

◆ teardown()

void mc_control::fsm::MetaTasksState::teardown ( Controller ctl)
overridevirtual

Called right before destruction

Implements mc_control::fsm::State.

Member Data Documentation

◆ criterias_

std::map<std::string, TaskCriteria> mc_control::fsm::MetaTasksState::criterias_
protected

Completion criterias as a map index by task name

◆ finished_first_

bool mc_control::fsm::MetaTasksState::finished_first_ = false
protected

True when the state has already been completed at least once

◆ outputCrit_

std::vector<std::string> mc_control::fsm::MetaTasksState::outputCrit_
protected

Completion criterias used to generate the state's output


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