DMP_BBO library
Public Member Functions | Protected Member Functions | Friends | List of all members
DmpContextualTwoStep Class Reference

Implementation of Contextual Dynamical Movement Primitives. More...

#include <DmpContextualTwoStep.hpp>

Inheritance diagram for DmpContextualTwoStep:
Inheritance graph
[legend]
Collaboration diagram for DmpContextualTwoStep:
Collaboration graph
[legend]

Public Member Functions

 DmpContextualTwoStep (int n_dims_dmp, std::vector< FunctionApproximator * > function_approximators, FunctionApproximator *policy_parameter_function, DmpType dmp_type=KULVICIUS_2012_JOINING)
 Initialization constructor for Contextual DMPs of known dimensionality, but with unknown initial and attractor states. More...
 
void computeFunctionApproximatorOutput (const Eigen::Ref< const Eigen::MatrixXd > &phase_state, Eigen::MatrixXd &fa_output) const
 Compute the outputs of the function approximators. More...
 
void train (const std::vector< Trajectory > &trajectories, const std::vector< Eigen::MatrixXd > &task_parameters, std::string save_directory="", bool overwrite=true)
 Train a contextual Dmp with a set of trajectories (and save results to file) This function is useful for debugging, i.e. More...
 
bool isTrained (void) const
 Return whether the DMP is trained or not. More...
 
- Public Member Functions inherited from DmpContextual
 DmpContextual (int n_dims_dmp, std::vector< FunctionApproximator * > function_approximators, DmpType dmp_type)
 Initialization constructor for Contextual DMPs of known dimensionality, but with unknown initial and attractor states. More...
 
void set_task_parameters (const Eigen::MatrixXd &task_parameters)
 Set the current task parameters. More...
 
void set_policy_parameter_function_goal (FunctionApproximator *function_approximator)
 Set a function approximator to predict the goal from the task parameters. More...
 
void set_policy_parameter_function_duration (FunctionApproximator *function_approximator)
 Set a function approximator to predict the duration from the task parameters. More...
 
void train (const std::vector< Trajectory > &trajectories, const std::vector< Eigen::MatrixXd > &task_parameters, std::string save_directory)
 Train a contextual DMP with multiple trajectories. More...
 
void train (const std::vector< Trajectory > &trajectories, const std::vector< Eigen::MatrixXd > &task_parameters)
 Train a contextual DMP with multiple trajectories. More...
 
void train (const std::vector< Trajectory > &trajectories, std::string save_directory, bool overwrite)
 Train a contextual DMP with multiple trajectories. More...
 
void train (const std::vector< Trajectory > &trajectories, std::string save_directory)
 Train a contextual DMP with multiple trajectories. More...
 
void train (const std::vector< Trajectory > &trajectories)
 Train a contextual DMP with multiple trajectories. More...
 
- Public Member Functions inherited from Dmp
 Dmp (double tau, Eigen::VectorXd y_init, Eigen::VectorXd y_attr, std::vector< FunctionApproximator * > function_approximators, double alpha_spring_damper, DynamicalSystem *goal_system, DynamicalSystem *phase_system, DynamicalSystem *gating_system, ForcingTermScaling scaling=NO_SCALING)
 Initialization constructor. More...
 
 Dmp (int n_dims_dmp, std::vector< FunctionApproximator * > function_approximators, double alpha_spring_damper, DynamicalSystem *goal_system, DynamicalSystem *phase_system, DynamicalSystem *gating_system, ForcingTermScaling scaling=NO_SCALING)
 Initialization constructor for Dmps of known dimensionality, but with unknown initial and attractor states. More...
 
 Dmp (double tau, Eigen::VectorXd y_init, Eigen::VectorXd y_attr, std::vector< FunctionApproximator * > function_approximators, DmpType dmp_type=KULVICIUS_2012_JOINING, ForcingTermScaling scaling=NO_SCALING)
 Constructor that initializes the DMP with default dynamical systems. More...
 
 Dmp (int n_dims_dmp, std::vector< FunctionApproximator * > function_approximators, DmpType dmp_type=KULVICIUS_2012_JOINING, ForcingTermScaling scaling=NO_SCALING)
 Initialization constructor for Dmps of known dimensionality, but with unknown initial and attractor states. More...
 
 Dmp (double tau, Eigen::VectorXd y_init, Eigen::VectorXd y_attr, double alpha_spring_damper, DynamicalSystem *goal_system)
 Initialization constructor for Dmps without a forcing term. More...
 
 ~Dmp (void)
 Destructor. More...
 
