LocalGuidance
A library that generates velocity references to follow a path.
dmp::DiscreteMovementPrimitive Class Reference

#include <DiscreteMovementPrimitive.hpp>

Classes

struct  DMPCanonical
 

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW DiscreteMovementPrimitive ()
 
 ~DiscreteMovementPrimitive ()
 
bool initialize (int num_transformation_systems, const Eigen::VectorXd num_rfs, const double activation, const bool exponentially_spaced, const double can_sys_cutoff, const double sampling_frequency, const double teaching_duration, const double execution_duration, const double alpha_z, const double beta_z)
 
bool isInitialized () const
 
bool reInitializeParams ()
 
bool learnFromThetas (const std::vector< Eigen::VectorXd > &thetas, const Eigen::VectorXd &initial_start, const Eigen::VectorXd &initial_goal, const double sampling_frequency, const double initial_duration)
 
void print ()
 
std::string getInfoString ()
 
bool getInitialDuration (double &initial_duration)
 
bool getInitialStart (Eigen::VectorXd &initial_start)
 
bool getInitialGoal (Eigen::VectorXd &initial_goal)
 
bool getGoal (Eigen::VectorXd &initial_goal)
 
bool getThetas (std::vector< Eigen::VectorXd > &thetas)
 
bool setThetas (const std::vector< Eigen::VectorXd > &thetas)
 
bool getInterpolatedTheta (const double x_input, std::vector< double > &interpolatedThetas)
 
bool getWidthsAndCenters (std::vector< Eigen::VectorXd > &widths, std::vector< Eigen::VectorXd > &centers)
 
bool getWidthsAndCenters (const int trans_system_index, Eigen::VectorXd &widths, Eigen::VectorXd &centers)
 
bool getNumRFS (const int trans_id, int &num_rfs)
 
bool getNumRFS (std::vector< int > &num_rfs)
 
bool getBasisFunctions (const int num_time_steps, std::vector< Eigen::MatrixXd > &basis_functions)
 
bool getBasisFunctionsValues (const double x_input, std::vector< Eigen::VectorXd > &currentBasisFunctionsValues)
 
bool setup (const double sampling_frequency)
 
bool setup (const Eigen::VectorXd &goal, const double movement_duration=-1.0, const double sampling_frequency=-1.0)
 
bool setup (const Eigen::VectorXd &start, const Eigen::VectorXd &goal, const double movement_duration=-1.0, const double sampling_frequency=-1.0)
 
bool changeGoal (const Eigen::VectorXd &goal, const int start_index, const int end_index)
 
bool changeGoal (const double new_goal, const int index)
 
bool changeStart (const Eigen::VectorXd &start)
 
bool isSetup () const
 
bool isStartSet () const
 
void unsetStart ()
 
bool setDuration (const double movement_duration, const int sampling_frequency)
 
bool propagateStep (std::vector< Eigen::VectorXd > &desired_coordinates, bool &movement_finished)
 
bool propagateStep (std::vector< Eigen::VectorXd > &desired_coordinates, bool &movement_finished, const double sampling_duration, const int num_samples)
 
bool getCurrentPosition (Eigen::VectorXd &current_position)
 
bool getCurrentVelocity (Eigen::VectorXd &current_velocity)
 
bool getCurrentAcceleration (Eigen::VectorXd &current_acceleration)
 
double getProgress (const double &x_input) const
 
double getProgress () const
 
int getNumTransformationSystems () const
 
bool isIncreasing (int transformation_system_index, bool &is_increasing)
 
bool getCanonicalSystemState (double &canonical_system_value, double &canonical_system_time)
 
bool getCanonicalSystem (const int num_time_steps, Eigen::VectorXd &can_system_vector)
 
bool initializeBase (const int item_id, const std::string item_name, const bool is_new_dmp=true)
 
int getID () const
 
bool setID (const int id)
 
std::string getName () const
 
std::string getFileName (const int trial_id)
 
void setDescription (const std::string &description)
 
std::string getDescription () const
 
std::string getClassName ()
 

