24 #include <boost/serialization/export.hpp> 25 #include <boost/archive/text_iarchive.hpp> 26 #include <boost/archive/text_oarchive.hpp> 27 #include <boost/archive/xml_iarchive.hpp> 28 #include <boost/archive/xml_oarchive.hpp> 34 #include <boost/serialization/base_object.hpp> 39 #include <eigen3/Eigen/Core> 46 using namespace Eigen;
50 ExponentialSystem::ExponentialSystem(
double tau, Eigen::VectorXd y_init, Eigen::VectorXd y_attr,
double alpha, std::string name)
54 attractor_state_prealloc_ = VectorXd::Zero(
dim_orig());
68 const Eigen::Ref<const Eigen::VectorXd>& x,
69 Eigen::Ref<Eigen::VectorXd> xd)
const 71 ENTERING_REAL_TIME_CRITICAL_CODE
75 xd.noalias() = alpha_*(attractor_state_prealloc_-x)/
tau();
77 EXITING_REAL_TIME_CRITICAL_CODE
88 bool caller_expects_transposed = (xs.rows()==
dim() && xs.cols()==T);
96 VectorXd exp_term = -alpha_*ts/
tau();
97 exp_term = exp_term.array().exp().transpose();
98 VectorXd pos_scale = exp_term;
99 VectorXd vel_scale = -(alpha_/
tau()) * exp_term;
101 xs = val_range.transpose().replicate(T,1).array() * pos_scale.replicate(1,
dim()).array();
103 xds = val_range.transpose().replicate(T,1).array() * vel_scale.replicate(1,
dim()).array();
105 if (caller_expects_transposed)
107 xs.transposeInPlace();
108 xds.transposeInPlace();
112 template<
class Archive>
113 void ExponentialSystem::serialize(Archive & ar,
const unsigned int version)
118 ar & BOOST_SERIALIZATION_NVP(alpha_);
double tau(void) const
Accessor function for the time constant.
int dim_orig(void) const
Get the dimensionality of the dynamical system, i.e.
ExponentialSystem class header file.
Eigen::VectorXd initial_state(void) const
Accessor function for the initial state of the dynamical system.
int dim(void) const
Get the dimensionality of the dynamical system, i.e.
#define RETURN_STRING_FROM_BOOST_SERIALIZATION_XML(name)
Macro to convert the boost XML serialization of an object into a string.
~ExponentialSystem(void)
Destructor.
Dynamical System modelling the evolution of an exponential system: .
std::string name(void) const
Accessor function for the name of the dynamical system.
BOOST_CLASS_EXPORT_IMPLEMENT(DmpBbo::ExponentialSystem)
For boost::serialization.
DynamicalSystem * clone(void) const
Return a pointer to a deep copy of the DynamicalSystem object.
Interface for implementing dynamical systems.
std::string toString(void) const
Returns a string representation of the object.
Eigen::VectorXd attractor_state(void) const
Accessor function for the attractor state of the dynamical system.
Header file to generate strings from boost serialized files.
void differentialEquation(const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::VectorXd > xd) const
The differential equation which defines the system.
void analyticalSolution(const Eigen::VectorXd &ts, Eigen::MatrixXd &xs, Eigen::MatrixXd &xds) const
Return analytical solution of the system at certain times.
Header file for serialization of Eigen matrices.