utils.h
00001 
00026 #ifndef INDUSTRIAL_MOVEIT_STOMP_CORE_INCLUDE_STOMP_CORE_STOMP_UTILS_H_
00027 #define INDUSTRIAL_MOVEIT_STOMP_CORE_INCLUDE_STOMP_CORE_STOMP_UTILS_H_
00028 
00029 #include <string>
00030 #include <vector>
00031 #include <Eigen/Core>
00032 
00033 namespace stomp_core
00034 {
00035 
00037 struct Rollout
00038 {
00039   Eigen::MatrixXd noise;                   
00040   Eigen::MatrixXd parameters_noise;        
00042   Eigen::VectorXd state_costs;             
00043   Eigen::MatrixXd control_costs;           
00044   Eigen::MatrixXd total_costs;             
00045   Eigen::MatrixXd probabilities;           
00047   std::vector<double> full_probabilities; 
00048   std::vector<double> full_costs;         
00051   double importance_weight;               
00052   double total_cost;                      
00054 };
00055 
00056 
00057 namespace DerivativeOrders
00058 {
00060 enum DerivativeOrder
00061 {
00062   STOMP_POSITION = 0,     
00063   STOMP_VELOCITY = 1,     
00064   STOMP_ACCELERATION = 2, 
00065   STOMP_JERK = 3          
00066 };
00067 }
00068 
00069 namespace TrajectoryInitializations
00070 {
00072 enum TrajectoryInitialization
00073 {
00074   LINEAR_INTERPOLATION = 1,       
00075   CUBIC_POLYNOMIAL_INTERPOLATION, 
00076   MININUM_CONTROL_COST            
00077 };
00078 }
00079 
00081 struct StompConfiguration
00082 {
00083   // General settings
00084   int num_iterations;                    
00085   int num_iterations_after_valid;        
00086   int num_timesteps;                     
00087   int num_dimensions;                    
00088   double delta_t;                        
00089   int initialization_method;             
00091   // Probability Calculation
00092   double exponentiated_cost_sensitivity; 
00094   // Noisy trajectory generation
00095   int num_rollouts;                      
00096   int max_rollouts;                      
00098   // Cost calculation
00099   double control_cost_weight;            
00100 };
00101 
00103 static const int FINITE_DIFF_RULE_LENGTH = 7;
00104 
00106 static const double FINITE_CENTRAL_DIFF_COEFFS[FINITE_DIFF_RULE_LENGTH][FINITE_DIFF_RULE_LENGTH] = {
00107     {0, 0        , 0        , 1        , 0        , 0         , 0      }, // position
00108     {0, 1.0/12.0 , -2.0/3.0 , 0        , 2.0/3.0  , -1.0/12.0 , 0      }, // velocity
00109     {0, -1/12.0  , 16/12.0  , -30/12.0 , 16/12.0  , -1/12.0   , 0      }, // acceleration (five point stencil)
00110     {0, 1/12.0   , -17/12.0 , 46/12.0  , -46/12.0 , 17/12.0   , -1/12.0}  // jerk
00111 };
00112 
00114 static const double FINITE_FORWARD_DIFF_COEFFS[FINITE_DIFF_RULE_LENGTH][FINITE_DIFF_RULE_LENGTH] = {
00115     {1          , 0         , 0         , 0      , 0        , 0         , 0    }, // position
00116     {-25.0/12.0 , 4.0       , -3.0      , 4.0/3.0, -1.0/4.0 , 0         , 0    }, // velocity
00117     {15.0/4.0   , -77.0/6.0 , 107.0/6.0 , -13.0  , 61.0/12.0, -5.0/6.0  , 0    }, // acceleration (five point stencil)
00118     {-49/8      , 29        , -461/8    , 62     , -307/8   , 13        , -15/8}  // jerk
00119 };
00120 
00128 void generateFiniteDifferenceMatrix(int num_time_steps, DerivativeOrders::DerivativeOrder order, double dt,
00129                                     Eigen::MatrixXd& diff_matrix);
00130 
00138 void differentiate(const Eigen::VectorXd& parameters, DerivativeOrders::DerivativeOrder order,
00139                           double dt, Eigen::VectorXd& derivatives );
00140 
00147 void generateSmoothingMatrix(int num_time_steps, double dt, Eigen::MatrixXd& projection_matrix_M);
00148 
00156 void toVector(const Eigen::MatrixXd& m,std::vector<Eigen::VectorXd>& v);
00157 
00163 std::string toString(const std::vector<Eigen::VectorXd>& data);
00164 
00170 std::string toString(const Eigen::VectorXd& data);
00171 
00177 std::string toString(const Eigen::MatrixXd& data);
00178 
00179 } /* namespace stomp */
00180 
00181 #endif /* INDUSTRIAL_MOVEIT_STOMP_CORE_INCLUDE_STOMP_CORE_STOMP_UTILS_H_ */


stomp_core
Author(s): Jorge Nicho
autogenerated on Sat Jun 8 2019 19:23:57