assignment_optimization-2Dgrasp
problem.h
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 //
3 // Author: Ugo Pattacini - <ugo.pattacini@iit.it>
4 
5 #ifndef PROBLEM_H
6 #define PROBLEM_H
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 #include <tuple>
12 #include <utility>
13 #include <cmath>
14 #include <algorithm>
15 #include <yarp/sig/Vector.h>
16 
17 namespace problem_ns {
18 
32 struct Force {
33  double t{0.};
34  double fn{0.};
35  double ft{0.};
36 };
37 
41 class Problem
42 {
43  bool configured{false};
44  std::vector<double> ti{M_PI/4.0, 3.0*M_PI/4.0, 5.0*M_PI/4.0, 7.0*M_PI/4.0};
45  std::vector<double> si{.2, .2, .2, .2};
46  std::vector<double> ci{0., 0., 0., 0.};
47  yarp::sig::Vector COM=yarp::sig::Vector(2,0.);
48  double friction{0.};
49  Force F;
50 
51  size_t get_quadrant(const double t) const;
52  std::tuple<double,size_t,double> calc_quantities(const double t) const;
53  yarp::sig::Vector calc_COM();
54  yarp::sig::Vector get_d2P(const double t) const;
55 
56 public:
64  bool configure(const std::vector<double> &shape, const double friction,
65  const Force &F);
66 
71  static std::shared_ptr<Problem> generate();
72 
78  static double wrap_angle(const double t);
79 
84  const std::vector<double>& get_shape() const;
85 
90  double get_friction() const;
91 
96  const Force& get_F() const;
97 
102  const yarp::sig::Vector& get_COM() const;
103 
109  yarp::sig::Vector get_P(const double t) const;
110 
116  yarp::sig::Vector get_dP(const double t) const;
117 
126  yarp::sig::Vector get_T(const double t) const;
127 
133  yarp::sig::Vector get_dT(const double t) const;
134 
143  yarp::sig::Vector get_N(const double t) const;
144 
150  yarp::sig::Vector get_dN(const double t) const;
151 
157  std::pair<yarp::sig::Vector,double> compute_newton_law(const std::vector<Force>& forces) const;
158 
164  bool check_no_slippage(const Force& force) const;
165 
171  bool check_no_slippage(const std::vector<Force>& forces) const;
172 };
173 
174 }
175 
176 #endif
Definition: problem.h:42
bool check_no_slippage(const std::vector< Force > &forces) const
yarp::sig::Vector get_P(const double t) const
Definition: problem.cpp:187
bool check_no_slippage(const Force &force) const
Definition: problem.cpp:293
const Force & get_F() const
Definition: problem.cpp:173
yarp::sig::Vector get_T(const double t) const
Definition: problem.cpp:241
const std::vector< double > & get_shape() const
Definition: problem.cpp:159
yarp::sig::Vector get_dN(const double t) const
Definition: problem.cpp:263
static std::shared_ptr< Problem > generate()
Definition: problem.cpp:69
bool configure(const std::vector< double > &shape, const double friction, const Force &F)
Definition: problem.cpp:50
yarp::sig::Vector get_N(const double t) const
Definition: problem.cpp:253
yarp::sig::Vector get_dP(const double t) const
Definition: problem.cpp:201
const yarp::sig::Vector & get_COM() const
Definition: problem.cpp:180
std::pair< yarp::sig::Vector, double > compute_newton_law(const std::vector< Force > &forces) const
Definition: problem.cpp:273
double get_friction() const
Definition: problem.cpp:166
static double wrap_angle(const double t)
Definition: problem.cpp:101
yarp::sig::Vector get_dT(const double t) const
Definition: problem.cpp:247
Definition: problem.h:32