ORCA: Optimization-based framework for Robotic Control Applications
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
orca::common::TaskBase Class Referenceabstract

The common base class for tasks and constraints. More...

#include <TaskBase.h>

+ Inheritance diagram for orca::common::TaskBase:
+ Collaboration diagram for orca::common::TaskBase:

Public Types

enum  State {
  Init = 0, Resized, Activating, Activated,
  Deactivating, Deactivated, Error
}
 Represents the internal state of the task. More...
 
using Ptr = std::shared_ptr< TaskBase >
 
- Public Types inherited from orca::common::ConfigurableOrcaObject
using Ptr = std::shared_ptr< ConfigurableOrcaObject >
 
using ParamMap = std::map< std::string, ParameterBase *>
 

Public Member Functions

 TaskBase (const std::string &name, optim::ControlVariable control_var)
 
virtual ~TaskBase ()
 
bool isActivated () const
 
bool isComputing () const
 
bool setRobotModel (robot::RobotModel::Ptr robot)
 
optim::ControlVariable getControlVariable () const
 
virtual bool activate ()
 
virtual void update (double current_time, double dt)
 
virtual bool deactivate ()
 
virtual void print () const
 
virtual bool setProblem (std::shared_ptr< const orca::optim::Problem > problem)
 
bool hasProblem () const
 
bool hasRobot () const
 
bool dependsOnProblem () const
 
bool dependsOnWrench () const
 
bool dependsOnRobotJoints () const
 
bool dependsOnFloatingBase () const
 
bool hasWrench () const
 
bool isRobotInitialized () const
 
State getState () const
 
void setRampDuration (double ramp_time)
 
double getRampDuration () const
 
double getCurrentRampValue () const
 
double getStartTime () const
 
double getStopTime () const
 
std::shared_ptr< const optim::ProblemgetProblem () const
 
std::shared_ptr< const common::WrenchgetWrench () const
 
std::shared_ptr< const robot::RobotModelgetRobot () const
 
void addChild (TaskBase::Ptr e)
 Add a child/slave task that will be updated BEFORE the parent task. More...
 
bool hasParent () const
 Returns true if the task owned by a parent task. More...
 
bool hasChildren () const
 Returns true if the task has children. More...
 
const std::string & getParentName () const
 Returns the parent name if it exists, empty otherwise. More...
 
const std::string & getPrintableName () const
 Returns the name that include parent name if present. More...
 
void onResizedCallback (std::function< void(void)> cb)
 
void onActivationCallback (std::function< void(void)> cb)
 
void onActivatedCallback (std::function< void(void)> cb)
 
void onComputeBeginCallback (std::function< void(double, double)> cb)
 
void onComputeEndCallback (std::function< void(double, double)> cb)
 
void onDeactivationCallback (std::function< void(void)> cb)
 
void onDeactivatedCallback (std::function< void(void)> cb)
 
- Public Member Functions inherited from orca::common::ConfigurableOrcaObject
 ConfigurableOrcaObject (const std::string &config_name)
 
virtual ~ConfigurableOrcaObject ()
 
template<class T >
void addParameter (const std::string &param_name, Parameter< T > *param, ParamPolicy policy=ParamPolicy::Required, std::function< void()> on_loading_success=0)
 Returns true if all params added with have been set. More...
 
template<class T >
void addParameter (const std::string &param_name, T &param, ParamPolicy policy=ParamPolicy::Required, std::function< void()> on_loading_success=0)
 
ParameterBasegetParameter (const std::string &param_name)
 Returns a param via its name. More...
 
void printParameters () const
 Print all parameters to std::cout. More...
 
bool configureFromFile (const std::string &yaml_url)
 Configure the task from YAML/JSON file. It must contain all the required parameters. More...
 
bool configureFromString (const std::string &yaml_str)
 Configure the task from YAML/JSON string. It must contain all the required parameters. More...
 
bool isConfigured () const
 
const ParamMapgetParameters () const
 
void onConfigureSuccess (std::function< void()> f)
 
- Public Member Functions inherited from orca::common::OrcaObject
 OrcaObject (const std::string &name)
 
virtual ~OrcaObject ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 

Public Attributes

orca::common::MutexRecursive mutex
 The recursive mutex that is locked during the update function. It is up to the external user to lock this mutex to protect the task attributes. More...
 

Protected Member Functions

virtual void resize ()
 
robot::RobotModel::Ptr robot ()
 
std::shared_ptr< Wrenchwrench ()
 
virtual void onResize ()=0
 
virtual void onResized ()
 
virtual void onActivation ()
 
virtual void onActivated ()
 
virtual bool rampUp (double time_since_start)
 
void setRampValue (double new_val)
 
virtual void onCompute (double current_time, double dt)=0
 
virtual bool rampDown (double time_since_stop)
 
virtual void onDeactivation ()
 
virtual void onDeactivated ()
 

Detailed Description

The common base class for tasks and constraints.

This class contains a model of the robot, the problem in which the tasks is currently being used, and a state machine. Although this class is called TaskBase, both tasks and constraints inherit from this.

Member Typedef Documentation

◆ Ptr

using orca::common::TaskBase::Ptr = std::shared_ptr<TaskBase>

Member Enumeration Documentation

◆ State

Represents the internal state of the task.

Enumerator
Init 

Task is instanciated

Resized 

The robot and the problem have been set

Activating 

Task is running but ramping up

Activated 

Task is running

Deactivating 

Task is running but ramping down

Deactivated 

Task has finishing ramping down and is now stopped

Error 

Task update returned an error (not used yet)

Constructor & Destructor Documentation

