1 |
|
|
// |
2 |
|
|
// Copyright (c) 2014 CNRS |
3 |
|
|
// Authors: Steve Tonneau (steve.tonneau@laas.fr) |
4 |
|
|
// |
5 |
|
|
// This file is part of hpp-rbprm. |
6 |
|
|
// hpp-rbprm 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-rbprm 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-core If not, see |
17 |
|
|
// <http://www.gnu.org/licenses/>. |
18 |
|
|
|
19 |
|
|
#ifndef HPP_RBPRM_SAMPLE_HH |
20 |
|
|
#define HPP_RBPRM_SAMPLE_HH |
21 |
|
|
|
22 |
|
|
#include <Eigen/StdVector> |
23 |
|
|
#include <deque> |
24 |
|
|
#include <hpp/pinocchio/device.hh> |
25 |
|
|
#include <hpp/rbprm/config.hh> |
26 |
|
|
namespace hpp { |
27 |
|
|
|
28 |
|
|
namespace rbprm { |
29 |
|
|
namespace sampling { |
30 |
|
|
HPP_PREDEF_CLASS(Sample); |
31 |
|
|
|
32 |
|
|
/// Sample configuration for a robot limb, stored |
33 |
|
|
/// in an octree and used for proximity requests for contact creation. |
34 |
|
|
/// assumes that joints are compact, ie they all are consecutive in |
35 |
|
|
/// configuration. |
36 |
|
|
class Sample; |
37 |
|
|
typedef shared_ptr<Sample> SamplePtr_t; |
38 |
|
|
|
39 |
|
|
class HPP_RBPRM_DLLAPI Sample { |
40 |
|
|
public: |
41 |
|
|
/// \cond |
42 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
43 |
|
|
/// \endcond |
44 |
|
|
|
45 |
|
|
/// Creates a sample configuration, given the current configuration of a limb. |
46 |
|
|
/// the current Configuration_t of the limb will be used to compute the |
47 |
|
|
/// sample. \param limb root of the considered limb \param effector joint to |
48 |
|
|
/// be considered as the effector of the limb \param offset location of the |
49 |
|
|
/// contact point of the effector, relatively to the effector joint \param id |
50 |
|
|
/// optional identifier for the sample |
51 |
|
|
Sample(const pinocchio::JointPtr_t limb, const pinocchio::Frame effector, |
52 |
|
|
const fcl::Vec3f& offset = fcl::Vec3f(0, 0, 0), |
53 |
|
|
const fcl::Vec3f& limbOffset = fcl::Vec3f(0, 0, 0), |
54 |
|
|
const std::size_t id = 0); |
55 |
|
|
|
56 |
|
|
Sample(const std::size_t id, const std::size_t length, |
57 |
|
|
const std::size_t startRank, const double staticValue, |
58 |
|
|
const fcl::Vec3f& effectorPosition, |
59 |
|
|
const fcl::Vec3f& effectorPositionInLimbFrame, |
60 |
|
|
const pinocchio::ConfigurationIn_t configuration, |
61 |
|
|
const Eigen::MatrixXd& jacobian, |
62 |
|
|
const Eigen::Matrix<pinocchio::value_type, 6, 6>& jacobianProduct); |
63 |
|
|
|
64 |
|
|
/// Creates sample configuration for a limb, extracted from a complete robot |
65 |
|
|
/// configuration, passed as a parameter \param limb root of the considered |
66 |
|
|
/// limb \param the configuration from which the limb sample will be extracted |
67 |
|
|
/// \param effector joint to be considered as the effector of the limb |
68 |
|
|
/// \param offset location of the contact point of the effector, relatively to |
69 |
|
|
/// the effector joint \param id optional identifier for the sample |
70 |
|
|
Sample(const pinocchio::JointPtr_t limb, const pinocchio::Frame effector, |
71 |
|
|
pinocchio::ConfigurationIn_t configuration, |
72 |
|
|
const fcl::Vec3f& offset = fcl::Vec3f(0, 0, 0), |
73 |
|
|
const fcl::Vec3f& limbOffset = fcl::Vec3f(0, 0, 0), |
74 |
|
|
const std::size_t id = 0); |
75 |
|
|
Sample(const Sample& clone); |
76 |
|
59089 |
~Sample() {} |
77 |
|
|
|
78 |
|
|
public: |
79 |
|
|
std::size_t startRank_; |
80 |
|
|
std::size_t length_; |
81 |
|
|
pinocchio::Configuration_t configuration_; |
82 |
|
|
/// Position relative to robot root (ie, robot base at 0 everywhere) |
83 |
|
|
fcl::Vec3f effectorPosition_; |
84 |
|
|
fcl::Vec3f effectorPositionInLimbFrame_; |
85 |
|
|
Eigen::MatrixXd jacobian_; |
86 |
|
|
/// Product of the jacobian by its transpose |
87 |
|
|
Eigen::Matrix<pinocchio::value_type, 6, 6> jacobianProduct_; |
88 |
|
|
/// id in sample container |
89 |
|
|
std::size_t id_; |
90 |
|
|
double staticValue_; |
91 |
|
|
// const fcl::Transform3f rotation_; TODO |
92 |
|
|
}; // class Sample |
93 |
|
|
|
94 |
|
|
struct sample_greater { |
95 |
|
110597 |
bool operator()(const Sample& lhs, const Sample& rhs) const { |
96 |
|
110597 |
return lhs.staticValue_ > rhs.staticValue_; |
97 |
|
|
} |
98 |
|
|
}; |
99 |
|
|
|
100 |
|
|
typedef std::vector<Sample, Eigen::aligned_allocator<Sample> > SampleVector_t; |
101 |
|
|
/// Automatically generates a deque of sample configuration for a given limb of |
102 |
|
|
/// a robot \param limb root of the considered limb \param effector tag |
103 |
|
|
/// identifying the end effector of the limb \param nbSamples number of samples |
104 |
|
|
/// to be generated \param offset location of the contact point of the effector |
105 |
|
|
/// relatively to the effector joint origin \param limbOffset offset betwwen the |
106 |
|
|
/// limb joint position and it's link \return a deque of sample configurations |
107 |
|
|
/// respecting joint limits. |
108 |
|
|
SampleVector_t GenerateSamples( |
109 |
|
|
const pinocchio::JointPtr_t limb, const std::string& effector, |
110 |
|
|
const std::size_t nbSamples, const fcl::Vec3f& offset = fcl::Vec3f(0, 0, 0), |
111 |
|
|
const fcl::Vec3f& limbOffset = fcl::Vec3f(0, 0, 0)); |
112 |
|
|
|
113 |
|
|
/// Assigns the limb configuration associated with a sample to a robot |
114 |
|
|
/// configuration \param sample The limb configuration to load \param robot the |
115 |
|
|
/// configuration to be modified |
116 |
|
|
void Load(const Sample& sample, pinocchio::ConfigurationOut_t robot); |
117 |
|
|
|
118 |
|
|
} // namespace sampling |
119 |
|
|
} // namespace rbprm |
120 |
|
|
} // namespace hpp |
121 |
|
|
#endif // HPP_RBPRM_SAMPLE_HH |