stomp.h
Go to the documentation of this file.
1 
26 #ifndef INDUSTRIAL_MOVEIT_STOMP_CORE_INCLUDE_STOMP_CORE_STOMP_H_
27 #define INDUSTRIAL_MOVEIT_STOMP_CORE_INCLUDE_STOMP_CORE_STOMP_H_
28 
29 #include <atomic>
30 #include <stomp_core/utils.h>
31 #include <XmlRpc.h>
32 #include "stomp_core/task.h"
33 
34 namespace stomp_core
35 {
36 
38 class Stomp
39 {
40 public:
46  Stomp(const StompConfiguration& config,TaskPtr task);
47 
55  bool solve(const std::vector<double>& first,const std::vector<double>& last,
56  Eigen::MatrixXd& parameters_optimized);
57 
65  bool solve(const Eigen::VectorXd& first,const Eigen::VectorXd& last,
66  Eigen::MatrixXd& parameters_optimized);
67 
74  bool solve(const Eigen::MatrixXd& initial_parameters,
75  Eigen::MatrixXd& parameters_optimized);
76 
81  void setConfig(const StompConfiguration& config);
82 
88  bool cancel();
89 
94  bool clear();
95 
96 
97 protected:
98 
99  // initialization methods
104  bool resetVariables();
105 
112  bool computeInitialTrajectory(const std::vector<double>& first,const std::vector<double>& last);
113 
114  // optimization steps
120  bool runSingleIteration();
121 
126  bool generateNoisyRollouts();
127 
132  bool filterNoisyRollouts();
133 
139 
145 
154 
159  bool computeProbabilities();
160 
165  bool updateParameters();
166 
173  bool computeOptimizedCost();
174 
175 protected:
176 
177  // process control
178  std::atomic<bool> proceed_;
181  unsigned int current_iteration_;
183  // optimized parameters
188  Eigen::MatrixXd parameters_optimized_;
190  Eigen::MatrixXd parameters_updates_;
191  Eigen::VectorXd parameters_state_costs_;
192  Eigen::MatrixXd parameters_control_costs_;
194  // rollouts
195  std::vector<Rollout> noisy_rollouts_;
196  std::vector<Rollout> reused_rollouts_;
199  // finite difference and optimization matrices
204  Eigen::MatrixXd control_cost_matrix_R_;
205  Eigen::MatrixXd inv_control_cost_matrix_R_;
208 };
209 
210 } /* namespace stomp */
211 
212 #endif /* INDUSTRIAL_MOVEIT_STOMP_CORE_INCLUDE_STOMP_CORE_STOMP_H_ */
std::shared_ptr< Task > TaskPtr
Definition: task.h:37
Eigen::MatrixXd finite_diff_matrix_A_padded_
The finite difference matrix including padding.
Definition: stomp.h:202
Eigen::MatrixXd control_cost_matrix_R_padded_
The control cost matrix including padding.
Definition: stomp.h:203
bool resetVariables()
Reset all internal variables.
Definition: stomp.cpp:299
int num_active_rollouts_
Number of active rollouts.
Definition: stomp.h:197
Stomp(const StompConfiguration &config, TaskPtr task)
Stomp Constructor.
Definition: stomp.cpp:172
std::atomic< bool > proceed_
Used to determine if the optimization has been cancelled.
Definition: stomp.h:178
bool runSingleIteration()
Run a single iteration of the stomp algorithm.
Definition: stomp.cpp:423
int num_timesteps_padded_
The number of timesteps to pad the optimization with: timesteps + 2*(FINITE_DIFF_RULE_LENGTH - 1) ...
Definition: stomp.h:200
bool cancel()
Cancel optimization in progress. (Thread-Safe) This method is thead-safe.
Definition: stomp.cpp:416
int start_index_padded_
The index corresponding to the start of the non-paded section in the padded arrays.
Definition: stomp.h:201
bool generateNoisyRollouts()
Generate a set of noisy rollouts.
Definition: stomp.cpp:443
StompConfiguration config_
Configuration parameters.
Definition: stomp.h:180
unsigned int current_iteration_
Current iteration for the optimization.
Definition: stomp.h:181
std::vector< Rollout > noisy_rollouts_
Holds the noisy rollouts.
Definition: stomp.h:195
void setConfig(const StompConfiguration &config)
Sets the configuration and resets all internal variables.
Definition: stomp.cpp:186
The Stomp class.
Definition: stomp.h:38
bool computeOptimizedCost()
Computes the optimized trajectory cost [Control Cost + State Cost] If the current cost is not less th...
Definition: stomp.cpp:771
TaskPtr task_
The task to be optimized.
Definition: stomp.h:179
bool computeRolloutsStateCosts()
Computes the cost at every timestep for each noisy rollout.
Definition: stomp.cpp:602
Eigen::VectorXd parameters_state_costs_
A vector [timesteps] of the parameters state costs.
Definition: stomp.h:191
bool computeRolloutsControlCosts()
Compute the control cost for each noisy rollout. This is the sum of the acceleration squared...
Definition: stomp.cpp:629
double parameters_total_cost_
Total cost of the optimized parameters.
Definition: stomp.h:186
Eigen::MatrixXd control_cost_matrix_R_
A matrix [timesteps][timesteps], Referred to as &#39;R = A x A_transpose&#39; in the literature.
Definition: stomp.h:204
double current_lowest_cost_
Hold the lowest cost of the optimized parameters.
Definition: stomp.h:187
bool filterNoisyRollouts()
Applies the optimization task&#39;s filter methods to the noisy trajectories.
Definition: stomp.cpp:538
Eigen::MatrixXd inv_control_cost_matrix_R_
A matrix [timesteps][timesteps], R^-1 &#39; matrix.
Definition: stomp.h:205
bool computeProbabilities()
Computes the probability from the state cost at every timestep for each noisy rollout.
Definition: stomp.cpp:654
bool computeInitialTrajectory(const std::vector< double > &first, const std::vector< double > &last)
Computes an inital guess at a solution given a start and end state.
Definition: stomp.cpp:393
The data structure used to store STOMP configuration parameters.
Definition: utils.h:81
bool solve(const std::vector< double > &first, const std::vector< double > &last, Eigen::MatrixXd &parameters_optimized)
Find the optimal solution provided a start and end goal.
Definition: stomp.cpp:192
Eigen::MatrixXd parameters_optimized_
A matrix [dimensions][timesteps] of the optimized parameters.
Definition: stomp.h:188
bool parameters_valid_prev_
whether or not the optimized parameters from the previous iteration are valid
Definition: stomp.h:185
This defines the stomp task.
bool clear()
Resets all internal variables.
Definition: stomp.cpp:181
bool updateParameters()
Computes update from probabilities using convex combination.
Definition: stomp.cpp:743
bool computeNoisyRolloutsCosts()
Computes the total cost for each of the noisy rollouts.
Definition: stomp.cpp:564
bool parameters_valid_
whether or not the optimized parameters are valid
Definition: stomp.h:184
Eigen::MatrixXd parameters_control_costs_
A matrix [dimensions][timesteps] of the parameters control costs.
Definition: stomp.h:192
Eigen::MatrixXd parameters_updates_
A matrix [dimensions][timesteps] of the parameter updates.
Definition: stomp.h:190
std::vector< Rollout > reused_rollouts_
Used for reordering arrays based on cost.
Definition: stomp.h:196


stomp_core
Author(s): Jorge Nicho
autogenerated on Fri May 8 2020 03:35:43