Private Member Functions

bool integrateAndFit ()
 
bool learnTransformationTarget ()
 
bool integrate (const double dt_total, const int num_iteration)
 
void integrateCanonicalSystem (double &canonical_system_x, const double canonical_system_time) const
 
void resetCanonicalState ()
 
void initialize ()
 

Private Attributes

bool initialized_
 
DmpParameters params_
 
DMPCanonical canonical_system_
 
boost::ptr_vector< TransformationSystemtransformation_systems_
 
std::vector< double > trajectory_target_function_input_
 

Constructor & Destructor Documentation

EIGEN_MAKE_ALIGNED_OPERATOR_NEW dmp::DiscreteMovementPrimitive::DiscreteMovementPrimitive ( )

constructor

dmp::DiscreteMovementPrimitive::~DiscreteMovementPrimitive ( )

destructor

Member Function Documentation

bool dmp::DiscreteMovementPrimitive::changeGoal ( const Eigen::VectorXd &  goal,
const int  start_index,
const int  end_index 
)

REAL-TIME REQUIREMENTS

Parameters
goal
start_index
end_index
Returns
bool dmp::DiscreteMovementPrimitive::changeGoal ( const double  new_goal,
const int  index 
)
bool dmp::DiscreteMovementPrimitive::changeStart ( const Eigen::VectorXd &  start)

REAL-TIME REQUIREMENTS

Parameters
start
Returns
bool dmp::DiscreteMovementPrimitive::getBasisFunctions ( const int  num_time_steps,
std::vector< Eigen::MatrixXd > &  basis_functions 
)
Parameters
num_time_steps
basis_functions
Returns
bool dmp::DiscreteMovementPrimitive::getBasisFunctionsValues ( const double  x_input,
std::vector< Eigen::VectorXd > &  currentBasisFunctionsValues 
)
Parameters
x_input
currentBasisFunctionsValues
Returns
bool dmp::DiscreteMovementPrimitive::getCanonicalSystem ( const int  num_time_steps,
Eigen::VectorXd &  can_system_vector 
)

Gets the linear progress of the canonical system from 0 to 1

Parameters
canonical_system_value
canonical_system_progress
Returns

Evaluates the canonical system using its duration (tau) and alpha_x at num_time_steps time steps going from 0 to 1.

Parameters
num_time_steps
can_system_vector
Returns
bool dmp::DiscreteMovementPrimitive::getCanonicalSystemState ( double &  canonical_system_value,
double &  canonical_system_time 
)
Parameters
canonical_system_value
canonical_system_time
Returns
std::string dmp::DiscreteMovementPrimitive::getClassName ( )
inline
Returns
bool dmp::DiscreteMovementPrimitive::getCurrentAcceleration ( Eigen::VectorXd &  current_acceleration)
bool dmp::DiscreteMovementPrimitive::getCurrentPosition ( Eigen::VectorXd &  current_position)

writes the data trace within dmp_debug to file. This has to happen outside the run() function since otherwise would violate the real-time constraints.

Parameters
current_desired_position
start_index
end_index
Returns
bool dmp::DiscreteMovementPrimitive::getCurrentVelocity ( Eigen::VectorXd &  current_velocity)
std::string dmp::DiscreteMovementPrimitive::getDescription ( ) const
std::string dmp::DiscreteMovementPrimitive::getFileName ( const int  trial_id)
bool dmp::DiscreteMovementPrimitive::getGoal ( Eigen::VectorXd &  initial_goal)
Parameters
goal
Returns
int dmp::DiscreteMovementPrimitive::getID ( ) const
std::string dmp::DiscreteMovementPrimitive::getInfoString ( )
bool dmp::DiscreteMovementPrimitive::getInitialDuration ( double &  initial_duration)
inline
Returns
bool dmp::DiscreteMovementPrimitive::getInitialGoal ( Eigen::VectorXd &  initial_goal)
Parameters
initial_goal
Returns
bool dmp::DiscreteMovementPrimitive::getInitialStart ( Eigen::VectorXd &  initial_start)
Parameters
initial_start
Returns
bool dmp::DiscreteMovementPrimitive::getInterpolatedTheta ( const double  x_input,
std::vector< double > &  interpolatedThetas 
)

