1 |
|
|
/// Copyright (c) 2015 CNRS |
2 |
|
|
/// Authors: Joseph Mirabel |
3 |
|
|
/// |
4 |
|
|
/// |
5 |
|
|
// This file is part of hpp-wholebody-step. |
6 |
|
|
// hpp-wholebody-step-planner is free software: you can redistribute it |
7 |
|
|
// and/or modify it under the terms of the GNU Lesser General Public |
8 |
|
|
// License as published by the Free Software Foundation, either version |
9 |
|
|
// 3 of the License, or (at your option) any later version. |
10 |
|
|
// |
11 |
|
|
// hpp-wholebody-step-planner is distributed in the hope that it will be |
12 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
13 |
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
|
|
// General Lesser Public License for more details. You should have |
15 |
|
|
// received a copy of the GNU Lesser General Public License along with |
16 |
|
|
// hpp-wholebody-step-planner. If not, see |
17 |
|
|
// <http://www.gnu.org/licenses/>. |
18 |
|
|
|
19 |
|
|
#ifndef HPP_SPLINE_EFFECTOR_RRT_HH |
20 |
|
|
#define HPP_SPLINE_EFFECTOR_RRT_HH |
21 |
|
|
|
22 |
|
|
#include <ndcurves/bezier_curve.h> |
23 |
|
|
#include <ndcurves/curve_constraint.h> |
24 |
|
|
#include <ndcurves/exact_cubic.h> |
25 |
|
|
|
26 |
|
|
#include <hpp/core/config-projector.hh> |
27 |
|
|
#include <hpp/core/path.hh> |
28 |
|
|
#include <hpp/core/problem.hh> |
29 |
|
|
#include <hpp/rbprm/config.hh> |
30 |
|
|
#include <hpp/rbprm/interpolation/com-rrt.hh> |
31 |
|
|
#include <hpp/rbprm/interpolation/interpolation-constraints.hh> |
32 |
|
|
#include <hpp/rbprm/interpolation/spline/bezier-path.hh> |
33 |
|
|
#include <hpp/rbprm/interpolation/time-constraint-helper.hh> |
34 |
|
|
#include <hpp/rbprm/interpolation/time-constraint-path.hh> |
35 |
|
|
#include <hpp/rbprm/interpolation/time-constraint-steering.hh> |
36 |
|
|
#include <hpp/rbprm/rbprm-device.hh> |
37 |
|
|
#include <hpp/rbprm/rbprm-fullbody.hh> |
38 |
|
|
#include <hpp/rbprm/rbprm-state.hh> |
39 |
|
|
#include <map> |
40 |
|
|
#include <vector> |
41 |
|
|
|
42 |
|
|
namespace hpp { |
43 |
|
|
namespace rbprm { |
44 |
|
|
namespace interpolation { |
45 |
|
|
struct SetEffectorRRTConstraints; |
46 |
|
|
|
47 |
|
|
typedef TimeConstraintHelper<TimeConstraintPath, EffectorRRTShooterFactory, |
48 |
|
|
SetEffectorRRTConstraints> |
49 |
|
|
EffectorRRTHelper; |
50 |
|
|
|
51 |
|
|
core::PathPtr_t effectorRRT(RbPrmFullBodyPtr_t fullbody, |
52 |
|
|
core::ProblemSolverPtr_t problemSolver, |
53 |
|
|
const PathPtr_t comPath, const State& startState, |
54 |
|
|
const State& nextState, |
55 |
|
|
const std::size_t numOptimizations, |
56 |
|
|
const bool keepExtraDof); |
57 |
|
|
|
58 |
|
|
core::PathPtr_t effectorRRT( |
59 |
|
|
RbPrmFullBodyPtr_t fullbody, core::ProblemSolverPtr_t problemSolver, |
60 |
|
|
const PathPtr_t comPath, const State& startState, const State& nextState, |
61 |
|
|
const std::size_t numOptimizations, const bool keepExtraDof, |
62 |
|
|
const std::vector<std::string>& constrainedJointPos = |
63 |
|
|
std::vector<std::string>(), |
64 |
|
|
const std::vector<std::string>& constrainedLockedJoints = |
65 |
|
|
std::vector<std::string>()); |
66 |
|
|
|
67 |
|
|
core::PathPtr_t generateEndEffectorBezier( |
68 |
|
|
RbPrmFullBodyPtr_t fullbody, core::ProblemSolverPtr_t problemSolver, |
69 |
|
|
const PathPtr_t comPath, const State& startState, const State& nextState); |
70 |
|
|
|
71 |
|
|
/** |
72 |
|
|
* @brief effectorRRTFromPath Call comRRT to compute a whole body path between |
73 |
|
|
* two states, then compute an end-effector's trajectory with a bezier curve |
74 |
|
|
* that fit the initial path found by the rrt, and recompute the whole body |
75 |
|
|
* trajectory that follow the end effector constraint |
76 |
|
|
* @param fullbody |
77 |
|
|
* @param referenceProblem |
78 |
|
|
* @param comPath reference path for the center of mass |
79 |
|
|
* @param fullBodyComPath fullBody path previously computed |
80 |
|
|
* @param startState |
81 |
|
|
* @param nextState |
82 |
|
|
* @param numOptimizations |
83 |
|
|
* @param keepExtraDof if false, remove the additionnal extraDoF introduced by |
84 |
|
|
* comRRT |
85 |
|
|
* @param pathId the Id of the returned path in the problem-solver. Usef to |
86 |
|
|
* match with the end-effector path indice stored in fullBody |
87 |
|
|
* @param refFullBodyPath |
88 |
|
|
* @param constrainedJointPos |
89 |
|
|
* @param constrainedLockedJoints |
90 |
|
|
* @return the fullBody path |
91 |
|
|
*/ |
92 |
|
|
PathPtr_t effectorRRTFromPath( |
93 |
|
|
RbPrmFullBodyPtr_t fullbody, core::ProblemSolverPtr_t problemSolver, |
94 |
|
|
const PathPtr_t comPath, const PathPtr_t fullBodyComPath, |
95 |
|
|
const State& startState, const State& nextState, |
96 |
|
|
const std::size_t numOptimizations, const bool keepExtraDof, |
97 |
|
|
const PathPtr_t refPath, |
98 |
|
|
const std::vector<std::string>& constrainedJointPos, |
99 |
|
|
const std::vector<std::string>& constrainedLockedJoints); |
100 |
|
|
|
101 |
|
|
/** |
102 |
|
|
* @brief effectorRRTFromPath Call comRRT to compute a whole body path between |
103 |
|
|
* two states, then compute an end-effector's trajectory with a bezier curve |
104 |
|
|
* that fit the initial path found by the rrt, and recompute the whole body |
105 |
|
|
* trajectory that follow the end effector constraint |
106 |
|
|
* @param fullbody |
107 |
|
|
* @param referenceProblem |
108 |
|
|
* @param comPath reference path for the center of mass |
109 |
|
|
* @param startState |
110 |
|
|
* @param nextState |
111 |
|
|
* @param numOptimizations |
112 |
|
|
* @param keepExtraDof if false, remove the additionnal extraDoF introduced by |
113 |
|
|
* comRRT |
114 |
|
|
* @param pathId the Id of the returned path in the problem-solver. Usef to |
115 |
|
|
* match with the end-effector path indice stored in fullBody |
116 |
|
|
* @param refFullBodyPath |
117 |
|
|
* @param constrainedJointPos |
118 |
|
|
* @param constrainedLockedJoints |
119 |
|
|
* @return the fullBody path |
120 |
|
|
*/ |
121 |
|
|
core::PathPtr_t effectorRRTFromPath( |
122 |
|
|
RbPrmFullBodyPtr_t fullbody, core::ProblemSolverPtr_t problemSolver, |
123 |
|
|
const PathPtr_t comPath, const State& startState, const State& nextState, |
124 |
|
|
const std::size_t numOptimizations, const bool keepExtraDof, |
125 |
|
|
const PathPtr_t refFullBodyPath, |
126 |
|
|
const std::vector<std::string>& constrainedJointPos = |
127 |
|
|
std::vector<std::string>(), |
128 |
|
|
const std::vector<std::string>& constrainedLockedJoints = |
129 |
|
|
std::vector<std::string>()); |
130 |
|
|
|
131 |
|
|
/** |
132 |
|
|
* @brief fitBeziersToPath generate a vector of pathVector : each pathVector |
133 |
|
|
* containt BezierPath, computed with varying value of weight-rrt |
134 |
|
|
* @param fullbody |
135 |
|
|
* @param effector |
136 |
|
|
* @param comPathLength |
137 |
|
|
* @param fullBodyComPath |
138 |
|
|
* @param startState |
139 |
|
|
* @param nextState |
140 |
|
|
* @return |
141 |
|
|
*/ |
142 |
|
|
std::vector<core::PathVectorPtr_t> fitBeziersToPath( |
143 |
|
|
RbPrmFullBodyPtr_t fullbody, const pinocchio::Frame& effector, |
144 |
|
|
const value_type comPathLength, const PathPtr_t fullBodyComPath, |
145 |
|
|
const State& startState, const State& nextState); |
146 |
|
|
|
147 |
|
|
typedef ndcurves::exact_cubic<double, double, true, |
148 |
|
|
Eigen::Matrix<value_type, 3, 1> > |
149 |
|
|
exact_cubic_t; |
150 |
|
|
typedef ndcurves::curve_constraints<Eigen::Matrix<value_type, 3, 1> > |
151 |
|
|
curve_constraint_t; |
152 |
|
|
typedef shared_ptr<exact_cubic_t> exact_cubic_Ptr; |
153 |
|
|
|
154 |
|
|
struct SetEffectorRRTConstraints { |
155 |
|
|
SetEffectorRRTConstraints( |
156 |
|
|
const core::PathPtr_t refCom, const core::PathPtr_t refEff, |
157 |
|
|
const core::PathPtr_t refFullbody, const pinocchio::Frame effector, |
158 |
|
|
const pinocchio::DevicePtr_t endEffectorDevice, |
159 |
|
|
const std::vector<pinocchio::JointPtr_t>& constrainedJointPos, |
160 |
|
|
const std::vector<pinocchio::JointPtr_t>& constrainedLockedJoints) |
161 |
|
|
: refCom_(refCom), |
162 |
|
|
refFullbody_(refFullbody), |
163 |
|
|
refEff_(refEff), |
164 |
|
|
effector_(effector), |
165 |
|
|
endEffectorDevice_(endEffectorDevice), |
166 |
|
|
constrainedJointPos_(constrainedJointPos), |
167 |
|
|
constrainedLockedJoints_(constrainedLockedJoints) {} |
168 |
|
|
|
169 |
|
|
void operator()(EffectorRRTHelper& helper, const State& from, |
170 |
|
|
const State& to) const; |
171 |
|
|
const core::PathPtr_t refCom_; |
172 |
|
|
const core::PathPtr_t refFullbody_; |
173 |
|
|
const core::PathPtr_t refEff_; |
174 |
|
|
const pinocchio::Frame effector_; |
175 |
|
|
const pinocchio::DevicePtr_t endEffectorDevice_; |
176 |
|
|
const std::vector<pinocchio::JointPtr_t> constrainedJointPos_; |
177 |
|
|
const std::vector<pinocchio::JointPtr_t> constrainedLockedJoints_; |
178 |
|
|
}; |
179 |
|
|
|
180 |
|
|
struct EndEffectorPath { |
181 |
|
|
EndEffectorPath(const DevicePtr_t device, const pinocchio::Frame& effector, |
182 |
|
|
const PathPtr_t path, |
183 |
|
|
const fcl::Vec3f& offset = fcl::Vec3f(0, 0, 0)) |
184 |
|
|
: device_(device), |
185 |
|
|
effector_(effector), |
186 |
|
|
fullBodyPath_(path), |
187 |
|
|
positionConstraint_( |
188 |
|
|
createPositionMethod(device, fcl::Vec3f(), effector)), |
189 |
|
|
offset_(offset), |
190 |
|
|
length_(path->length()) {} |
191 |
|
|
vector_t operator()(value_type t) const; |
192 |
|
|
void setOffset(const fcl::Vec3f& offset) { |
193 |
|
|
hppDout(notice, "End effector path, offset = " << offset); |
194 |
|
|
offset_ = offset; |
195 |
|
|
} |
196 |
|
|
|
197 |
|
|
const core::DevicePtr_t device_; |
198 |
|
|
const pinocchio::Frame effector_; |
199 |
|
|
const core::PathPtr_t fullBodyPath_; |
200 |
|
|
constraints::PositionPtr_t positionConstraint_; |
201 |
|
|
fcl::Vec3f offset_; |
202 |
|
|
const value_type length_; |
203 |
|
|
}; |
204 |
|
|
|
205 |
|
|
} // namespace interpolation |
206 |
|
|
} // namespace rbprm |
207 |
|
|
} // namespace hpp |
208 |
|
|
#endif // HPP_SPLINE_EFFECTOR_TRAJECTORY_HH |