hpp-bezier-com-traj  4.15.1
Multi contact trajectory generation for the COM using Bezier curves
waypoints_c0_dc0_c1.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018, LAAS-CNRS
3  * Author: Pierre Fernbach
4  */
5 
6 #ifndef BEZIER_COM_TRAJ_C0DC0C1_H
7 #define BEZIER_COM_TRAJ_C0DC0C1_H
8 
10 
11 namespace bezier_com_traj {
12 namespace c0_dc0_c1 {
13 
14 static const ConstraintFlag flag = INIT_POS | INIT_VEL | END_POS;
15 
18 
25 inline coefs_t evaluateCurveAtTime(const std::vector<point_t>& pi, double t) {
26  coefs_t wp;
27  double t2 = t * t;
28  double t3 = t2 * t;
29  // equation found with sympy
30  wp.first = -3.0 * t3 + 3.0 * t2;
31  wp.second = -1.0 * pi[0] * t3 + 3.0 * pi[0] * t2 - 3.0 * pi[0] * t +
32  1.0 * pi[0] + 3.0 * pi[1] * t3 - 6.0 * pi[1] * t2 +
33  3.0 * pi[1] * t + 1.0 * pi[3] * t3;
34  return wp;
35 }
36 
37 inline coefs_t evaluateAccelerationCurveAtTime(const std::vector<point_t>& pi,
38  double T, double t) {
39  coefs_t wp;
40  double alpha = 1. / (T * T);
41  // equation found with sympy
42  wp.first = (-18.0 * t + 6.0) * alpha;
43  wp.second = (-6.0 * pi[0] * t + 6.0 * pi[0] + 18.0 * pi[1] * t -
44  12.0 * pi[1] + 6.0 * pi[3] * t) *
45  alpha;
46  return wp;
47 }
48 
49 inline std::vector<point_t> computeConstantWaypoints(const ProblemData& pData,
50  double T) {
51  // equation for constraint on initial and final position and velocity (degree
52  // 4, 4 constant waypoint and one free (p2)) first, compute the constant
53  // waypoints that only depend on pData :
54  int n = 3;
55  std::vector<point_t> pi;
56  pi.push_back(pData.c0_); // p0
57  pi.push_back((pData.dc0_ * T / n) + pData.c0_); // p1
58  pi.push_back(point_t::Zero()); // p2 = x
59  pi.push_back(pData.c1_); // p3
60 
61  return pi;
62 }
63 
64 inline bezier_wp_t::t_point_t computeWwaypoints(const ProblemData& pData,
65  double T) {
66  bezier_wp_t::t_point_t wps;
67  const int DIM_POINT = 6;
68  const int DIM_VAR = 3;
69  std::vector<point_t> pi = computeConstantWaypoints(pData, T);
70  std::vector<Matrix3> Cpi;
71  for (std::size_t i = 0; i < pi.size(); ++i) {
72  Cpi.push_back(skew(pi[i]));
73  }
74  const Vector3 g = pData.contacts_.front().contactPhase_->m_gravity;
75  const Matrix3 Cg = skew(g);
76  const double T2 = T * T;
77  const double alpha = 1 / (T2);
78  // equation of waypoints for curve w found with sympy
79  waypoint_t w0 = initwp(DIM_POINT, DIM_VAR);
80  w0.first.block<3, 3>(0, 0) = 6 * alpha * Matrix3::Identity();
81  w0.first.block<3, 3>(3, 0) = 6.0 * Cpi[0] * alpha;
82  w0.second.head<3>() = (6 * pi[0] - 12 * pi[1]) * alpha;
83  w0.second.tail<3>() =
84  1.0 * (1.0 * Cg * T2 * pi[0] - 12.0 * Cpi[0] * pi[1]) * alpha;
85  wps.push_back(w0);
86  waypoint_t w1 = initwp(DIM_POINT, DIM_VAR);
87  w1.first.block<3, 3>(3, 0) = 1.0 * (-6.0 * Cpi[0] + 6.0 * Cpi[1]) * alpha;
88  w1.second.head<3>() = 1.0 * (4.0 * pi[0] - 6.0 * pi[1] + 2.0 * pi[3]) * alpha;
89  w1.second.tail<3>() =
90  1.0 * (1.0 * Cg * T2 * pi[1] + 2.0 * Cpi[0] * pi[3]) * alpha;
91  wps.push_back(w1);
92  waypoint_t w2 = initwp(DIM_POINT, DIM_VAR);
93  w2.first.block<3, 3>(0, 0) = -6.0 * alpha * Matrix3::Identity();
94  w2.first.block<3, 3>(3, 0) = 1.0 * (1.0 * Cg * T2 - 6.0 * Cpi[1]) * alpha;
95  w2.second.head<3>() = 1.0 * (2.0 * pi[0] + 4.0 * pi[3]) * alpha;
96  w2.second.tail<3>() =
97  1.0 * (-2.0 * Cpi[0] * pi[3] + 6.0 * Cpi[1] * pi[3]) * alpha;
98  wps.push_back(w2);
99  waypoint_t w3 = initwp(DIM_POINT, DIM_VAR);
100  w3.first.block<3, 3>(0, 0) = -12 * alpha * Matrix3::Identity();
101  w3.first.block<3, 3>(3, 0) = -12.0 * Cpi[3] * alpha;
102  w3.second.head<3>() = (6 * pi[1] + 6 * pi[3]) * alpha;
103  w3.second.tail<3>() =
104  1.0 * (1.0 * Cg * T2 * pi[3] - 6.0 * Cpi[1] * pi[3]) * alpha;
105  wps.push_back(w3);
106  return wps;
107 }
108 
109 inline coefs_t computeFinalVelocityPoint(const ProblemData& pData, double T) {
110  coefs_t v;
111  // equation found with sympy
112  v.first = -3. / T;
113  v.second = 3. * pData.c1_ / T;
114  return v;
115 }
116 
117 } // namespace c0_dc0_c1
118 } // namespace bezier_com_traj
119 
120 #endif
bezier_wp_t::t_point_t computeWwaypoints(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_c1.hh:64
waypoint6_t w2(point_t_tC p0, point_t_tC p1, point_t_tC g, const Matrix3 &, const Matrix3 &, const Matrix3 &gX, const double alpha)
Definition: solve_0_step.cpp:34
coefs_t evaluateCurveAtTime(const std::vector< point_t > &pi, double t)
evaluateCurveAtTime compute the expression of the point on the curve at t, defined by the waypoint pi...
Definition: waypoints_c0_dc0_c1.hh:25
centroidal_dynamics::Vector3 Vector3
Definition: definitions.hh:22
waypoint6_t w1(point_t_tC p0, point_t_tC p1, point_t_tC, const Matrix3 &, const Matrix3 &, const Matrix3 &gX, const double alpha)
Definition: solve_0_step.cpp:23
VectorX second
Definition: utils.hh:27
waypoint6_t w3(point_t_tC p0, point_t_tC p1, point_t_tC g, const Matrix3 &, const Matrix3 &, const Matrix3 &, const double alpha)
Definition: solve_0_step.cpp:45
INIT_VEL
Definition: flags.hh:21
std::vector< point_t > computeConstantWaypoints(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_c1.hh:49
Definition: utils.hh:25
point_t c0_
Definition: data.hh:107
MatrixXX first
Definition: utils.hh:26
END_POS
Definition: flags.hh:23
std::pair< double, point3_t > coefs_t
Definition: definitions.hh:62
point_t dc0_
Definition: data.hh:107
waypoint6_t w0(point_t_tC p0, point_t_tC p1, point_t_tC g, const Matrix3 &p0X, const Matrix3 &, const Matrix3 &, const double alpha)
Definition: solve_0_step.cpp:12
coefs_t computeFinalVelocityPoint(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_c1.hh:109
Eigen::Matrix< value_type, 3, 3 > Matrix3
Definition: definitions.hh:17
coefs_t evaluateAccelerationCurveAtTime(const std::vector< point_t > &pi, double T, double t)
Definition: waypoints_c0_dc0_c1.hh:37
Defines all the inputs of the problem: Initial and terminal constraints, as well as selected cost fun...
Definition: data.hh:92
Definition: common_solve_methods.hh:15
INIT_POS
Definition: flags.hh:20
BEZIER_COM_TRAJ_DLLAPI Matrix3 skew(point_t_tC x)
skew symmetric matrix
Definition: utils.cpp:62
std::vector< ContactData > contacts_
Definition: data.hh:106
point_t c1_
Definition: data.hh:107
const int DIM_POINT
Definition: solve_end_effector.hh:15