hpp-constraints 6.0.0
Definition of basic geometric constraints for motion planning
Loading...
Searching...
No Matches
relative-transformation.hh
Go to the documentation of this file.
1// Copyright (c) 2015 - 2018, CNRS
2// Authors: Joseph Mirabel (joseph.mirabel@laas.fr), Florent Lamiraux
3//
4
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// 1. Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright
13// notice, this list of conditions and the following disclaimer in the
14// documentation and/or other materials provided with the distribution.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27// DAMAGE.
28
29#ifndef HPP_CONSTRAINTS_EXPLICIT_RELATIVE_TRANSFORMATION_HH
30#define HPP_CONSTRAINTS_EXPLICIT_RELATIVE_TRANSFORMATION_HH
31
35
36namespace hpp {
37namespace constraints {
40
41namespace explicit_ {
44
58 : public DifferentiableFunction {
59 public:
69 static RelativeTransformationPtr_t create(const std::string& name,
70 const DevicePtr_t& robot,
71 const JointConstPtr_t& joint1,
72 const JointConstPtr_t& joint2,
73 const Transform3s& frame1,
74 const Transform3s& frame2);
75
77 const JointConstPtr_t& joint1() const { return joint1_; }
78
80 const JointConstPtr_t& joint2() const { return joint2_; }
81
91 std::pair<JointConstPtr_t, JointConstPtr_t> dependsOnRelPoseBetween(
92 DeviceConstPtr_t /*robot*/) const {
93 JointConstPtr_t j1 = joint1();
94 JointConstPtr_t j2 = joint2();
95 size_type index1 = (j1 ? j1->index() : 0);
96 size_type index2 = (j2 ? j2->index() : 0);
97 if (index1 <= index2) {
98 return std::pair<JointConstPtr_t, JointConstPtr_t>(j1, j2);
99 } else {
100 return std::pair<JointConstPtr_t, JointConstPtr_t>(j2, j1);
101 }
102 };
103
104 protected:
108
109 RelativeTransformation(const std::string& name, const DevicePtr_t& robot,
110 const JointConstPtr_t& joint1,
111 const JointConstPtr_t& joint2,
112 const Transform3s& frame1, const Transform3s& frame2,
113 const segments_t inConf, const segments_t outConf,
114 const segments_t inVel, const segments_t outVel,
115 std::vector<bool> mask = std::vector<bool>(6, true));
116
118 : DifferentiableFunction(other),
119 robot_(other.robot_),
120 parentJoint_(other.parentJoint_),
121 inConf_(other.inConf_),
122 inVel_(other.inVel_),
123 outConf_(other.outConf_),
124 outVel_(other.outVel_),
125 F1inJ1_invF2inJ2_(other.F1inJ1_invF2inJ2_) {}
126
127 // Store weak pointer to itself
128 void init(const RelativeTransformationWkPtr_t& weak) { weak_ = weak; }
129
136 void impl_compute(LiegroupElementRef result, vectorIn_t argument) const;
137
138 void impl_jacobian(matrixOut_t jacobian, vectorIn_t arg) const;
139
140 bool isEqual(const DifferentiableFunction& other) const {
141 const RelativeTransformation& castother =
142 dynamic_cast<const RelativeTransformation&>(other);
143 if (!DifferentiableFunction::isEqual(other)) return false;
144
145 if (robot_ != castother.robot_) return false;
146 if (parentJoint_ != castother.parentJoint_) return false;
147 if (joint1_ != castother.joint1_) return false;
148 if (joint2_ != castother.joint2_) return false;
149 if (frame1_ != castother.frame1_) return false;
150 if (frame2_ != castother.frame2_) return false;
151 if (inConf_.rows() != castother.inConf_.rows()) return false;
152 if (inVel_.cols() != castother.inVel_.cols()) return false;
153 if (outConf_.rows() != castother.outConf_.rows()) return false;
154 if (outVel_.rows() != castother.outVel_.rows()) return false;
155 if (F1inJ1_invF2inJ2_ != castother.F1inJ1_invF2inJ2_) return false;
156
157 return true;
158 }
159
160 private:
161 void forwardKinematics(vectorIn_t arg) const;
162
163 DevicePtr_t robot_;
164 // Parent of the R3 joint.
165 JointConstPtr_t parentJoint_;
166 JointConstPtr_t joint1_, joint2_;
167 Transform3s frame1_, frame2_;
168 RowBlockIndices inConf_;
169 ColBlockIndices inVel_;
170 RowBlockIndices outConf_, outVel_;
171 Transform3s F1inJ1_invF2inJ2_;
172
173 RelativeTransformationWkPtr_t weak_;
174
175 // Tmp variables
176 mutable vector_t qsmall_, q_;
177 mutable matrix_t tmpJac_, J2_parent_minus_J1_;
178
180 HPP_SERIALIZABLE();
181}; // class RelativeTransformation
183
184} // namespace explicit_
185} // namespace constraints
186} // namespace hpp
187
189
190#endif // HPP_CONSTRAINTS_EXPLICIT_RELATIVE_TRANSFORMATION_HH
const ColIndices_t & cols() const
Definition matrix-view.hh:679
const RowIndices_t & rows() const
Definition matrix-view.hh:675
Definition differentiable-function.hh:63
Definition relative-transformation.hh:58
void init(const RelativeTransformationWkPtr_t &weak)
Definition relative-transformation.hh:128
Eigen::RowBlockIndices RowBlockIndices
Definition relative-transformation.hh:106
std::pair< JointConstPtr_t, JointConstPtr_t > dependsOnRelPoseBetween(DeviceConstPtr_t) const
Definition relative-transformation.hh:91
Eigen::BlockIndex BlockIndex
Definition relative-transformation.hh:105
bool isEqual(const DifferentiableFunction &other) const
Definition relative-transformation.hh:140
Eigen::ColBlockIndices ColBlockIndices
Definition relative-transformation.hh:107
void impl_compute(LiegroupElementRef result, vectorIn_t argument) const
const JointConstPtr_t & joint1() const
Get joint 1.
Definition relative-transformation.hh:77
static RelativeTransformationPtr_t create(const std::string &name, const DevicePtr_t &robot, const JointConstPtr_t &joint1, const JointConstPtr_t &joint2, const Transform3s &frame1, const Transform3s &frame2)
void impl_jacobian(matrixOut_t jacobian, vectorIn_t arg) const
const JointConstPtr_t & joint2() const
Get joint 2.
Definition relative-transformation.hh:80
RelativeTransformation(const std::string &name, const DevicePtr_t &robot, const JointConstPtr_t &joint1, const JointConstPtr_t &joint2, const Transform3s &frame1, const Transform3s &frame2, const segments_t inConf, const segments_t outConf, const segments_t inVel, const segments_t outVel, std::vector< bool > mask=std::vector< bool >(6, true))
RelativeTransformation(const RelativeTransformation &other)
Definition relative-transformation.hh:117
#define HPP_CONSTRAINTS_DLLAPI
Definition config.hh:88
shared_ptr< RelativeTransformation > RelativeTransformationPtr_t
Definition fwd.hh:197
pinocchio::Transform3s Transform3s
Definition fwd.hh:64
pinocchio::DevicePtr_t DevicePtr_t
Definition fwd.hh:109
shared_ptr< RelativeTransformation > RelativeTransformationPtr_t
Definition fwd.hh:168
pinocchio::DeviceConstPtr_t DeviceConstPtr_t
Definition fwd.hh:110
pinocchio::size_type size_type
Definition fwd.hh:47
pinocchio::vectorIn_t vectorIn_t
Definition fwd.hh:60
pinocchio::matrix_t matrix_t
Definition fwd.hh:56
Eigen::Ref< matrix_t > matrixOut_t
Definition fwd.hh:58
std::vector< segment_t > segments_t
Definition fwd.hh:84
pinocchio::vector_t vector_t
Definition fwd.hh:59
pinocchio::LiegroupElementRef LiegroupElementRef
Definition fwd.hh:66
GenericTransformation< RelativeBit|PositionBit|OrientationBit > RelativeTransformation
Definition fwd.hh:151
pinocchio::JointConstPtr_t JointConstPtr_t
Definition fwd.hh:50
Definition active-set-differentiable-function.hh:36
Definition matrix-view.hh:49