hpp-constraints: include/hpp/constraints/explicit/relative-transformation.hh Source File

hpp-constraints 9.0.2 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
32#include <hpp/constraints/explicit.hh>
33#include <hpp/constraints/generic-transformation.hh>
34#include <hpp/constraints/matrix-view.hh>
35
36 namespace hpp {
37 namespace constraints {
38 using constraints::RelativeTransformation;
39 using constraints::RelativeTransformationPtr_t;
40
41 namespace explicit_ {
44
57 class HPP_CONSTRAINTS_DLLAPI RelativeTransformation
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:
105 typedef Eigen::BlockIndex BlockIndex;
106 typedef Eigen::RowBlockIndices RowBlockIndices;
107 typedef Eigen::ColBlockIndices ColBlockIndices;
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
117 RelativeTransformation(const RelativeTransformation& other)
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
179 RelativeTransformation() {}
180 HPP_SERIALIZABLE();
181}; // class RelativeTransformation
183
184} // namespace explicit_
185} // namespace constraints
186} // namespace hpp
187
188BOOST_CLASS_EXPORT_KEY(hpp::constraints::explicit_::RelativeTransformation)
189
190#endif // HPP_CONSTRAINTS_EXPLICIT_RELATIVE_TRANSFORMATION_HH
Eigen::MatrixBlocks< false, true >
Eigen::MatrixBlocks::cols
const ColIndices_t & cols() const
Definition matrix-view.hh:679
Eigen::MatrixBlocks::rows
const RowIndices_t & rows() const
Definition matrix-view.hh:675
hpp::constraints::DifferentiableFunction
Definition differentiable-function.hh:63
hpp::constraints::explicit_::RelativeTransformation
Definition relative-transformation.hh:58
hpp::constraints::explicit_::RelativeTransformation::init
void init(const RelativeTransformationWkPtr_t &weak)
Definition relative-transformation.hh:128
hpp::constraints::explicit_::RelativeTransformation::RowBlockIndices
Eigen::RowBlockIndices RowBlockIndices
Definition relative-transformation.hh:106
hpp::constraints::explicit_::RelativeTransformation::dependsOnRelPoseBetween
std::pair< JointConstPtr_t, JointConstPtr_t > dependsOnRelPoseBetween(DeviceConstPtr_t) const
Definition relative-transformation.hh:91
hpp::constraints::explicit_::RelativeTransformation::BlockIndex
Eigen::BlockIndex BlockIndex
Definition relative-transformation.hh:105
hpp::constraints::explicit_::RelativeTransformation::isEqual
bool isEqual(const DifferentiableFunction &other) const
Definition relative-transformation.hh:140
hpp::constraints::explicit_::RelativeTransformation::ColBlockIndices
Eigen::ColBlockIndices ColBlockIndices
Definition relative-transformation.hh:107
hpp::constraints::explicit_::RelativeTransformation::impl_compute
void impl_compute(LiegroupElementRef result, vectorIn_t argument) const
hpp::constraints::explicit_::RelativeTransformation::joint1
const JointConstPtr_t & joint1() const
Get joint 1.
Definition relative-transformation.hh:77
hpp::constraints::explicit_::RelativeTransformation::create
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)
hpp::constraints::explicit_::RelativeTransformation::impl_jacobian
void impl_jacobian(matrixOut_t jacobian, vectorIn_t arg) const
hpp::constraints::explicit_::RelativeTransformation::joint2
const JointConstPtr_t & joint2() const
Get joint 2.
Definition relative-transformation.hh:80
hpp::constraints::explicit_::RelativeTransformation::RelativeTransformation
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))
hpp::constraints::explicit_::RelativeTransformation::RelativeTransformation
RelativeTransformation(const RelativeTransformation &other)
Definition relative-transformation.hh:117
hpp::pinocchio::LiegroupElementBase
HPP_CONSTRAINTS_DLLAPI
#define HPP_CONSTRAINTS_DLLAPI
Definition config.hh:88
explicit.hh
generic-transformation.hh
matrix-view.hh
hpp::constraints::explicit_::RelativeTransformationPtr_t
shared_ptr< RelativeTransformation > RelativeTransformationPtr_t
Definition fwd.hh:201
hpp::constraints::Transform3s
pinocchio::Transform3s Transform3s
Definition fwd.hh:65
hpp::constraints::DevicePtr_t
pinocchio::DevicePtr_t DevicePtr_t
Definition fwd.hh:111
hpp::constraints::RelativeTransformationPtr_t
shared_ptr< RelativeTransformation > RelativeTransformationPtr_t
Definition fwd.hh:170
hpp::constraints::DeviceConstPtr_t
pinocchio::DeviceConstPtr_t DeviceConstPtr_t
Definition fwd.hh:112
hpp::constraints::size_type
pinocchio::size_type size_type
Definition fwd.hh:48
hpp::constraints::vectorIn_t
pinocchio::vectorIn_t vectorIn_t
Definition fwd.hh:61
hpp::constraints::matrix_t
pinocchio::matrix_t matrix_t
Definition fwd.hh:57
hpp::constraints::matrixOut_t
Eigen::Ref< matrix_t > matrixOut_t
Definition fwd.hh:59
hpp::constraints::segments_t
std::vector< segment_t > segments_t
Definition fwd.hh:86
hpp::constraints::vector_t
pinocchio::vector_t vector_t
Definition fwd.hh:60
hpp::constraints::RelativeTransformation
GenericTransformation< RelativeBit|PositionBit|OrientationBit > RelativeTransformation
Definition fwd.hh:153
hpp::constraints::JointConstPtr_t
pinocchio::JointConstPtr_t JointConstPtr_t
Definition fwd.hh:51
hpp
HPP_SERIALIZABLE
#define HPP_SERIALIZABLE()
Eigen::BlockIndex
Definition matrix-view.hh:49