hpp-core: include/hpp/core/constraint.hh Source File

hpp-core 9.0.2 Implement basic classes for canonical path planning for kinematic chains.

Loading...
Searching...
No Matches
constraint.hh
Go to the documentation of this file.
1//
2// Copyright (c) 2014 CNRS
3// Authors: Florent Lamiraux
4//
5
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// 1. Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12//
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28// DAMAGE.
29
30#ifndef HPP_CORE_CONSTRAINT_HH
31#define HPP_CORE_CONSTRAINT_HH
32
33#include <hpp/core/config.hh>
34#include <hpp/core/fwd.hh>
35#include <hpp/util/serialization-fwd.hh>
36#include <ostream>
37
38namespace hpp {
39namespace core {
42
49 class HPP_CORE_DLLAPI Constraint {
50 public:
54 bool apply(ConfigurationOut_t configuration);
56 const std::string& name() const { return name_; }
57
61 virtual bool isSatisfied(ConfigurationIn_t config) = 0;
62
68 virtual bool isSatisfied(ConfigurationIn_t config, vector_t& error) = 0;
69
71 virtual ConstraintPtr_t copy() const = 0;
72
73 virtual ~Constraint() {};
74
75 protected:
77 virtual bool impl_compute(ConfigurationOut_t configuration) = 0;
79 Constraint(const std::string& name) : name_(name), weak_() {}
80 Constraint(const Constraint& constraint) : name_(constraint.name_), weak_() {}
82 void init(const ConstraintPtr_t& self) { weak_ = self; }
83
84 private:
85 virtual std::ostream& print(std::ostream& os) const = 0;
86
87 virtual void addLockedJoint(const LockedJointPtr_t&) {}
88
89 std::string name_;
90 ConstraintWkPtr_t weak_;
91 friend class ConstraintSet;
92 friend class constraints::LockedJoint;
93 friend class ConfigProjector;
94 friend std::ostream& operator<<(std::ostream& os, const Constraint&);
95
96 Constraint() {}
97 HPP_SERIALIZABLE();
98}; // class Constraint
99 inline std::ostream& operator<<(std::ostream& os,
100 const Constraint& constraint) {
101 return constraint.print(os);
102}
104} // namespace core
105} // namespace hpp
106#endif // HPP_CORE_CONSTRAINT_HH
hpp::constraints::LockedJoint
hpp::core::ConfigProjector
Definition config-projector.hh:66
hpp::core::ConstraintSet
Definition constraint-set.hh:47
hpp::core::Constraint
Definition constraint.hh:49
hpp::core::Constraint::isSatisfied
virtual bool isSatisfied(ConfigurationIn_t config, vector_t &error)=0
hpp::core::Constraint::impl_compute
virtual bool impl_compute(ConfigurationOut_t configuration)=0
User defined implementation of the constraint.
hpp::core::Constraint::Constraint
Constraint(const Constraint &constraint)
Definition constraint.hh:80
hpp::core::Constraint::apply
bool apply(ConfigurationOut_t configuration)
hpp::core::Constraint::init
void init(const ConstraintPtr_t &self)
Store shared pointer to itself.
Definition constraint.hh:82
hpp::core::Constraint::isSatisfied
virtual bool isSatisfied(ConfigurationIn_t config)=0
hpp::core::Constraint::Constraint
Constraint(const std::string &name)
Constructor.
Definition constraint.hh:79
hpp::core::Constraint::~Constraint
virtual ~Constraint()
Definition constraint.hh:73
hpp::core::Constraint::copy
virtual ConstraintPtr_t copy() const =0
return shared pointer to copy
hpp::core::Constraint::name
const std::string & name() const
Get name of constraint.
Definition constraint.hh:56
operator<<
hpp::constraints::ComparisonTypes_t operator<<(hpp::constraints::internal::ReplicateCompType c1, hpp::constraints::internal::ReplicateCompType c2)
config.hh
HPP_CORE_DLLAPI
#define HPP_CORE_DLLAPI
Definition config.hh:88
fwd.hh
hpp::core::operator<<
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition constraint.hh:99
hpp
hpp::core::ConstraintPtr_t
shared_ptr< Constraint > ConstraintPtr_t
Definition fwd.hh:129
hpp::core::ConfigurationOut_t
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition fwd.hh:109
hpp::core::vector_t
pinocchio::vector_t vector_t
Definition fwd.hh:220
hpp::core::ConfigurationIn_t
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition fwd.hh:108
hpp::core::LockedJointPtr_t
constraints::LockedJointPtr_t LockedJointPtr_t
Definition fwd.hh:159
serialization-fwd.hh
HPP_SERIALIZABLE
#define HPP_SERIALIZABLE()