hpp-bezier-com-traj  4.12.0
Multi contact trajectory generation for the COM using Bezier curves
waypoints_c0_dc0_ddc0_dc1_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_c0_dc0_ddc0_dc1_c1_H
7 #define BEZIER_COM_TRAJ_c0_dc0_ddc0_dc1_c1_H
8 
10 
11 namespace bezier_com_traj {
12 namespace c0_dc0_ddc0_dc1_c1 {
13 
14 static const ConstraintFlag flag = INIT_POS | INIT_VEL | INIT_ACC | END_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  double t4 = t3 * t;
30  double t5 = t4 * t;
31  // equation found with sympy
32  wp.first = 10.0 * t5 - 20.0 * t4 + 10.0 * t3;
33  wp.second = -1.0 * pi[0] * t5 + 5.0 * pi[0] * t4 - 10.0 * pi[0] * t3 + 10.0 * pi[0] * t2 - 5.0 * pi[0] * t +
34  1.0 * pi[0] + 5.0 * pi[1] * t5 - 20.0 * pi[1] * t4 + 30.0 * pi[1] * t3 - 20.0 * pi[1] * t2 +
35  5.0 * pi[1] * t - 10.0 * pi[2] * t5 + 30.0 * pi[2] * t4 - 30.0 * pi[2] * t3 + 10.0 * pi[2] * t2 -
36  5.0 * pi[4] * t5 + 5.0 * pi[4] * t4 + 1.0 * pi[5] * t5;
37  return wp;
38 }
39 
40 inline coefs_t evaluateAccelerationCurveAtTime(const std::vector<point_t>& pi, double T, double t) {
41  coefs_t wp;
42  double alpha = 1. / (T * T);
43  double t2 = t * t;
44  double t3 = t2 * t;
45  // equation found with sympy
46  wp.first = (200.0 * t3 - 240.0 * t2 + 60.0 * t) * alpha;
47  wp.second = 1.0 *
48  (-20.0 * pi[0] * t3 + 60.0 * pi[0] * t2 - 60.0 * pi[0] * t + 20.0 * pi[0] + 100.0 * pi[1] * t3 -
49  240.0 * pi[1] * t2 + 180.0 * pi[1] * t - 40.0 * pi[1] - 200.0 * pi[2] * t3 + 360.0 * pi[2] * t2 -
50  180.0 * pi[2] * t + 20.0 * pi[2] - 100.0 * pi[4] * t3 + 60.0 * pi[4] * t2 + 20.0 * pi[5] * t3) *
51  alpha;
52  return wp;
53 }
54 
55 inline std::vector<point_t> computeConstantWaypoints(const ProblemData& pData, double T) {
56  // equation for constraint on initial and final position and velocity and initial acceleration(degree 5, 5 constant
57  // waypoint and one free (p3)) first, compute the constant waypoints that only depend on pData :
58  double n = 5.;
59  std::vector<point_t> pi;
60  pi.push_back(pData.c0_); // p0
61  pi.push_back((pData.dc0_ * T / n) + pData.c0_); // p1
62  pi.push_back((pData.ddc0_ * T * T / (n * (n - 1))) + (2. * pData.dc0_ * T / n) + pData.c0_); // p2
63  pi.push_back(point_t::Zero()); // x
64  pi.push_back((-pData.dc1_ * T / n) + pData.c1_); // p4
65  pi.push_back(pData.c1_); // p5
66  return pi;
67 }
68 
69 inline bezier_wp_t::t_point_t computeWwaypoints(const ProblemData& pData, double T) {
70  bezier_wp_t::t_point_t wps;
71  const int DIM_POINT = 6;
72  const int DIM_VAR = 3;
73  std::vector<point_t> pi = computeConstantWaypoints(pData, T);
74  std::vector<Matrix3> Cpi;
75  for (std::size_t i = 0; i < pi.size(); ++i) {
76  Cpi.push_back(skew(pi[i]));
77  }
78  const Vector3 g = pData.contacts_.front().contactPhase_->m_gravity;
79  const Matrix3 Cg = skew(g);
80  const double T2 = T * T;
81  const double alpha = 1 / (T2);
82 
83  // equation of waypoints for curve w found with sympy
84  waypoint_t w0 = initwp(DIM_POINT, DIM_VAR);
85  w0.second.head<3>() = (20 * pi[0] - 40 * pi[1] + 20 * pi[2]) * alpha;
86  w0.second.tail<3>() = 1.0 * (1.0 * Cg * T2 * pi[0] - 40.0 * Cpi[0] * pi[1] + 20.0 * Cpi[0] * pi[2]) * alpha;
87  wps.push_back(w0);
88  waypoint_t w1 = initwp(DIM_POINT, DIM_VAR);
89  w1.first.block<3, 3>(0, 0) = 8.57142857142857 * alpha * Matrix3::Identity();
90  w1.first.block<3, 3>(3, 0) = 8.57142857142857 * Cpi[0] * alpha;
91  w1.second.head<3>() = 1.0 * (11.4285714285714 * pi[0] - 14.2857142857143 * pi[1] - 5.71428571428572 * pi[2]) * alpha;
92  w1.second.tail<3>() = 1.0 *
93  (0.285714285714286 * Cg * T2 * pi[0] + 0.714285714285714 * Cg * T2 * pi[1] -
94  20.0 * Cpi[0] * pi[2] + 14.2857142857143 * Cpi[1] * pi[2]) *
95  alpha;
96  wps.push_back(w1);
97  waypoint_t w2 = initwp(DIM_POINT, DIM_VAR);
98  w2.first.block<3, 3>(0, 0) = 5.71428571428571 * alpha * Matrix3::Identity();
99  w2.first.block<3, 3>(3, 0) = 1.0 * (-8.57142857142857 * Cpi[0] + 14.2857142857143 * Cpi[1]) * alpha;
100  w2.second.head<3>() = 1.0 * (5.71428571428571 * pi[0] - 14.2857142857143 * pi[2] + 2.85714285714286 * pi[4]) * alpha;
101  w2.second.tail<3>() =
102  1.0 *
103  (0.0476190476190479 * Cg * T2 * pi[0] + 0.476190476190476 * Cg * T2 * pi[1] +
104  0.476190476190476 * Cg * T2 * pi[2] + 2.85714285714286 * Cpi[0] * pi[4] - 14.2857142857143 * Cpi[1] * pi[2]) *
105  alpha;
106  wps.push_back(w2);
107  waypoint_t w3 = initwp(DIM_POINT, DIM_VAR);
108  w3.first.block<3, 3>(0, 0) = -2.85714285714286 * alpha * Matrix3::Identity();
109  w3.first.block<3, 3>(3, 0) =
110  1.0 * (0.285714285714286 * Cg * T2 - 14.2857142857143 * Cpi[1] + 11.4285714285714 * Cpi[2]) * alpha;
111  w3.second.head<3>() = 1.0 *
112  (2.28571428571429 * pi[0] + 5.71428571428571 * pi[1] - 11.4285714285714 * pi[2] +
113  5.71428571428571 * pi[4] + 0.571428571428571 * pi[5]) *
114  alpha;
115  w3.second.tail<3>() =
116  1.0 *
117  (0.142857142857143 * Cg * T2 * pi[1] + 0.571428571428571 * Cg * T2 * pi[2] - 2.85714285714286 * Cpi[0] * pi[4] +
118  0.571428571428571 * Cpi[0] * pi[5] + 8.57142857142857 * Cpi[1] * pi[4]) *
119  alpha;
120  wps.push_back(w3);
121  waypoint_t w4 = initwp(DIM_POINT, DIM_VAR);
122  w4.first.block<3, 3>(0, 0) = -11.4285714285714 * alpha * Matrix3::Identity();
123  w4.first.block<3, 3>(3, 0) = 1.0 * (0.571428571428571 * Cg * T2 - 11.4285714285714 * Cpi[2]) * alpha;
124  w4.second.head<3>() = 1.0 *
125  (0.571428571428571 * pi[0] + 5.71428571428571 * pi[1] - 2.85714285714286 * pi[2] +
126  5.71428571428571 * pi[4] + 2.28571428571429 * pi[5]) *
127  alpha;
128  w4.second.tail<3>() =
129  1.0 *
130  (0.285714285714286 * Cg * T2 * pi[2] + 0.142857142857143 * Cg * T2 * pi[4] - 0.571428571428572 * Cpi[0] * pi[5] -
131  8.57142857142857 * Cpi[1] * pi[4] + 2.85714285714286 * Cpi[1] * pi[5] + 14.2857142857143 * Cpi[2] * pi[4]) *
132  alpha;
133  wps.push_back(w4);
134  waypoint_t w5 = initwp(DIM_POINT, DIM_VAR);
135  w5.first.block<3, 3>(0, 0) = -14.2857142857143 * alpha * Matrix3::Identity();
136  w5.first.block<3, 3>(3, 0) = 1.0 * (0.476190476190476 * Cg * T2 - 14.2857142857143 * Cpi[4]) * alpha;
137  w5.second.head<3>() = 1.0 * (2.85714285714286 * pi[1] + 5.71428571428571 * pi[2] + 5.71428571428571 * pi[5]) * alpha;
138  w5.second.tail<3>() =
139  1.0 *
140  (0.476190476190476 * Cg * T2 * pi[4] + 0.0476190476190476 * Cg * T2 * pi[5] - 2.85714285714286 * Cpi[1] * pi[5] -
141  14.2857142857143 * Cpi[2] * pi[4] + 8.57142857142857 * Cpi[2] * pi[5]) *
142  alpha;
143  wps.push_back(w5);
144  waypoint_t w6 = initwp(DIM_POINT, DIM_VAR);
145  w6.first.block<3, 3>(0, 0) = -5.71428571428572 * alpha * Matrix3::Identity();
146  w6.first.block<3, 3>(3, 0) = 1.0 * (14.2857142857143 * Cpi[4] - 20.0 * Cpi[5]) * alpha;
147  w6.second.head<3>() = 1.0 * (8.57142857142857 * pi[2] - 14.2857142857143 * pi[4] + 11.4285714285714 * pi[5]) * alpha;
148  w6.second.tail<3>() =
149  1.0 *
150  (0.714285714285714 * Cg * T2 * pi[4] + 0.285714285714286 * Cg * T2 * pi[5] - 8.57142857142858 * Cpi[2] * pi[5]) *
151  alpha;
152  wps.push_back(w6);
153  waypoint_t w7 = initwp(DIM_POINT, DIM_VAR);
154  w7.first.block<3, 3>(0, 0) = 20 * alpha * Matrix3::Identity();
155  w7.first.block<3, 3>(3, 0) = 1.0 * (20.0 * Cpi[5]) * alpha;
156  w7.second.head<3>() = (-40 * pi[4] + 20 * pi[5]) * alpha;
157  w7.second.tail<3>() = 1.0 * (1.0 * Cg * T2 * pi[5] + 40.0 * Cpi[4] * pi[5]) * alpha;
158  wps.push_back(w7);
159  return wps;
160 }
161 
162 inline coefs_t computeFinalVelocityPoint(const ProblemData& pData, double T) {
163  coefs_t v;
164  std::vector<point_t> pi = computeConstantWaypoints(pData, T);
165  // equation found with sympy
166  v.first = 0.;
167  v.second = (-5.0 * pi[4] + 5.0 * pi[5]) / T;
168  return v;
169 }
170 
171 } // namespace c0_dc0_ddc0_dc1_c1
172 } // namespace bezier_com_traj
173 
174 #endif
coefs_t computeFinalVelocityPoint(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_ddc0_dc1_c1.hh:162
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_ddc0_dc1_c1.hh:25
point_t ddc0_
Definition: data.hh:103
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:32
centroidal_dynamics::Vector3 Vector3
Definition: definitions.hh:21
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:22
VectorX second
Definition: utils.hh:29
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:42
INIT_VEL
Definition: flags.hh:21
Definition: utils.hh:27
waypoint6_t w4(point_t_tC, point_t_tC p1, point_t_tC g, const Matrix3 &, const Matrix3 &, const Matrix3 &, const double alpha)
Definition: solve_0_step.cpp:52
point_t c0_
Definition: data.hh:103
MatrixXX first
Definition: utils.hh:28
END_POS
Definition: flags.hh:23
point_t dc1_
Definition: data.hh:103
std::pair< double, point3_t > coefs_t
Definition: definitions.hh:61
INIT_ACC
Definition: flags.hh:22
point_t dc0_
Definition: data.hh:103
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
bezier_wp_t::t_point_t computeWwaypoints(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_ddc0_dc1_c1.hh:69
coefs_t evaluateAccelerationCurveAtTime(const std::vector< point_t > &pi, double T, double t)
Definition: waypoints_c0_dc0_ddc0_dc1_c1.hh:40
END_VEL
Definition: flags.hh:24
Eigen::Matrix< value_type, 3, 3 > Matrix3
Definition: definitions.hh:16
Defines all the inputs of the problem: Initial and terminal constraints, as well as selected cost fun...
Definition: data.hh:88
Definition: common_solve_methods.hh:16
INIT_POS
Definition: flags.hh:20
std::vector< point_t > computeConstantWaypoints(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_ddc0_dc1_c1.hh:55
BEZIER_COM_TRAJ_DLLAPI Matrix3 skew(point_t_tC x)
skew symmetric matrix
Definition: utils.cpp:56
std::vector< ContactData > contacts_
Definition: data.hh:102
point_t c1_
Definition: data.hh:103
const int DIM_POINT
Definition: solve_end_effector.hh:15