Dmpclone (void) const
 Return a deep copy of this object. More...
 
virtual void integrateStart (Eigen::Ref< Eigen::VectorXd > x, Eigen::Ref< Eigen::VectorXd > xd) const
 Start integrating the system. More...
 
void differentialEquation (const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::VectorXd > xd) const
 The differential equation which defines the system. More...
 
void analyticalSolution (const Eigen::VectorXd &ts, Eigen::MatrixXd &xs, Eigen::MatrixXd &xds, Eigen::MatrixXd &forcing_terms, Eigen::MatrixXd &fa_output) const
 Return analytical solution of the system at certain times (and return forcing terms) More...
 
void analyticalSolution (const Eigen::VectorXd &ts, Eigen::MatrixXd &xs, Eigen::MatrixXd &xds, Eigen::MatrixXd &forcing_terms) const
 Return analytical solution of the system at certain times (and return forcing terms) More...
 
void analyticalSolution (const Eigen::VectorXd &ts, Eigen::MatrixXd &xs, Eigen::MatrixXd &xds) const
 Return analytical solution of the system at certain times. More...
 
virtual void analyticalSolution (const Eigen::VectorXd &ts, Trajectory &trajectory) const
 Return analytical solution of the system at certain times. More...
 
void analyticalSolution (const Eigen::VectorXd &ts, Trajectory &trajectory, Eigen::MatrixXd &forcing_terms) const
 Return analytical solution of the system at certain times. More...
 
virtual void statesAsTrajectory (const Eigen::MatrixXd &x_in, const Eigen::MatrixXd &xd_in, Eigen::MatrixXd &y_out, Eigen::MatrixXd &yd_out, Eigen::MatrixXd &ydd_out) const
 Get the output of a DMP dynamical system as a trajectory. More...
 
virtual void statesAsTrajectory (const Eigen::VectorXd &ts, const Eigen::MatrixXd &x_in, const Eigen::MatrixXd &xd_in, Trajectory &trajectory) const
 Get the output of a DMP dynamical system as a trajectory. More...
 
virtual void train (const Trajectory &trajectory)
 Train a DMP with a trajectory. More...
 
virtual void train (const Trajectory &trajectory, std::string save_directory, bool overwrite=false)
 Train a DMP with a trajectory, and write results to file. More...
 
virtual void set_tau (double tau)
 Accessor function for the time constant. More...
 
virtual void set_initial_state (const Eigen::VectorXd &y_init)
 Accessor function for the initial state of the system. More...
 
virtual void set_attractor_state (const Eigen::VectorXd &y_attr)
 Accessor function for the attractor state of the system. More...
 
void set_damping_coefficient (double damping_coefficient)
 Accessor function for damping coefficient of spring-damper system. More...
 
void set_spring_constant (double spring_constant)
 Accessor function for spring constant of spring-damper system. More...
 
std::string toString (void) const
 Returns a string representation of the object. More...
 
void getSelectableParameters (std::set< std::string > &selectable_values_labels) const
 Return all the names of the parameter types that can be selected. More...
 
void setSelectedParameters (const std::set< std::string > &selected_values_labels)
 Determine which subset of parameters is represented in the vector returned by Parameterizable::getParameterVectorSelected. More...
 
int getParameterVectorAllSize (void) const
 Get the size of the parameter values vector when it contains all available parameter values. More...
 
void getParameterVectorAll (Eigen::VectorXd &values) const
 Return a vector that returns all available parameter values. More...
 
