ocra-recipes
Doxygen documentation for the ocra-recipes repository
|
Declaration file of the IFunction interface. More...
#include <ocra/util/MathTypes.h>
#include "ocra/optim/ocra_assert.h"
#include <iostream>
#include <vector>
#include <stdexcept>
Go to the source code of this file.
Classes | |
struct | ocra::return_type_traits< T > |
type and function definitions for the return types. More... | |
class | ocra::IFunction< Property > |
Computation ability of a ocra function. More... | |
Namespaces | |
ocra | |
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization problems dedicated to the control of multi-body systems. | |
Macros | |
#define | DECLARE_SUBTYPE_TRAITS(type, subTypeReturn, preAccess, access) |
#define | DECLARE_FUNCTION_TRAITS(templateArg, propName, returnType, virtualFunctionName, abilityId) |
#define | OCRA_FUNCTION_INTERFACE_LIST(begin, pre, end) |
#define | OCRA_FUNCTION_INTERFACE_COMA , |
#define | OCRA_FUNCTION_INTERFACE_INHERITANCE(inheritanceAccessRight) OCRA_FUNCTION_INTERFACE_LIST(inheritanceAccessRight, OCRA_FUNCTION_INTERFACE_COMA inheritanceAccessRight, ) |
#define | OCRA_APPLY_FUNCTION_ON_ALL_INTERFACE(methodAndArgs) OCRA_FUNCTION_INTERFACE_LIST(, , ::methodAndArgs;) |
#define | OCRA_FUNCTION_INTERFACE_INITIALIZE(usageSet) OCRA_FUNCTION_INTERFACE_LIST(, OCRA_FUNCTION_INTERFACE_COMA, (usageSet)) |
Enumerations | |
enum | ocra::eFunctionAbility { ocra::FUN_VALUE = 0, ocra::PARTIAL_X, ocra::PARTIAL_T, ocra::FUN_DOT, ocra::PARTIAL_X_DOT, ocra::PARTIAL_XX, ocra::FUN_DDOT, ocra::PARTIAL_TT, ocra::PARTIAL_TX, ocra::PARTIAL_XT, ocra::PARTIAL_T_DOT, ocra::PARTIAL_X_DOT_X_DOT, ocra::PROP_NUMBER } |
Enumeration of the computation abilities of a ocra function. More... | |
Functions | |
ocra::DECLARE_SUBTYPE_TRAITS (VectorXd, double,, operator[]) | |
ocra::DECLARE_SUBTYPE_TRAITS (MatrixXd, MatrixXdRow,, row) | |
ocra::DECLARE_SUBTYPE_TRAITS (std::vector< MatrixXd * >, const MatrixXd &,*, operator[]) | |
ocra::DECLARE_FUNCTION_TRAITS (eFunctionAbility Property,, int, updateProperty,-1) | |
ocra::DECLARE_FUNCTION_TRAITS (,< FUN_VALUE >, VectorXd, updateValue, FUN_VALUE) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_X >, MatrixXd, updateJacobian, PARTIAL_X) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_T >, VectorXd, updatePartialT, PARTIAL_T) | |
ocra::DECLARE_FUNCTION_TRAITS (,< FUN_DOT >, VectorXd, updateFdot, FUN_DOT) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_X_DOT >, MatrixXd, updateJdot, PARTIAL_X_DOT) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_XX >, std::vector< MatrixXd * >, updateHessian, PARTIAL_XX) | |
ocra::DECLARE_FUNCTION_TRAITS (,< FUN_DDOT >, VectorXd, updateFddot, FUN_DDOT) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_TT >, VectorXd, updatePartialTT, PARTIAL_TT) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_TX >, MatrixXd, updatePartialTX, PARTIAL_TX) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_XT >, MatrixXd, updatePartialXT, PARTIAL_XT) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_T_DOT >, VectorXd, updatePartialTdot, PARTIAL_T_DOT) | |
ocra::DECLARE_FUNCTION_TRAITS (,< PARTIAL_X_DOT_X_DOT >, VectorXd, updateJdotXdot, PARTIAL_X_DOT_X_DOT) | |
Declaration file of the IFunction interface.
Copyright (C) 2010 CEA/DRT/LIST/DIASI/LSI
Given a (mathematical) function f depending on a set of time-dependant variable x and possibly explicitly of the time t, the coding mechanism to obtain the value at the point of this function or one of its (partial) derivative is always the same, despite the fact that the output spaces can be different. For example, if , is a m-vector and is mxn matrix, yet obtaining this value eventually boils down on a programmer viewpoint to calling a method of a class. The IFunction interface aims at taking advantage of this similarity to factorize code.
On an programmer viewpoint, the object corresponding to a mathematical function can only compute its value at or the value of a derivative if the corresponding method has been implemented. We call ability the capacity of a (c++ object) function to compute such a value. Each possible ability produces a corresponding IFunction.
This file defines several coding mechanims (traits and macros) to make it easy to add and implement new abilities. If you wish to add an ability you need to: (a) add an identifier in the enumeration eFunctionAbility, (b) add a DECLARE_FUNCTION_TRAITS call, with the desired return type for your ability and the name of the function that will compute its value, (c) add a line in the macro OCRA_FUNCTION_INTERFACE_LIST. It is VERY IMPORTANT to add this line at the end of the macros. Failing to do so would mess up with the initialization list of the derived classes in a silent way since default parameters are used. In step (b) you might want to use a type for which a sub_type_traits was not defined yet, in which case you need to add a DECLARE_SUBTYPE_TRAITS call with the proper arguments. Every point where the programmer may want/need to add an entry is flagged by [ADD-IN] in the documentation preceeding the point.
Copyright (C) 2010 CEA/DRT/LIST/DIASI/LSI
Definition in file IFunction.h.
#define DECLARE_FUNCTION_TRAITS | ( | templateArg, | |
propName, | |||
returnType, | |||
virtualFunctionName, | |||
abilityId | |||
) |
Definition at line 178 of file IFunction.h.
#define DECLARE_SUBTYPE_TRAITS | ( | type, | |
subTypeReturn, | |||
preAccess, | |||
access | |||
) |
Definition at line 111 of file IFunction.h.
#define OCRA_APPLY_FUNCTION_ON_ALL_INTERFACE | ( | methodAndArgs | ) | OCRA_FUNCTION_INTERFACE_LIST(, , ::methodAndArgs;) |
Definition at line 412 of file IFunction.h.
#define OCRA_FUNCTION_INTERFACE_COMA , |
Definition at line 396 of file IFunction.h.
#define OCRA_FUNCTION_INTERFACE_INHERITANCE | ( | inheritanceAccessRight | ) | OCRA_FUNCTION_INTERFACE_LIST(inheritanceAccessRight, OCRA_FUNCTION_INTERFACE_COMA inheritanceAccessRight, ) |
Definition at line 403 of file IFunction.h.
#define OCRA_FUNCTION_INTERFACE_INITIALIZE | ( | usageSet | ) | OCRA_FUNCTION_INTERFACE_LIST(, OCRA_FUNCTION_INTERFACE_COMA, (usageSet)) |
Definition at line 418 of file IFunction.h.
#define OCRA_FUNCTION_INTERFACE_LIST | ( | begin, | |
pre, | |||
end | |||
) |
Definition at line 380 of file IFunction.h.