Gets the linearly interpolated theta value for x_input This function is used for logging and visualization

Parameters
x_input
interpolatedThetas
Returns
True on success, false on failure
std::string dmp::DiscreteMovementPrimitive::getName ( ) const
bool dmp::DiscreteMovementPrimitive::getNumRFS ( const int  trans_id,
int &  num_rfs 
)

Gets the number of receptive field used by transformation system with id trans_id

Parameters
trans_id
num_rfs
Returns
bool dmp::DiscreteMovementPrimitive::getNumRFS ( std::vector< int > &  num_rfs)

Gets the number of receptive fields for each transformation system

Parameters
num_rfs
Returns
int dmp::DiscreteMovementPrimitive::getNumTransformationSystems ( ) const
inline
Returns
double dmp::DiscreteMovementPrimitive::getProgress ( const double &  x_input) const
Returns
double dmp::DiscreteMovementPrimitive::getProgress ( ) const
Returns
bool dmp::DiscreteMovementPrimitive::getThetas ( std::vector< Eigen::VectorXd > &  thetas)

Gets the parameters of each transformation system

Parameters
thetas
Returns
bool dmp::DiscreteMovementPrimitive::getWidthsAndCenters ( std::vector< Eigen::VectorXd > &  widths,
std::vector< Eigen::VectorXd > &  centers 
)

Gets the widths and centers of each transformation system

Parameters
thetas
Returns
bool dmp::DiscreteMovementPrimitive::getWidthsAndCenters ( const int  trans_system_index,
Eigen::VectorXd &  widths,
Eigen::VectorXd &  centers 
)
Parameters
widths
centers
Returns
bool dmp::DiscreteMovementPrimitive::initialize ( int  num_transformation_systems,
const Eigen::VectorXd  num_rfs,
const double  activation,
const bool  exponentially_spaced,
const double  can_sys_cutoff,
const double  sampling_frequency,
const double  teaching_duration,
const double  execution_duration,
const double  alpha_z,
const double  beta_z 
)

Initializes the DMP. This is necessary for all future use of the DMP.

Parameters
num_transformation_systems(input) Number of transformation systems (dimensions) of the DMP.
dmp_id(input) ID of the DMP
dmp_parameter_namespace(input) namespace in which the DMP parameters live on the param server
lwr_parameter_namespace(input) namespace in which the LWR parameters live on the param server
Returns
true if initialization was successful, false if it failed
void dmp::DiscreteMovementPrimitive::initialize ( )
private
bool dmp::DiscreteMovementPrimitive::initializeBase ( const int  item_id,
const std::string  item_name,
const bool  is_new_dmp = true 
)
inline

Reads a DMP from the directory provided by directory_name and the dmp_id

Parameters
directory_name
item_id
Returns

Writes the DMP to the directory

Returns
Parameters
version
Returns
Parameters
directory_name
item_id
item_name
is_new_dmp
Returns
bool dmp::DiscreteMovementPrimitive::integrate ( const double  dt_total,
const int  num_iteration 
)
private
Returns
returns false if the Gaussian kernel model could not come up with a prediction for various reasons, otherwise true.
bool dmp::DiscreteMovementPrimitive::integrateAndFit ( )
private
void dmp::DiscreteMovementPrimitive::integrateCanonicalSystem ( double &  canonical_system_x,
const double  canonical_system_time 
) const
private

Evaluates the canonical system at the given time step (canonical_system_time) and writes it to canonical_system_x

Parameters
canonical_system_x(output)
canonical_system_time(input)
Returns
bool dmp::DiscreteMovementPrimitive::isIncreasing ( int  transformation_system_index,
bool &  is_increasing 
)
Parameters
transformation_system_index
is_increasing
Returns
bool dmp::DiscreteMovementPrimitive::isInitialized ( ) const
inline

