python_definitions.h 1.95 KB
Newer Older
1
#include "curves/fwd.h"
2
3
#include "curves/bezier_curve.h"
#include "curves/linear_variable.h"
stevet's avatar
stevet committed
4
#include "curves/quadratic_variable.h"
stevet's avatar
stevet committed
5
6
7
8
9
10

#include <vector>

#ifndef _DEFINITION_PYTHON_BINDINGS
#define _DEFINITION_PYTHON_BINDINGS

Guilhem Saurel's avatar
Guilhem Saurel committed
11
namespace curves {
12
/*** TEMPLATE SPECIALIZATION FOR PYTHON ****/
Guilhem Saurel's avatar
Guilhem Saurel committed
13
typedef double real;
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
typedef std::vector<real> t_time_t;
typedef Eigen::VectorXd time_waypoints_t;

typedef Eigen::Matrix<double, Eigen::Dynamic, 1, 0, Eigen::Dynamic, 1> ret_pointX_t;
typedef std::pair<pointX_t, pointX_t> pair_pointX_tangent_t;
typedef Eigen::MatrixXd pointX_list_t;
typedef std::vector<pair_pointX_tangent_t, Eigen::aligned_allocator<pair_pointX_tangent_t> > t_pair_pointX_tangent_t;
typedef curves::curve_constraints<pointX_t> curve_constraints_t;
typedef curves::curve_constraints<point3_t> curve_constraints3_t;
typedef std::pair<real, pointX_t> waypoint_t;
typedef std::vector<waypoint_t> t_waypoint_t;
typedef Eigen::Matrix<real, Eigen::Dynamic, Eigen::Dynamic> point_listX_t;
typedef Eigen::Matrix<real, 3, Eigen::Dynamic> point_list3_t;
typedef Eigen::Matrix<real, 6, Eigen::Dynamic> point_list6_t;

typedef polynomial_t::coeff_t coeff_t;
typedef curves::Bern<double> bernstein_t;
Pierre Fernbach's avatar
Pierre Fernbach committed
31

Guilhem Saurel's avatar
Guilhem Saurel committed
32
33
34
35
36
template <typename PointList, typename T_Point>
T_Point vectorFromEigenArray(const PointList& array) {
  T_Point res;
  for (int i = 0; i < array.cols(); ++i) {
    res.push_back(array.col(i));
37
  }
Guilhem Saurel's avatar
Guilhem Saurel committed
38
39
40
41
42
43
44
  return res;
}
template <typename PointList, typename T_Point>
T_Point vectorFromEigenVector(const PointList& vector) {
  T_Point res;
  for (int i = 0; i < vector.rows(); ++i) {
    res.push_back(vector[i]);
45
  }
Guilhem Saurel's avatar
Guilhem Saurel committed
46
47
  return res;
}
48
49
50
51
52
53
54
55
56
57
58

template <typename T_point, typename PointList>
PointList vectorToEigenArray(const T_point& vect) {
  const size_t nCols = vect.size();
  const size_t nRows = vect[0].rows();
  PointList res(nRows,nCols);
  for (size_t i = 0; i < vect.size(); ++i) {
    res.block(0,i,nRows,1) = vect[i];
  }
  return res;
}
Guilhem Saurel's avatar
Guilhem Saurel committed
59
60
}  // namespace curves
#endif  //_DEFINITION_PYTHON_BINDINGS