GCC Code Coverage Report


Directory: ./
File: include/hpp/constraints/locked-joint.hh
Date: 2025-05-05 12:19:30
Exec Total Coverage
Lines: 3 3 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // Copyright (c) 2015 - 2018, LAAS-CNRS
2 // Authors: Florent Lamiraux, Joseph Mirabel
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_LOCKED_JOINT_HH
30 #define HPP_CONSTRAINTS_LOCKED_JOINT_HH
31
32 #include <hpp/constraints/explicit.hh>
33 #include <hpp/pinocchio/joint.hh>
34
35 namespace hpp {
36 namespace constraints {
37
38 /// \addtogroup constraints
39 /// \{
40
41 /**
42 Implementation of constraint specific to a locked joint.
43
44 The implicit formulation as defined in class Implicit is given by
45 \f{equation}
46 h (\mathbf{q}) = q_{out} - value
47 \f}
48 where \f$value\f$ is an element of the configuration space of the locked
49 joint passed to method \link
50 LockedJoint::create(const JointPtr_t& joint, const LiegroupElement& value)
51 create\endlink.
52
53 Note that \f$h\f$ takes values in \f$\mathbf{R}^{nv}\f$ where
54 \f$nv\f$ is the dimension of the joint tangent space.
55
56 The explicit formulation is given by
57 \f{equation}
58 q_{out} = value + rhs
59 \f}
60 where coordinates of \f$rhs\f$ corresponding to comparison types different
61 from Equality are set to 0.
62
63 As such, the relation between the explicit formulation and the implicit
64 formulation is the default one.
65 */
66 class HPP_CONSTRAINTS_DLLAPI LockedJoint : public Explicit {
67 public:
68 /// Copy object and return shared pointer to copy
69 virtual ImplicitPtr_t copy() const;
70
71 /// Create locked joint and return shared pointer
72 /// \param joint joint that is locked,
73 /// \param value of the constant joint config,
74 static LockedJointPtr_t create(const JointPtr_t& joint,
75 const LiegroupElement& value);
76
77 /// Create partial locked joint (only some degrees of freedom)
78 /// \param joint joint that is locked,
79 /// \param index first locked degree of freedom in the joint,
80 /// \param value of the constant joint partial config, size of value
81 /// determines the number of degrees of freedom locked.
82 /// \note valid only for translation joints.
83 static LockedJointPtr_t create(const JointPtr_t& joint, const size_type index,
84 vectorIn_t value);
85
86 /// Create locked degrees of freedom of extra config space
87 /// \param dev robot
88 /// \param index index of the first locked extra degree of freedom,
89 /// \param value of the locked degrees of freedom, size of value
90 /// determines the number of degrees of freedom locked.
91 static LockedJointPtr_t create(const DevicePtr_t& dev, const size_type index,
92 vectorIn_t value);
93
94 /// Return shared pointer to copy
95 /// \param other instance to copy.
96 static LockedJointPtr_t createCopy(LockedJointConstPtr_t other);
97
98 /// Get index of locked degree of freedom in robot configuration vector
99 size_type rankInConfiguration() const;
100
101 /// Get index of locked degree of freedom in robot velocity vector.
102 size_type rankInVelocity() const;
103
104 /// Get the configuration size of the joint.
105 size_type configSize() const;
106
107 /// Get number of degrees of freedom of the joint
108 size_type numberDof() const;
109
110 /// Get configuration space of locked joint
111 const LiegroupSpacePtr_t& configSpace() const;
112
113 /// Get the value of the locked joint.
114 vectorIn_t value() const;
115
116 /// Set the value of the locked joint.
117 void value(vectorIn_t value);
118
119 /// Return shared pointer to joint
120 const JointPtr_t& joint() { return joint_; }
121 /// Return the joint name.
122 1 const std::string& jointName() const { return jointName_; }
123 /// Print object in a stream
124 std::ostream& print(std::ostream& os) const;
125
126 /// Get pair of joints whose relative pose is fully constrained
127 ///
128 /// \param robot the device that this constraint is applied to
129 /// \return pair of pointers to the parent joint and the locked joint,
130 /// arranged in order of increasing joint index
131 /// \note absolute pose is considered relative pose with respect to
132 /// "universe". "universe" is returned as a nullpointer
133 /// as the first element of the pair, if applicable.
134 virtual std::pair<JointConstPtr_t, JointConstPtr_t>
135 doesConstrainRelPoseBetween(DeviceConstPtr_t robot) const;
136
137 protected:
138 /// Constructor
139 /// \param joint joint that is locked,
140 /// \param value of the constant joint config,
141 LockedJoint(const JointPtr_t& joint, const LiegroupElement& value);
142 /// Constructor of partial locked joint
143 /// \param joint joint that is locked,
144 /// \param index first locked degree of freedom in the joint,
145 /// \param value of the constant joint partial config, size of value
146 /// determines the number of degrees of freedom locked.
147 /// \note valid only for translation joints.
148 LockedJoint(const JointPtr_t& joint, const size_type index, vectorIn_t value);
149 /// Constructor of locked degrees of freedom of extra config space
150 /// \param robot robot
151 /// \param index index of the first locked extra degree of freedom,
152 /// \param value of the locked degrees of freedom, size of value
153 /// determines the number of degrees of freedom locked.
154 LockedJoint(const DevicePtr_t& robot, const size_type index,
155 vectorIn_t value);
156 /// Copy constructor
157 LockedJoint(const LockedJoint& other);
158 /// Test equality with other instance
159 /// \param other object to copy
160 /// \param swapAndTest whether we should also check other == this
161 virtual bool isEqual(const Implicit& other, bool swapAndTest) const;
162
163 void init(const LockedJointPtr_t& self);
164
165 private:
166 std::string jointName_;
167 JointPtr_t joint_;
168 LiegroupSpacePtr_t configSpace_;
169 /// Weak pointer to itself
170 LockedJointWkPtr_t weak_;
171
172 1 LockedJoint() {}
173 HPP_SERIALIZABLE();
174 }; // class LockedJoint
175
176 /// \}
177 inline std::ostream& operator<<(std::ostream& os, const LockedJoint& lj) {
178 return lj.print(os);
179 }
180 } // namespace constraints
181 } // namespace hpp
182
183 12 BOOST_CLASS_EXPORT_KEY(hpp::constraints::LockedJoint)
184 #endif // HPP_CONSTRAINTS_LOCKED_JOINT_HH
185