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> 37 #include <eigen3/Eigen/Core> 42 using namespace Eigen;
46 TimeSystem::TimeSystem(
double tau,
bool count_down, std::string name)
49 count_down_(count_down)
68 const Eigen::Ref<const Eigen::VectorXd>& x,
69 Eigen::Ref<Eigen::VectorXd> xd)
const 71 ENTERING_REAL_TIME_CRITICAL_CODE
89 EXITING_REAL_TIME_CRITICAL_CODE
100 bool caller_expects_transposed = (xs.rows()==
dim() && xs.cols()==T);
107 int velocity_stop_index = -1;
109 while (velocity_stop_index<0 && i<ts.size())
111 velocity_stop_index = i-1;
113 if (velocity_stop_index<0)
114 velocity_stop_index = ts.size();
118 xs.topRows(velocity_stop_index) = (-ts.segment(0,velocity_stop_index).array()/
tau()).array()+1.0;
119 xs.bottomRows(xs.size()-velocity_stop_index).fill(0.0);
121 xds.topRows(velocity_stop_index).fill(-1.0/
tau());
122 xds.bottomRows(xds.size()-velocity_stop_index).fill(0.0);
126 xs.topRows(velocity_stop_index) = ts.segment(0,velocity_stop_index).array()/
tau();
127 xs.bottomRows(xs.size()-velocity_stop_index).fill(1.0);
129 xds.topRows(velocity_stop_index).fill(1.0/
tau());
130 xds.bottomRows(xds.size()-velocity_stop_index).fill(0.0);
133 if (caller_expects_transposed)
135 xs.transposeInPlace();
136 xds.transposeInPlace();
140 template<
class Archive>
141 void TimeSystem::serialize(Archive & ar,
const unsigned int version)
146 ar & BOOST_SERIALIZATION_NVP(count_down_);
double tau(void) const
Accessor function for the time constant.
virtual void set_attractor_state(const Eigen::Ref< const Eigen::VectorXd > &attractor_state)
Mutator function for the attractor state of the dynamical system.
BOOST_CLASS_EXPORT_IMPLEMENT(DmpBbo::TimeSystem)
For boost::serialization.
Dynamical System modelling the evolution of a time: .
virtual void set_initial_state(const Eigen::VectorXd &initial_state)
Mutator function for the initial state of the dynamical system.
int dim(void) const
Get the dimensionality of the dynamical system, i.e.
TimeSystem class header file.
#define RETURN_STRING_FROM_BOOST_SERIALIZATION_XML(name)
Macro to convert the boost XML serialization of an object into a string.
DynamicalSystem * clone(void) const
Return a pointer to a deep copy of the DynamicalSystem object.
bool count_down(void) const
Accessor function for count_down.
void differentialEquation(const Eigen::Ref< const Eigen::VectorXd > &x, Eigen::Ref< Eigen::VectorXd > xd) const
The differential equation which defines the system.
std::string name(void) const
Accessor function for the name of the dynamical system.
void analyticalSolution(const Eigen::VectorXd &ts, Eigen::MatrixXd &xs, Eigen::MatrixXd &xds) const
Return analytical solution of the system at certain times.
Interface for implementing dynamical systems.
Header file to generate strings from boost serialized files.
~TimeSystem(void)
Destructor.
std::string toString(void) const
Returns a string representation of the object.