Indicates whether the DMP is initialized

Returns
true if DMP is initialized, false if not
bool dmp::DiscreteMovementPrimitive::isSetup ( ) const
inline
Returns
bool dmp::DiscreteMovementPrimitive::isStartSet ( ) const
inline
bool dmp::DiscreteMovementPrimitive::learnFromThetas ( const std::vector< Eigen::VectorXd > &  thetas,
const Eigen::VectorXd &  initial_start,
const Eigen::VectorXd &  initial_goal,
const double  sampling_frequency,
const double  initial_duration 
)
Parameters
theta_matrix
Returns
bool dmp::DiscreteMovementPrimitive::learnTransformationTarget ( )
private
Returns
void dmp::DiscreteMovementPrimitive::print ( )
bool dmp::DiscreteMovementPrimitive::propagateStep ( std::vector< Eigen::VectorXd > &  desired_coordinates,
bool &  movement_finished 
)

REAL-TIME REQUIREMENTS Propagates the DMP and generates an entire rollout of size num_samples. The duration of the DMP need to be set previously using one of the setup functions. The sampling duration and the number of samples specified determine the length of the trajectory and its sampling frequecy. Note, the sampling frequency of the trajectory may change.

Parameters
trajectory
sampling_duration
num_samples
Returns

REAL-TIME REQUIREMENTS

Parameters
desired_coordinates
finished
current_position
movement_duration
Returns
bool dmp::DiscreteMovementPrimitive::propagateStep ( std::vector< Eigen::VectorXd > &  desired_coordinates,
bool &  movement_finished,
const double  sampling_duration,
const int  num_samples 
)

REAL-TIME REQUIREMENTS

Parameters
desired_coordinates
movement_finished
sampling_duration
num_samples
Returns
bool dmp::DiscreteMovementPrimitive::reInitializeParams ( )
Parameters
parameter_namespace
Returns
void dmp::DiscreteMovementPrimitive::resetCanonicalState ( )
inlineprivate
void dmp::DiscreteMovementPrimitive::setDescription ( const std::string &  description)
Parameters
description
bool dmp::DiscreteMovementPrimitive::setDuration ( const double  movement_duration,
const int  sampling_frequency 
)
Parameters
movement_duration
sampling_frequency
Returns
bool dmp::DiscreteMovementPrimitive::setID ( const int  id)
bool dmp::DiscreteMovementPrimitive::setThetas ( const std::vector< Eigen::VectorXd > &  thetas)

Sets the parameters of each transformation system

Parameters
thetas
Returns
bool dmp::DiscreteMovementPrimitive::setup ( const double  sampling_frequency)

set start and goal to initial start and initial goal

Parameters
sampling_frequency
Returns
bool dmp::DiscreteMovementPrimitive::setup ( const Eigen::VectorXd &  goal,
const double  movement_duration = -1.0,
const double  sampling_frequency = -1.0 
)
Parameters
goal
sampling_frequency
Returns
bool dmp::DiscreteMovementPrimitive::setup ( const Eigen::VectorXd &  start,
const Eigen::VectorXd &  goal,
const double  movement_duration = -1.0,
const double  sampling_frequency = -1.0 
)
Parameters
start
goal
movement_duration
sampling_frequency
Returns
void dmp::DiscreteMovementPrimitive::unsetStart ( )
inline

Member Data Documentation

DMPCanonical dmp::DiscreteMovementPrimitive::canonical_system_
private

struct that contains the variables of the canonical system (the phase variable x and time)

bool dmp::DiscreteMovementPrimitive::initialized_
private
DmpParameters dmp::DiscreteMovementPrimitive::params_
private

parameters that are read from file and (usually) kept the same for all DMPs

std::vector<double> dmp::DiscreteMovementPrimitive::trajectory_target_function_input_
private
boost::ptr_vector<TransformationSystem> dmp::DiscreteMovementPrimitive::transformation_systems_
private

vector of num_transformation_systems_ instances of the class DMPTransformationSystem that contain relevant information for each dimension of the movement system.


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