hpp-bezier-com-traj  4.11.0
Multi contact trajectory generation for the COM using Bezier curves
waypoints_c0_dc0_dc1.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_C0DC0D1_H
7 #define BEZIER_COM_TRAJ_C0DC0D1_H
8 
10 
11 namespace bezier_com_traj {
12 namespace c0_dc0_dc1 {
13 
14 static const ConstraintFlag flag = INIT_POS | INIT_VEL | END_VEL;
15 
17 
23 inline coefs_t evaluateCurveAtTime(const std::vector<point_t>& pi, double t) {
24  coefs_t wp;
25  double t2 = t * t;
26  double t3 = t2 * t;
27  // equation found with sympy
28  wp.first = -2.0 * t3 + 3.0 * t2;
29  wp.second = -1.0 * pi[0] * t3 + 3.0 * pi[0] * t2 - 3.0 * pi[0] * t + 1.0 * pi[0] + 3.0 * pi[1] * t3 -
30  6.0 * pi[1] * t2 + 3.0 * pi[1] * t;
31  return wp;
32 }
33 
34 inline coefs_t evaluateAccelerationCurveAtTime(const std::vector<point_t>& pi, double T, double t) {
35  coefs_t wp;
36  double alpha = 1. / (T * T);
37  // equation found with sympy
38  wp.first = (-12.0 * t + 6.0) * alpha;
39  wp.second = (-6.0 * pi[0] * t + 6.0 * pi[0] + 18.0 * pi[1] * t - 12.0 * pi[1]) * alpha;
40  return wp;
41 }
42 
43 inline std::vector<point_t> computeConstantWaypoints(const ProblemData& pData, double T) {
44  // equation for constraint on initial and final position and velocity (degree 3, 2 constant waypoints and two free
45  // (p2 = p3)) first, compute the constant waypoints that only depend on pData :
46  if (pData.dc1_.norm() != 0.) throw std::runtime_error("Capturability not implemented for spped different than 0");
47  std::vector<point_t> pi;
48  pi.push_back(pData.c0_); // p0
49  pi.push_back((pData.dc0_ * T / 3.) + pData.c0_); // p1
50  pi.push_back(point_t::Zero()); // p2 = x
51  pi.push_back(point_t::Zero()); // p3 = x
52  return pi;
53 }
54 
55 inline bezier_wp_t::t_point_t computeWwaypoints(const ProblemData& pData, double T) {
56  bezier_wp_t::t_point_t wps;
57  const int DIM_POINT = 6;
58  const int DIM_VAR = 3;
59  std::vector<point_t> pi = c0_dc0_dc1::computeConstantWaypoints(pData, T);
60  std::vector<Matrix3> Cpi;
61  for (std::size_t i = 0; i < pi.size(); ++i) {
62  Cpi.push_back(skew(pi[i]));
63  }
64  const Vector3 g = pData.contacts_.front().contactPhase_->m_gravity;
65  const Matrix3 Cg = skew(g);
66  const double T2 = T * T;
67  const double alpha = 1. / (T2);
68  // equation of waypoints for curve w found with sympy
69  // TODO Apparently sympy equations are false ...
70 
71  waypoint_t w0 = initwp(DIM_POINT, DIM_VAR);
72  w0.first.block<3, 3>(0, 0) = 6 * alpha * Matrix3::Identity();
73  w0.first.block<3, 3>(3, 0) = 6.0 * Cpi[0] * alpha;
74  w0.second.head<3>() = (6 * pi[0] - 12 * pi[1]) * alpha;
75  w0.second.tail<3>() = (-Cpi[0]) * (12.0 * pi[1] * alpha + g);
76  wps.push_back(w0);
77  waypoint_t w1 = initwp(DIM_POINT, DIM_VAR);
78  w1.first.block<3, 3>(0, 0) = 3 * alpha * Matrix3::Identity();
79  w1.first.block<3, 3>(3, 0) = skew(1.5 * (3 * pi[1] - pi[0])) * alpha;
80  w1.second.head<3>() = 1.5 * alpha * (3 * pi[0] - 5 * pi[1]);
81  w1.second.tail<3>() = (3 * alpha * pi[0]).cross(-pi[1]) + 0.25 * (Cg * (3 * pi[1] + pi[0]));
82  wps.push_back(w1);
83  waypoint_t w2 = initwp(DIM_POINT, DIM_VAR);
84  w2.first.block<3, 3>(0, 0) = 0 * alpha * Matrix3::Identity();
85  w2.first.block<3, 3>(3, 0) = skew(0.5 * g - 3 * alpha * pi[0] + 3 * alpha * pi[1]);
86  w2.second.head<3>() = 3 * alpha * (pi[0] - pi[1]);
87  w2.second.tail<3>() = 0.5 * Cg * pi[1];
88  wps.push_back(w2);
89  waypoint_t w3 = initwp(DIM_POINT, DIM_VAR);
90  w3.first.block<3, 3>(0, 0) = -3 * alpha * Matrix3::Identity();
91  w3.first.block<3, 3>(3, 0) = skew(g - 1.5 * alpha * (pi[1] + pi[0]));
92  w3.second.head<3>() = 1.5 * alpha * (pi[1] + pi[0]);
93  wps.push_back(w3);
94  waypoint_t w4 = initwp(DIM_POINT, DIM_VAR);
95  w4.first.block<3, 3>(0, 0) = -6 * alpha * Matrix3::Identity();
96  w4.first.block<3, 3>(3, 0) = skew(g - 6 * alpha * pi[1]);
97  w4.second.head<3>() = 6 * pi[1] * alpha;
98  wps.push_back(w4);
99  return wps;
100 }
101 
102 inline coefs_t computeFinalVelocityPoint(const ProblemData& pData, double T) {
103  coefs_t v;
104  std::vector<point_t> pi = c0_dc0_dc1::computeConstantWaypoints(pData, T);
105  // equation found with sympy
106  v.first = 0.;
107  v.second = point3_t::Zero();
108  return v;
109 }
110 
111 } // namespace c0_dc0_dc1
112 } // namespace bezier_com_traj
113 
114 #endif
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
coefs_t evaluateAccelerationCurveAtTime(const std::vector< point_t > &pi, double T, double t)
Definition: waypoints_c0_dc0_dc1.hh:34
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
bezier_wp_t::t_point_t computeWwaypoints(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_dc1.hh:55
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
coefs_t evaluateCurveAtTime(const std::vector< point_t > &pi, double t)
EQUATION FOR CONSTRAINTS ON INIT AND FINAL POSITION AND VELOCITY (DEGREE = 4)
Definition: waypoints_c0_dc0_dc1.hh:23
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
coefs_t computeFinalVelocityPoint(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_dc1.hh:102
point_t dc1_
Definition: data.hh:103
std::pair< double, point3_t > coefs_t
Definition: definitions.hh:61
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
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
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
std::vector< point_t > computeConstantWaypoints(const ProblemData &pData, double T)
Definition: waypoints_c0_dc0_dc1.hh:43
const int DIM_POINT
Definition: solve_end_effector.hh:15