DMP_BBO library
DmpContextual.hpp
Go to the documentation of this file.
1 
24 #ifndef _DMP_CONTEXTUAL_H_
25 #define _DMP_CONTEXTUAL_H_
26 
27 #include "dmp/Dmp.hpp"
28 
29 #include <set>
30 
31 namespace DmpBbo {
32 
33 class FunctionApproximator;
34 
79 class DmpContextual : public Dmp
80 {
81 public:
82 
90  DmpContextual(int n_dims_dmp, std::vector<FunctionApproximator*> function_approximators, DmpType dmp_type);
91 
95  void set_task_parameters(const Eigen::MatrixXd& task_parameters);
96 
101 
106 
107  // Overrides Dmp::computeFunctionApproximatorOutput
109  const Eigen::Ref<const Eigen::MatrixXd>& phase_state, Eigen::MatrixXd& fa_output) const = 0;
110 
111 protected:
112 
122  void trainLocal(const std::vector<Trajectory>& trajectories, const std::vector<Eigen::MatrixXd>& task_parameters, std::string save_directory, bool overwrite);
123 
124 public:
134  virtual void train(const std::vector<Trajectory>& trajectories, const std::vector<Eigen::MatrixXd>& task_parameters, std::string save_directory, bool overwrite) = 0;
135 
141  void train(const std::vector<Trajectory>& trajectories, const std::vector<Eigen::MatrixXd>& task_parameters, std::string save_directory);
142 
147  void train(const std::vector<Trajectory>& trajectories, const std::vector<Eigen::MatrixXd>& task_parameters);
148 
154  void train(const std::vector<Trajectory>& trajectories, std::string save_directory, bool overwrite);
155 
160  void train(const std::vector<Trajectory>& trajectories, std::string save_directory);
161 
165  void train(const std::vector<Trajectory>& trajectories);
166 
167 
168 
169 
170 protected:
173  Eigen::MatrixXd task_parameters_;
174 
178  void checkTrainTrajectories(const std::vector<Trajectory>& trajectories);
179 
182  std::vector<FunctionApproximator*> policy_parameter_function_goal_;
183 
187 
188 
189 protected:
190  DmpContextual(void) {};
191 
192 private:
194  friend class boost::serialization::access;
195 
201  template<class Archive>
202  void serialize(Archive & ar, const unsigned int version)
203  {
204  // serialize base class information
205  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Dmp);
206 
207  // Do not archive task_parameters_; these will change constantly,
208  // depending on the task being solved.
209  }
210 
211 };
212 
213 }
214 
215 #include <boost/serialization/export.hpp>
216 
219 
221 BOOST_CLASS_IMPLEMENTATION(DmpBbo::DmpContextual,boost::serialization::object_serializable);
222 
223 #endif
BOOST_SERIALIZATION_ASSUME_ABSTRACT(DmpBbo::DmpContextual)
Don&#39;t add version information to archives.
Implementation of Dynamical Movement Primitives.
Definition: Dmp.hpp:56
std::vector< FunctionApproximator * > policy_parameter_function_goal_
FunctionApproximators that relate task parameters the goal of the DMP.
BOOST_CLASS_IMPLEMENTATION(DmpBbo::DmpContextual, boost::serialization::object_serializable)
Don&#39;t add version information to archives.
Dmp class header file.
FunctionApproximator * policy_parameter_function_duration_
FunctionApproximator that relates task parameters the duration of the DMP.
void set_policy_parameter_function_goal(FunctionApproximator *function_approximator)
Set a function approximator to predict the goal from the task parameters.
virtual void train(const std::vector< Trajectory > &trajectories, const std::vector< Eigen::MatrixXd > &task_parameters, std::string save_directory, bool overwrite)=0
Train a contextual Dmp with a set of trajectories (and save results to file) This function is useful ...
Base class for all function approximators.
void trainLocal(const std::vector< Trajectory > &trajectories, const std::vector< Eigen::MatrixXd > &task_parameters, std::string save_directory, bool overwrite)
Train a contextual DMP.
Implementation of Contextual Dynamical Movement Primitives.
DmpType
Different types of DMPs that can be initialized.
Definition: Dmp.hpp:61
friend class boost::serialization::access
Give boost serialization access to private members.
void set_policy_parameter_function_duration(FunctionApproximator *function_approximator)
Set a function approximator to predict the duration from the task parameters.
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.
virtual void computeFunctionApproximatorOutput(const Eigen::Ref< const Eigen::MatrixXd > &phase_state, Eigen::MatrixXd &fa_output) const =0
Compute the outputs of the function approximators.
void checkTrainTrajectories(const std::vector< Trajectory > &trajectories)
Check if several trajectories have the same duration and initial/final states.
void set_task_parameters(const Eigen::MatrixXd &task_parameters)
Set the current task parameters.