GCC Code Coverage Report


Directory: ./
File: include/hpp/constraints/configuration-constraint.hh
Date: 2025-05-05 12:19:30
Exec Total Coverage
Lines: 1 8 12.5%
Branches: 0 10 0.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2015 CNRS
3 // Authors: Joseph Mirabel
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_CONFIGURATION_CONSTRAINT_HH
32 #define HPP_CONSTRAINTS_CONFIGURATION_CONSTRAINT_HH
33
34 #include <Eigen/Core>
35 #include <hpp/constraints/config.hh>
36 #include <hpp/constraints/differentiable-function.hh>
37 #include <hpp/constraints/fwd.hh>
38
39 namespace hpp {
40 namespace constraints {
41
42 /// Square distance between input configuration and reference configuration
43 class HPP_CONSTRAINTS_DLLAPI ConfigurationConstraint
44 : public DifferentiableFunction {
45 public:
46 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
47
48 /// Return a shared pointer to a new instance
49 static ConfigurationConstraintPtr_t create(
50 const std::string& name, const DevicePtr_t& robot, ConfigurationIn_t goal,
51 std::vector<bool> mask = std::vector<bool>(0));
52
53 /// Return a shared pointer to a new instance
54 /// \param weights vector of size robot->numberDof()
55 static ConfigurationConstraintPtr_t create(const std::string& name,
56 const DevicePtr_t& robot,
57 ConfigurationIn_t goal,
58 const vector_t& weights);
59
60 8 virtual ~ConfigurationConstraint() {}
61
62 /// \param weights vector of size robot->numberDof()
63 ConfigurationConstraint(const std::string& name, const DevicePtr_t& robot,
64 ConfigurationIn_t goal, const vector_t& weights);
65
66 const vector_t& weights() const { return weights_; }
67
68 void weights(const vector_t& ws);
69
70 const LiegroupElement& goal() const { return goal_; }
71
72 protected:
73 /// Compute value of error
74 ///
75 /// \param argument configuration of the robot,
76 /// \retval result error vector
77 virtual void impl_compute(LiegroupElementRef result,
78 ConfigurationIn_t argument) const;
79
80 virtual void impl_jacobian(matrixOut_t jacobian, ConfigurationIn_t arg) const;
81
82 std::ostream& print(std::ostream& o) const;
83
84 bool isEqual(const DifferentiableFunction& other) const {
85 const ConfigurationConstraint& castother =
86 dynamic_cast<const ConfigurationConstraint&>(other);
87 if (!DifferentiableFunction::isEqual(other)) return false;
88
89 if (robot_ != castother.robot_) return false;
90 if (goal_.vector() != castother.goal_.vector()) return false;
91 if (weights_ != castother.weights_) return false;
92
93 return true;
94 }
95
96 private:
97 typedef Eigen::Array<bool, Eigen::Dynamic, 1> EigenBoolVector_t;
98 DevicePtr_t robot_;
99 LiegroupElement goal_;
100 vector_t weights_;
101 }; // class ConfigurationConstraint
102 } // namespace constraints
103 } // namespace hpp
104 #endif // HPP_CONSTRAINTS_CONFIGURATION_CONSTRAINT_HH
105