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