void setParameterVectorAll (const Eigen::VectorXd &values)
 Set all available parameter values with one vector. More...
 
void getParameterVectorMask (const std::set< std::string > selected_values_labels, Eigen::VectorXi &selected_mask) const
 Get a mask for selecting parameters. More...
 
void computeFunctionApproximatorInputsAndTargets (const Trajectory &trajectory, Eigen::VectorXd &fa_inputs_phase, Eigen::MatrixXd &fa_targets) const
 Given a trajectory, compute the inputs and targets for the function approximators. More...
 
void set_perturbation_analytical_solution (double perturbation_standard_deviation)
 Add a perturbation to the forcing term when computing the analytical solution. More...
 
double get_perturbation_analytical_solution () const
 Get the perturbation to the forcing term when computing the analytical solution. More...
 
- Public Member Functions inherited from DynamicalSystem
 DynamicalSystem (int order, double tau, Eigen::VectorXd initial_state, Eigen::VectorXd attractor_state, std::string name)
 Initialization constructor. More...
 
virtual ~DynamicalSystem (void)
 Destructor.
 
void integrateStart (const Eigen::VectorXd &x_init, Eigen::Ref< Eigen::VectorXd > x, Eigen::Ref< Eigen::VectorXd > xd)
 Start integrating the system with a new initial state. More...
 
virtual void integrateStep (double dt, const Eigen::Ref< const Eigen::VectorXd > x, Eigen::Ref< Eigen::VectorXd > x_updated, Eigen::Ref< Eigen::VectorXd > xd_updated) const
 Integrate the system one time step. More...
 
void set_integration_method (IntegrationMethod integration_method)
 Choose the integration method. More...
 
int dim (void) const
 Get the dimensionality of the dynamical system, i.e. More...
 
int dim_orig (void) const
 Get the dimensionality of the dynamical system, i.e. More...
 
double tau (void) const
 Accessor function for the time constant. More...
 
Eigen::VectorXd initial_state (void) const
 Accessor function for the initial state of the dynamical system. More...
 
void initial_state (Eigen::VectorXd &initial_state) const
 Accessor function for the initial state of the dynamical system. More...
 
Eigen::VectorXd attractor_state (void) const
 Accessor function for the attractor state of the dynamical system. More...
 
void attractor_state (Eigen::VectorXd &attractor_state) const
 Accessor function for the attractor state of the dynamical system. More...
 
virtual void set_attractor_state (const Eigen::Ref< const Eigen::VectorXd > &attractor_state)
 Mutator function for the attractor state of the dynamical system. More...
 
std::string name (void) const
 Accessor function for the name of the dynamical system. More...
 
virtual void set_name (std::string name)
 Mutator function for the name of the dynamical system. More...
 
- Public Member Functions inherited from Parameterizable
virtual ~Parameterizable (void)
 Destructor.
 