◆ TaskBase()

TaskBase::TaskBase ( const std::string &  name,
optim::ControlVariable  control_var 
)

◆ ~TaskBase()

TaskBase::~TaskBase ( )
virtual

Member Function Documentation

◆ activate()

bool TaskBase::activate ( )
virtual

◆ addChild()

void TaskBase::addChild ( TaskBase::Ptr  e)

Add a child/slave task that will be updated BEFORE the parent task.

◆ deactivate()

bool TaskBase::deactivate ( )
virtual

◆ dependsOnFloatingBase()

bool TaskBase::dependsOnFloatingBase ( ) const

◆ dependsOnProblem()

bool TaskBase::dependsOnProblem ( ) const

◆ dependsOnRobotJoints()

bool TaskBase::dependsOnRobotJoints ( ) const

◆ dependsOnWrench()

bool TaskBase::dependsOnWrench ( ) const

◆ getControlVariable()

ControlVariable TaskBase::getControlVariable ( ) const

◆ getCurrentRampValue()

double TaskBase::getCurrentRampValue ( ) const

◆ getParentName()

const std::string & TaskBase::getParentName ( ) const

Returns the parent name if it exists, empty otherwise.

◆ getPrintableName()

const std::string & TaskBase::getPrintableName ( ) const

Returns the name that include parent name if present.

◆ getProblem()

std::shared_ptr< const Problem > TaskBase::getProblem ( ) const

◆ getRampDuration()

double TaskBase::getRampDuration ( ) const

◆ getRobot()

std::shared_ptr< const RobotModel > TaskBase::getRobot ( ) const

◆ getStartTime()

double TaskBase::getStartTime ( ) const

◆ getState()

TaskBase::State TaskBase::getState ( ) const

◆ getStopTime()

double TaskBase::getStopTime ( ) const

◆ getWrench()

std::shared_ptr< const Wrench > TaskBase::getWrench ( ) const

◆ hasChildren()

bool TaskBase::hasChildren ( ) const

Returns true if the task has children.

◆ hasParent()

bool TaskBase::hasParent ( ) const

Returns true if the task owned by a parent task.

◆ hasProblem()

bool TaskBase::hasProblem ( ) const

◆ hasRobot()

bool TaskBase::hasRobot ( ) const

◆ hasWrench()

bool TaskBase::hasWrench ( ) const

◆ isActivated()

bool TaskBase::isActivated ( ) const

◆ isComputing()

bool TaskBase::isComputing ( ) const

◆ isRobotInitialized()

bool TaskBase::isRobotInitialized ( ) const

◆ onActivated()

virtual void orca::common::TaskBase::onActivated ( )
inlineprotectedvirtual

◆ onActivatedCallback()

void TaskBase::onActivatedCallback ( std::function< void(void)>  cb)

◆ onActivation()

virtual void orca::common::TaskBase::onActivation ( )
inlineprotectedvirtual

◆ onActivationCallback()

void TaskBase::onActivationCallback ( std::function< void(void)>  cb)

◆ onCompute()

virtual void orca::common::TaskBase::onCompute ( double  current_time,
double  dt 
)
protectedpure virtual

◆ onComputeBeginCallback()

void TaskBase::onComputeBeginCallback ( std::function< void(double, double)>  cb)

◆ onComputeEndCallback()

void TaskBase::onComputeEndCallback ( std::function< void(double, double)>  cb)

◆ onDeactivated()

virtual void orca::common::TaskBase::onDeactivated ( )
inlineprotectedvirtual

Reimplemented in orca::common::Wrench.

◆ onDeactivatedCallback()

void TaskBase::onDeactivatedCallback ( std::function< void(void)>  cb)

◆ onDeactivation()

virtual void orca::common::TaskBase::onDeactivation ( )
inlineprotectedvirtual

◆ onDeactivationCallback()

void TaskBase::onDeactivationCallback ( std::function< void(void)>  cb)

◆ onResize()

virtual void orca::common::TaskBase::onResize ( )
protectedpure virtual

◆ onResized()

virtual void orca::common::TaskBase::onResized ( )
inlineprotectedvirtual

◆ onResizedCallback()

void TaskBase::onResizedCallback ( std::function< void(void)>  cb)

◆ print()

void TaskBase::print ( ) const
virtual

◆ rampDown()

bool TaskBase::rampDown ( double  time_since_stop)
protectedvirtual

Reimplemented in orca::task::GenericTask.

◆ rampUp()

bool TaskBase::rampUp ( double  time_since_start)
protectedvirtual

Reimplemented in orca::task::GenericTask.

◆ resize()

void TaskBase::resize ( )
protectedvirtual

◆ robot()

std::shared_ptr< RobotModel > TaskBase::robot ( )
protected

◆ setProblem()

bool TaskBase::setProblem ( std::shared_ptr< const orca::optim::Problem problem)
virtual

◆ setRampDuration()

void TaskBase::setRampDuration ( double  ramp_time)

◆ setRampValue()

void TaskBase::setRampValue ( double  new_val)
protected

◆ setRobotModel()

bool TaskBase::setRobotModel ( robot::RobotModel::Ptr  robot)

◆ update()

void TaskBase::update ( double  current_time,
double  dt 
)
virtual

◆ wrench()

std::shared_ptr< Wrench > TaskBase::wrench ( )
protected

Member Data Documentation

◆ mutex

orca::common::MutexRecursive orca::common::TaskBase::mutex
mutable

The recursive mutex that is locked during the update function. It is up to the external user to lock this mutex to protect the task attributes.


The documentation for this class was generated from the following files: