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