virtual int getParameterVectorSelectedSize (void) const
 Get the size of the vector of selected parameters, as returned by getParameterVectorSelected(. More...
 
virtual void getParameterVectorSelected (Eigen::VectorXd &values, bool normalized=false) const
 Get the values of the selected parameters in one vector. More...
 
virtual void getParameterVectorSelectedNormalized (Eigen::VectorXd &values) const
 Get the normalized values of the selected parameters in one vector. More...
 
void getParameterVectorSelectedMinMax (Eigen::VectorXd &min, Eigen::VectorXd &max) const
 Get the minimum and maximum of the selected parameters in one vector. More...
 
void getParameterVectorAllMinMax (Eigen::VectorXd &min, Eigen::VectorXd &max) const
 Get the minimum and maximum values of the current parameter vector. More...
 
void getParameterVectorSelectedRanges (Eigen::VectorXd &ranges) const
 Get the ranges of the selected parameters, i.e. More...
 
virtual void setParameterVectorSelected (const Eigen::VectorXd &values, bool normalized=false)
 Set all the values of the selected parameters with one vector. More...
 
virtual void setParameterVectorSelectedNormalized (const Eigen::VectorXd &values)
 Set all the values of the selected parameters with one vector of normalized values. More...
 
void setSelectedParametersOne (std::string selected)
 Set the parameters that are currently selected. More...
 
void setParameterVectorModifier (std::string modifier, bool new_value)
 Turn certain modifiers on or off. More...
 
void setVectorLengthsPerDimension (const Eigen::VectorXi &lengths_per_dimension)
 The vector (VectorXd) with parameter values can be split into different parts (as vector<VectorXd>; this function specifices the length of each sub-vector. More...
 
Eigen::VectorXi getVectorLengthsPerDimension (void) const
 Get the specified length of each vector in each dimension. More...
 
void getParameterVectorSelected (std::vector< Eigen::VectorXd > &values, bool normalized=false) const
 Get the values of the selected parameters in one vector. More...
 
void setParameterVectorSelected (const std::vector< Eigen::VectorXd > &values, bool normalized=false)
 Set all the values of the selected parameters with a vector of vectors. More...
 

Protected Member Functions

 DmpContextualTwoStep (void)
 Default constructor. More...
 
- Protected Member Functions inherited from DmpContextual
void trainLocal (const std::vector< Trajectory > &trajectories, const std::vector< Eigen::MatrixXd > &task_parameters, std::string save_directory, bool overwrite)
 Train a contextual DMP. More...
 
void checkTrainTrajectories (const std::vector< Trajectory > &trajectories)
 Check if several trajectories have the same duration and initial/final states. More...
 
- Protected Member Functions inherited from Dmp
FunctionApproximatorfunction_approximator (int i_dim) const
 Get a pointer to the function approximator for a certain dimension. More...
 
- Protected Member Functions inherited from DynamicalSystem
 DynamicalSystem (void)
 Default constructor. More...
 
void set_dim (int dim)
 Set the dimensionality of the dynamical system, i.e. More...
 

Friends

class boost::serialization::access
 Give boost serialization access to private members. More...
 

Additional Inherited Members

- Public Types inherited from Dmp
enum  DmpType { IJSPEERT_2002_MOVEMENT, KULVICIUS_2012_JOINING, COUNTDOWN_2013 }
 Different types of DMPs that can be initialized. More...
 
enum  ForcingTermScaling { NO_SCALING, G_MINUS_Y0_SCALING, AMPLITUDE_SCALING }
 Different ways to scale the forcing term. More...
 
- Public Types inherited from DynamicalSystem
enum  IntegrationMethod { EULER, RUNGE_KUTTA }
 The possible integration methods that can be used. More...
 
- Protected Attributes inherited from DmpContextual
Eigen::MatrixXd task_parameters_
 The current task parameters.
 
std::vector< FunctionApproximator * > policy_parameter_function_goal_
 FunctionApproximators that relate task parameters the goal of the DMP.
 
FunctionApproximatorpolicy_parameter_function_duration_
 FunctionApproximator that relates task parameters the duration of the DMP.
 

Detailed Description

Implementation of Contextual Dynamical Movement Primitives.

Definition at line 40 of file DmpContextualTwoStep.hpp.

Constructor & Destructor Documentation

DmpContextualTwoStep ( int  n_dims_dmp,
std::vector< FunctionApproximator * >  function_approximators,
FunctionApproximator policy_parameter_function,
DmpType  dmp_type = KULVICIUS_2012_JOINING 
)

Initialization constructor for Contextual DMPs of known dimensionality, but with unknown initial and attractor states.

Initializes the DMP with default dynamical systems.

Parameters
n_dims_dmpDimensionality of the DMP
function_approximatorsFunction approximators for the forcing term
policy_parameter_functionFunction approximators for the policy parameter function
dmp_typeThe type of DMP, see Dmp::DmpType

Definition at line 41 of file DmpContextualTwoStep.cpp.

42 : DmpContextual(n_dims_dmp, function_approximators, dmp_type)
43 {
44  policy_parameter_function_ = vector<vector<FunctionApproximator*> >(dim_orig());
45  for (int dd=0; dd<dim_orig(); dd++)
46  {
47  policy_parameter_function_[dd] = vector<FunctionApproximator*>(1);
48  policy_parameter_function_[dd][0] = policy_parameter_function->clone();
49  }
50 }
int dim_orig(void) const
Get the dimensionality of the dynamical system, i.e.
DmpContextual(int n_dims_dmp, std::vector< FunctionApproximator * > function_approximators, DmpType dmp_type)
Initialization constructor for Contextual DMPs of known dimensionality, but with unknown initial and ...

Here is the call graph for this function:

DmpContextualTwoStep ( void  )
inlineprotected

Default constructor.

Remarks
This default constuctor is required for boost::serialization to work. See Boost serialization issues

Definition at line 75 of file DmpContextualTwoStep.hpp.

75 {};

Here is the call graph for this function:

Member Function Documentation

void computeFunctionApproximatorOutput ( const Eigen::Ref< const Eigen::MatrixXd > &  phase_state,
Eigen::MatrixXd &  fa_output 
) const
virtual

Compute the outputs of the function approximators.

Parameters
[in]phase_stateThe phase states for which the outputs are computed.
[out]fa_outputThe outputs of the function approximators.

Implements DmpContextual.

Definition at line 53 of file DmpContextualTwoStep.cpp.

55 {
56  int n_time_steps = phase_state.rows();
57  fa_output.resize(n_time_steps,dim_orig());
58  fa_output.fill(0.0);
59 
60  if (task_parameters_.rows()==0)
61  {
62  // When the task parameters are not set, we cannot compute the output of the function approximator.
63  return;
64  }
65 
66  MatrixXd task_parameters = task_parameters_;
67  if (task_parameters.rows()==1)
68  {
69  task_parameters = task_parameters.row(0).replicate(n_time_steps,1).eval();
70  }
71  else if (task_parameters.cols()==1)
72  {
73  task_parameters = task_parameters.col(0).transpose().replicate(n_time_steps,1).eval();
74  }
75 
76  assert(n_time_steps==task_parameters.rows());
77 
78  //int n_task_parameters = task_parameters.cols();
79 
80  VectorXd model_parameters;
81  MatrixXd output(1,1);
82  for (int dd=0; dd<dim_orig(); dd++)
83  {
84  int n_parameters = function_approximator(dd)->getParameterVectorSelectedSize();
85  model_parameters.resize(n_parameters);
86  for (int pp=0; pp<n_parameters; pp++)
87  {
88  policy_parameter_function_[dd][pp]->predict(task_parameters,output);
89  model_parameters[pp] = output(0,0);
90  }
92  }
93 
94  // The parameters of the function_approximators have been set, get their outputs now.
95  for (int dd=0; dd<dim_orig(); dd++)
96  {
97  function_approximator(dd)->predict(phase_state,output);
98  if (output.size()>0)
99  {
100  fa_output.col(dd) = output;
101  }
102  }
103 
104 }
int dim_orig(void) const
Get the dimensionality of the dynamical system, i.e.
void setParameterVectorSelected(const Eigen::VectorXd &values, bool normalized=false)
Set all the values of the selected parameters with one vector.
virtual void predict(const Eigen::Ref< const Eigen::MatrixXd > &inputs, Eigen::MatrixXd &outputs)=0
Query the function approximator to make a prediction.
FunctionApproximator * function_approximator(int i_dim) const
Get a pointer to the function approximator for a certain dimension.
Definition: Dmp.hpp:345
Eigen::MatrixXd task_parameters_
The current task parameters.
int getParameterVectorSelectedSize(void) const
Get the size of the vector of selected parameters, as returned by getParameterVectorSelected(.

Here is the call graph for this function:

void train ( const std::vector< Trajectory > &  trajectories,
const std::vector< Eigen::MatrixXd > &  task_parameters,
std::string  save_directory = "",
bool  overwrite = true 
)
virtual

Train a contextual Dmp with a set of trajectories (and save results to file) This function is useful for debugging, i.e.

if you want to save intermediate results to a directory

Parameters
[in]trajectoriesThe set of trajectories
[in]task_parametersThe task parameters for each of the trajectories.
[in]save_directoryDirectory to which to save intermediate results.
[in]overwriteOverwrite existing files in the directory above Overloads Dmp::train

Implements DmpContextual.

Definition at line 116 of file DmpContextualTwoStep.cpp.

117 {
118  // Here's the basic structure of this function
119  // 1) Do some checks
120  // 2) Train a separate Dmp for each demonstration, and get the resulting model parameters
121  // 3) Gather all task parameter values for all demonstrations
122  // 4) Train the policy parameter function for each dimension and each model parameter
123 
124 
125  //-----------------------------------------------------
126  // 1) Do some checks
127 
128  // Check if inputs are of the right size.
129  unsigned int n_demonstrations = trajectories.size();
130  assert(n_demonstrations==task_parameters.size());
131 
132 
133  // Then check if the trajectories have the same duration and initial/final state
134  // Later on, if they are not the same, they should be learned also.
135  checkTrainTrajectories(trajectories);
136 
137  // Set tau, initial_state and attractor_state from the trajectories
138  set_tau(trajectories[0].duration());
139  set_initial_state(trajectories[0].initial_y());
140  set_attractor_state(trajectories[0].final_y());
141 
142  //-----------------------------------------------------
143  // 2) Train a separate Dmp for each demonstration, and get the resulting model parameters
144  std::set<std::string> selected;
145  selected.insert("offsets");
146  selected.insert("slopes");
147 
148  MatrixXd cur_task_parameters;
149  VectorXd cur_model_parameters;// todo Remove redundant tmp variable
150  vector<MatrixXd> all_model_parameters(n_demonstrations);
151  for (unsigned int i_demo=0; i_demo<n_demonstrations; i_demo++)
152  {
153 
154  string save_directory_demo;
155  if (!save_directory.empty())
156  save_directory_demo = save_directory + "/demo" + to_string(i_demo);
157 
158  Dmp::train(trajectories[i_demo],save_directory_demo,overwrite);
159 
160  for (int i_dim=0; i_dim<dim_orig(); i_dim++)
161  {
162 
163  // todo Should be argument of constructor
164  function_approximator(i_dim)->setSelectedParameters(selected);
165 
166  function_approximator(i_dim)->getParameterVectorSelected(cur_model_parameters);
167  //cout << cur_model_parameters << endl;
168  if (i_demo==0)
169  all_model_parameters[i_dim].resize(n_demonstrations,cur_model_parameters.size());
170  else
171  assert(cur_model_parameters.size()==all_model_parameters[i_dim].cols());
172 
173  all_model_parameters[i_dim].row(i_demo) = cur_model_parameters;
174 
175  }
176  }
177 
178 
179  //-----------------------------------------------------
180  // 3) Gather all task parameter values for all demonstrations
181 
182  // Gather task parameters in a matrix
183  int n_task_parameters = task_parameters[0].cols();
184  // This is the first time task_parameters_ is set, because this is the first time we know
185  // n_task_parameters.
186  // We set it so that set_task_parameters can check if task_parameters_.cols()==n_task_parameters
187  task_parameters_ = MatrixXd::Zero(1,n_task_parameters);
188  VectorXd cur_task_parameters_t0;
189 
190  MatrixXd inputs(n_demonstrations,n_task_parameters);
191  for (unsigned int i_demo=0; i_demo<n_demonstrations; i_demo++)
192  {
193  // These are the task parameters for the current demonstration at t=0
194  cur_task_parameters_t0 = task_parameters[i_demo].row(0);
195 
196  // Task parameter may not change over time for 2-Step contextual DMP
197  // Start comparison to i_time=0 at i_time=1
198  for (int i_time=1; i_time<task_parameters[i_demo].rows(); i_time++)
199  {
200  if ( (cur_task_parameters_t0.array() != task_parameters[i_demo].row(i_time).array()).any())
201  {
202  cerr << __FILE__ << ":" << __LINE__ << ":";
203  cerr << "WARNING. For DmpContextualTwoStep, task parameters may not vary over time during training. Using task parameters at t=0 only." << endl;
204  }
205  }
206 
207  // Take the first row, i.e. at time_i = 0. We checked above if they are constant over time.
208  inputs.row(i_demo) = cur_task_parameters_t0;
209  }
210 
211  //-----------------------------------------------------
212  // 4) Train the policy parameter function for each dimension and each model parameter
213 
214  // Input to policy parameter functions: task_parameters
215  // Target for each policy parameter function: all_model_parameters.col(param)
216 
217  for (int i_dim=0; i_dim<dim_orig(); i_dim++)
218  {
219  int n_pol_pars = all_model_parameters[i_dim].cols();
220  for (int i_pol_par=1; i_pol_par<n_pol_pars; i_pol_par++)
221  {
222  policy_parameter_function_[i_dim].push_back(policy_parameter_function_[i_dim][0]->clone());
223  //cout << *(policy_parameter_function_[i_dim][i_pol_par]) << endl;
224  }
225 
226  for (int i_pol_par=0; i_pol_par<n_pol_pars; i_pol_par++)
227  {
228  MatrixXd targets = all_model_parameters[i_dim].col(i_pol_par);
229  //cout << "_________________" << endl;
230  //cout << inputs.transpose() << endl << endl;
231  //cout << targets.transpose() << endl;
232 
233  string save_directory_cur;
234  if (!save_directory.empty())
235  save_directory_cur = save_directory + "/dim" + to_string(i_dim) + "_polpar" + to_string(i_pol_par);
236 
237  policy_parameter_function_[i_dim][i_pol_par]->train(inputs,targets,save_directory_cur,overwrite);
238 
239  }
240  }
241 
242 
243 }
virtual void set_attractor_state(const Eigen::VectorXd &y_attr)
Accessor function for the attractor state of the system.
Definition: Dmp.cpp:873
int dim_orig(void) const
Get the dimensionality of the dynamical system, i.e.
virtual void set_tau(double tau)
Accessor function for the time constant.
Definition: Dmp.cpp:853
void getParameterVectorSelected(Eigen::VectorXd &values, bool normalized=false) const
Get the values of the selected parameters in one vector.
virtual void train(const Trajectory &trajectory)
Train a DMP with a trajectory.
Definition: Dmp.cpp:643
Dmp * clone(void) const
Return a deep copy of this object.
Definition: Dmp.cpp:252
FunctionApproximator * function_approximator(int i_dim) const
Get a pointer to the function approximator for a certain dimension.
Definition: Dmp.hpp:345
Eigen::MatrixXd task_parameters_
The current task parameters.
void setSelectedParameters(const std::set< std::string > &selected_values_labels)
Determine which subset of parameters is represented in the vector returned by Parameterizable::getPar...
virtual void set_initial_state(const Eigen::VectorXd &y_init)
Accessor function for the initial state of the system.
Definition: Dmp.cpp:864
void checkTrainTrajectories(const std::vector< Trajectory > &trajectories)
Check if several trajectories have the same duration and initial/final states.

Here is the call graph for this function:

bool isTrained ( void  ) const

Return whether the DMP is trained or not.

Returns
true if the DMP is trained, false otherwise

Definition at line 106 of file DmpContextualTwoStep.cpp.

107 {
108  for (int dd=0; dd<dim_orig(); dd++)
109  for (unsigned int pp=0; pp<policy_parameter_function_[dd].size(); pp++)
110  if (!policy_parameter_function_[dd][pp]->isTrained())
111  return false;
112 
113  return true;
114 }
int dim_orig(void) const
Get the dimensionality of the dynamical system, i.e.
bool isTrained(void) const
Return whether the DMP is trained or not.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Give boost serialization access to private members.

Definition at line 75 of file DmpContextualTwoStep.hpp.


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