57#include <stomp/task.h>
63 std::function<bool(
const Eigen::MatrixXd& values, Eigen::MatrixXd& noisy_values, Eigen::MatrixXd& noise)>;
65using CostFn = std::function<bool(
const Eigen::MatrixXd& values, Eigen::VectorXd& costs,
bool& validity)>;
67using FilterFn = std::function<bool(
const Eigen::MatrixXd& values, Eigen::MatrixXd& filtered_values)>;
69using PostIterationFn = std::function<void(
int iteration_number,
double cost,
const Eigen::MatrixXd& values)>;
72 std::function<void(
bool success,
int total_iterations,
double final_cost,
const Eigen::MatrixXd& values)>;
83 : noise_generator_fn_(std::move(noise_generator_fn))
84 , cost_fn_(std::move(cost_fn))
85 , filter_fn_(std::move(filter_fn))
86 , post_iteration_fn_(std::move(post_iteration_fn))
87 , done_fn_(std::move(done_fn))
105 std::size_t ,
int ,
int ,
106 Eigen::MatrixXd& parameters_noise, Eigen::MatrixXd& noise)
override
108 return noise_generator_fn_(parameters, parameters_noise, noise);
121 bool computeCosts(
const Eigen::MatrixXd& parameters, std::size_t , std::size_t ,
122 int , Eigen::VectorXd& costs,
bool& validity)
override
124 return cost_fn_(parameters, costs, validity);
139 std::size_t ,
int ,
int ,
140 Eigen::VectorXd& costs,
bool& validity)
override
142 return cost_fn_(parameters, costs, validity);
157 const Eigen::MatrixXd& parameters, Eigen::MatrixXd& updates)
override
159 return filter_fn_(parameters, updates);
171 void postIteration(std::size_t , std::size_t ,
int iteration_number,
double cost,
172 const Eigen::MatrixXd& parameters)
override
174 post_iteration_fn_(iteration_number, cost, parameters);
185 void done(
bool success,
int total_iterations,
double final_cost,
const Eigen::MatrixXd& parameters)
override
187 done_fn_(success, total_iterations, final_cost, parameters);
~ComposableTask()=default
bool filterParameterUpdates(std::size_t, std::size_t, int, const Eigen::MatrixXd ¶meters, Eigen::MatrixXd &updates) override
Filters the given parameters which is applied after the update. It could be used for clipping of join...
void postIteration(std::size_t, std::size_t, int iteration_number, double cost, const Eigen::MatrixXd ¶meters) override
Called by STOMP at the end of each iteration.
void done(bool success, int total_iterations, double final_cost, const Eigen::MatrixXd ¶meters) override
Called by Stomp at the end of the optimization process.
bool generateNoisyParameters(const Eigen::MatrixXd ¶meters, std::size_t, std::size_t, int, int, Eigen::MatrixXd ¶meters_noise, Eigen::MatrixXd &noise) override
Generates a noisy trajectory from the parameters.
ComposableTask(NoiseGeneratorFn noise_generator_fn, CostFn cost_fn, FilterFn filter_fn, PostIterationFn post_iteration_fn, DoneFn done_fn)
bool computeNoisyCosts(const Eigen::MatrixXd ¶meters, std::size_t, std::size_t, int, int, Eigen::VectorXd &costs, bool &validity) override
computes the state costs as a function of the distance from the bias parameters
bool computeCosts(const Eigen::MatrixXd ¶meters, std::size_t, std::size_t, int, Eigen::VectorXd &costs, bool &validity) override
computes the state costs as a function of the distance from the bias parameters
std::function< bool(const Eigen::MatrixXd &values, Eigen::MatrixXd &noisy_values, Eigen::MatrixXd &noise)> NoiseGeneratorFn
std::function< void(bool success, int total_iterations, double final_cost, const Eigen::MatrixXd &values)> DoneFn
std::function< bool(const Eigen::MatrixXd &values, Eigen::MatrixXd &filtered_values)> FilterFn
std::function< bool(const Eigen::MatrixXd &values, Eigen::VectorXd &costs, bool &validity)> CostFn
std::function< void(int iteration_number, double cost, const Eigen::MatrixXd &values)> PostIterationFn