Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2014 CNRS |
3 |
|
|
// Authors: Florent Lamiraux |
4 |
|
|
// |
5 |
|
|
// |
6 |
|
|
|
7 |
|
|
// Redistribution and use in source and binary forms, with or without |
8 |
|
|
// modification, are permitted provided that the following conditions are |
9 |
|
|
// met: |
10 |
|
|
// |
11 |
|
|
// 1. Redistributions of source code must retain the above copyright |
12 |
|
|
// notice, this list of conditions and the following disclaimer. |
13 |
|
|
// |
14 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright |
15 |
|
|
// notice, this list of conditions and the following disclaimer in the |
16 |
|
|
// documentation and/or other materials provided with the distribution. |
17 |
|
|
// |
18 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 |
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 |
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 |
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 |
|
|
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 |
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 |
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 |
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 |
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
29 |
|
|
// DAMAGE. |
30 |
|
|
|
31 |
|
|
#ifndef HPP_CONSTRAINTS_RELATIVE_COM_HH |
32 |
|
|
#define HPP_CONSTRAINTS_RELATIVE_COM_HH |
33 |
|
|
|
34 |
|
|
#include <hpp/constraints/config.hh> |
35 |
|
|
#include <hpp/constraints/differentiable-function.hh> |
36 |
|
|
#include <hpp/constraints/fwd.hh> |
37 |
|
|
|
38 |
|
|
namespace hpp { |
39 |
|
|
namespace constraints { |
40 |
|
|
|
41 |
|
|
/// \addtogroup constraints |
42 |
|
|
/// \{ |
43 |
|
|
|
44 |
|
|
/** |
45 |
|
|
* Constraint on the relative position of the center of mass |
46 |
|
|
* |
47 |
|
|
* The value of the function is defined as the position of the center |
48 |
|
|
* of mass in the reference frame of a joint. |
49 |
|
|
* |
50 |
|
|
* \f{eqnarray*} |
51 |
|
|
* \mathbf{f}(\mathbf{q}) &=& R^T \left(\mathbf{x} - \mathbf{t}\right) |
52 |
|
|
* - \mathbf{x}^{*}\\ |
53 |
|
|
* \mathbf{\dot{f}} &=& R^T \left( |
54 |
|
|
* J_{com} + [\mathbf{x}-\mathbf{t}]_{\times}J_{joint}^{\omega} |
55 |
|
|
* - J_{joint}^{\mathbf{v}}\right)\mathbf{\dot{q}} |
56 |
|
|
* \f} |
57 |
|
|
* |
58 |
|
|
* where |
59 |
|
|
* \li \f$ |
60 |
|
|
* \left(\begin{array}{cc} R & \mathbf{t} \\ 0 & 1\end{array}\right) |
61 |
|
|
* \f$ |
62 |
|
|
* is the position of the joint, |
63 |
|
|
* \li \f$\mathbf{x}\f$ is the position of the center of mass, |
64 |
|
|
* \li \f$\mathbf{x}^{*}\f$ is the desired position of the center of mass |
65 |
|
|
* expressed in joint frame. |
66 |
|
|
**/ |
67 |
|
|
class HPP_CONSTRAINTS_DLLAPI RelativeCom : public DifferentiableFunction { |
68 |
|
|
public: |
69 |
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW |
70 |
|
|
/// Return a shared pointer to a new instance |
71 |
|
|
static RelativeComPtr_t create( |
72 |
|
|
const DevicePtr_t& robot, const JointPtr_t& joint, |
73 |
|
|
const vector3_t reference, |
74 |
|
|
std::vector<bool> mask = std::vector<bool>(3, true)) { |
75 |
|
|
return create("RelativeCom", robot, joint, reference, mask); |
76 |
|
|
} |
77 |
|
|
static RelativeComPtr_t create( |
78 |
|
|
const std::string& name, const DevicePtr_t& robot, |
79 |
|
|
const JointPtr_t& joint, const vector3_t reference, |
80 |
|
|
std::vector<bool> mask = std::vector<bool>(3, true)); |
81 |
|
|
static RelativeComPtr_t create( |
82 |
|
|
const DevicePtr_t& robot, const CenterOfMassComputationPtr_t& comc, |
83 |
|
|
const JointPtr_t& joint, const vector3_t reference, |
84 |
|
|
std::vector<bool> mask = std::vector<bool>(3, true)); |
85 |
|
|
static RelativeComPtr_t create( |
86 |
|
|
const std::string& name, const DevicePtr_t& robot, |
87 |
|
|
const CenterOfMassComputationPtr_t& comc, const JointPtr_t& joint, |
88 |
|
|
const vector3_t reference, |
89 |
|
|
std::vector<bool> mask = std::vector<bool>(3, true)); |
90 |
|
4 |
virtual ~RelativeCom() {} |
91 |
|
|
RelativeCom(const DevicePtr_t& robot, |
92 |
|
|
const CenterOfMassComputationPtr_t& comc, const JointPtr_t& joint, |
93 |
|
|
const vector3_t reference, std::vector<bool> mask, |
94 |
|
|
const std::string& name); |
95 |
|
|
|
96 |
|
|
virtual std::ostream& print(std::ostream& o) const; |
97 |
|
|
|
98 |
|
|
protected: |
99 |
|
|
/// Compute value of error |
100 |
|
|
/// |
101 |
|
|
/// \param argument configuration of the robot, |
102 |
|
|
/// \retval result error vector |
103 |
|
|
virtual void impl_compute(LiegroupElementRef result, |
104 |
|
|
ConfigurationIn_t argument) const; |
105 |
|
|
virtual void impl_jacobian(matrixOut_t jacobian, ConfigurationIn_t arg) const; |
106 |
|
|
|
107 |
|
✗ |
bool isEqual(const DifferentiableFunction& other) const { |
108 |
|
✗ |
const RelativeCom& castother = dynamic_cast<const RelativeCom&>(other); |
109 |
|
✗ |
if (!DifferentiableFunction::isEqual(other)) return false; |
110 |
|
|
|
111 |
|
✗ |
if (robot_ != castother.robot_) return false; |
112 |
|
✗ |
if (comc_ != castother.comc_) return false; |
113 |
|
✗ |
if (joint_ != castother.joint_) return false; |
114 |
|
✗ |
if (mask_ != castother.mask_) return false; |
115 |
|
✗ |
if (nominalCase_ != castother.nominalCase_) return false; |
116 |
|
|
|
117 |
|
✗ |
return true; |
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
private: |
121 |
|
|
DevicePtr_t robot_; |
122 |
|
|
CenterOfMassComputationPtr_t comc_; |
123 |
|
|
JointPtr_t joint_; |
124 |
|
|
vector3_t reference_; |
125 |
|
|
std::vector<bool> mask_; |
126 |
|
|
bool nominalCase_; |
127 |
|
|
mutable ComJacobian_t jacobian_; |
128 |
|
|
|
129 |
|
✗ |
RelativeCom() {} |
130 |
|
|
HPP_SERIALIZABLE(); |
131 |
|
|
}; // class RelativeCom |
132 |
|
|
/// \} |
133 |
|
|
} // namespace constraints |
134 |
|
|
} // namespace hpp |
135 |
|
|
#endif // HPP_CONSTRAINTS_RELATIVE_COM_HH |
136 |
|
|
|