#include <iostream>
#include <Eigen/Dense>
static const std::vector<double>
START_POS = {1.4, 1.4, 0.5};
static const std::vector<double>
END_POS = {-1.25, 1.0, -0.26};
static const std::vector<double>
BIAS_THRESHOLD = {0.050,0.050,0.050};
static const std::vector<double>
STD_DEV = {1.0, 1.0, 1.0};
{
return c;
}
const std::vector<double>& thresholds)
{
auto num_dimensions = optimized.rows();
Trajectory diff = Trajectory::Zero(num_dimensions,optimized.cols());
for(
auto d = 0u;
d < num_dimensions ;
d++)
{
diff.row(d) = optimized.row(d)- desired.row(d);
diff.row(d).cwiseAbs();
if((diff.row(d).array() > thresholds[
d] ).any() )
{
return false;
}
}
return true;
}
void interpolate(
const std::vector<double>& start,
const std::vector<double>& end,
{
auto dimensions = start.size();
traj = Eigen::MatrixXd::Zero(dimensions,num_timesteps);
for(
auto d = 0u;
d < dimensions;
d++)
{
double delta = (end[
d] - start[
d])/(num_timesteps - 1);
for(auto t = 0u; t < num_timesteps; t++)
{
traj(d,t) = start[
d] + t*delta;
}
}
}
int main(
int argc,
char** argv)
{
interpolate(START_POS,END_POS,NUM_TIMESTEPS,trajectory_bias);
Stomp stomp(config,task);
if(stomp.solve(START_POS,END_POS,optimized))
{
std::cout<<"STOMP succeeded"<<std::endl;
}
else
{
std::cout<<"A valid solution was not found"<<std::endl;
return -1;
}
if(
compareDiff(optimized,trajectory_bias,BIAS_THRESHOLD))
{
std::cout<<"The solution is within the expected thresholds"<<std::endl;
}
else
{
std::cout<<"The solution exceeded the required thresholds"<<std::endl;
return -1;
}
return 0;
}