GCC Code Coverage Report


Directory: ./
File: include/hpp/constraints/distance-between-bodies.hh
Date: 2025-05-05 12:19:30
Exec Total Coverage
Lines: 0 9 0.0%
Branches: 0 12 0.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2015 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_DISTANCE_BETWEEN_BODIES_HH
32 #define HPP_CONSTRAINTS_DISTANCE_BETWEEN_BODIES_HH
33
34 #include <hpp/constraints/differentiable-function.hh>
35 #include <hpp/constraints/fwd.hh>
36 #include <hpp/pinocchio/collision-object.hh>
37 #include <hpp/pinocchio/liegroup-element.hh>
38 #include <pinocchio/multibody/geometry.hpp>
39
40 namespace hpp {
41 namespace constraints {
42 /// Distance between two sets of objects
43 ///
44 /// This function maps to a configuration of a robot, the distance
45 /// \li either between objects of a joints and objects of another joint,
46 /// \li or objects of a joint with a list of fixed objects.
47 ///
48 /// The above type of distance is determined by the method "create" called.
49 class HPP_CONSTRAINTS_DLLAPI DistanceBetweenBodies
50 : public DifferentiableFunction {
51 public:
52 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
53
54 /// Create instance and return shared pointer
55 ///
56 /// \param name name of the constraint,
57 /// \param robot robot that own the bodies,
58 /// \param joint1 joint that holds the first body,
59 /// \param joint2 joint that holds the second body.
60 static DistanceBetweenBodiesPtr_t create(const std::string& name,
61 const DevicePtr_t& robot,
62 const JointPtr_t& joint1,
63 const JointPtr_t& joint2);
64
65 /// Create instance and return shared pointer
66 ///
67 /// \param name name of the constraint,
68 /// \param robot robot that own the bodies,
69 /// \param joint joint that holds the body,
70 /// \param objects list of fixed objects in the environment.
71 static DistanceBetweenBodiesPtr_t create(
72 const std::string& name, const DevicePtr_t& robot,
73 const JointPtr_t& joint,
74 const std::vector<CollisionObjectPtr_t>& objects);
75
76 virtual ~DistanceBetweenBodies() {}
77
78 protected:
79 /// Protected constructor
80 ///
81 /// \param name name of the constraint,
82 /// \param robot robot that own the bodies,
83 /// \param joint1 joint that holds the first body,
84 /// \param joint2 joint that holds the second body.
85 DistanceBetweenBodies(const std::string& name, const DevicePtr_t& robot,
86 const JointPtr_t& joint1, const JointPtr_t& joint2);
87
88 /// Protected constructor
89 ///
90 /// \param name name of the constraint,
91 /// \param robot robot that own the bodies,
92 /// \param joint joint that holds the body,
93 /// \param objects list of fixed objects in the environment.
94 DistanceBetweenBodies(const std::string& name, const DevicePtr_t& robot,
95 const JointPtr_t& joint,
96 const std::vector<CollisionObjectPtr_t>& objects);
97
98 virtual void impl_compute(LiegroupElementRef result,
99 ConfigurationIn_t argument) const;
100 virtual void impl_jacobian(matrixOut_t jacobian, ConfigurationIn_t arg) const;
101
102 bool isEqual(const DifferentiableFunction& other) const {
103 const DistanceBetweenBodies& castother =
104 dynamic_cast<const DistanceBetweenBodies&>(other);
105 if (!DifferentiableFunction::isEqual(other)) return false;
106
107 if (robot_ != castother.robot_) return false;
108 if (joint1_ != castother.joint1_) return false;
109 if (joint2_ != castother.joint2_) return false;
110 if (data_ != castother.data_) return false;
111
112 return true;
113 }
114
115 private:
116 typedef ::pinocchio::GeometryData GeometryData;
117
118 DevicePtr_t robot_;
119 JointPtr_t joint1_;
120 JointPtr_t joint2_;
121 mutable GeometryData data_;
122 mutable std::size_t minIndex_;
123 mutable Configuration_t latestArgument_;
124 mutable LiegroupElement latestResult_;
125 }; // class DistanceBetweenBodies
126 } // namespace constraints
127 } // namespace hpp
128
129 #endif // HPP_CONSTRAINTS_DISTANCE_BETWEEN_BODIES_HH
130