hpp-corbaserver: include/hpp/corbaserver/constraints_idl/constraints.hh Source File

hpp-corbaserver 9.0.2 Corba server for Humanoid Path Planner applications

constraints.hh
Go to the documentation of this file.
1 // Copyright (C) 2019 by Joseph Mirabel, LAAS-CNRS.
2 //
3
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 // DAMAGE.
27 //
28 // This software is provided "as is" without warranty of any kind,
29 // either expressed or implied, including but not limited to the
30 // implied warranties of fitness for a particular purpose.
31 //
32 // See the COPYING file for more information.
33
34 #ifndef HPP_CONSTRAINTS_IDL_CONSTRAINTS_HH
35 #define HPP_CONSTRAINTS_IDL_CONSTRAINTS_HH
36
37 #include <hpp/constraints/differentiable-function.hh>
38 #include <hpp/constraints/implicit.hh>
39 #include <hpp/constraints_idl/constraints-idl.hh>
40 #include <hpp/corbaserver/conversions.hh>
41 #include <hpp/corbaserver/fwd.hh>
42 #include <hpp/corbaserver/servant-base.hh>
43
44 namespace hpp {
45 namespace corbaServer {
46 namespace constraints_idl {
47 template <typename _Base, typename _Storage>
48 class DifferentiableFunctionServant
49 : public ServantBase<constraints::DifferentiableFunction, _Storage>,
50 public virtual _Base {
51 SERVANT_BASE_TYPEDEFS(hpp::constraints_idl::DifferentiableFunction,
52 constraints::DifferentiableFunction);
53
54 public:
55 DifferentiableFunctionServant(Server* server, const Storage& s)
56 : _ServantBase(server, s) {}
57
58 virtual ~DifferentiableFunctionServant() {}
59
60 floatSeq* value(const floatSeq& arg) {
61 return vectorToFloatSeq(
62 (*get())(floatSeqToVector(arg, get()->inputSize())).vector());
63 }
64
65 floatSeqSeq* jacobian(const floatSeq& arg) {
66 matrix_t J(get()->outputDerivativeSize(), get()->inputDerivativeSize());
67 get()->jacobian(J, floatSeqToVector(arg));
68 return matrixToFloatSeqSeq(J);
69 }
70
71 size_type inputSize() { return get()->inputSize(); }
72 size_type inputDerivativeSize() { return get()->inputDerivativeSize(); }
73 size_type outputSize() { return get()->outputSize(); }
74 size_type outputDerivativeSize() { return get()->outputDerivativeSize(); }
75 char* name() { return c_str(get()->name()); }
76
77 char* str() {
78 std::ostringstream oss;
79 oss << *get();
80 std::string res = oss.str();
81 return CORBA::string_dup(res.c_str());
82 }
83 };
84
85 typedef DifferentiableFunctionServant<
86 POA_hpp::constraints_idl::DifferentiableFunction,
87 constraints::DifferentiableFunctionPtr_t>
88 DifferentiableFunction;
89
90 template <typename _Base, typename _Storage>
91 class ImplicitServant : public ServantBase<constraints::Implicit, _Storage>,
92 public virtual _Base {
93 SERVANT_BASE_TYPEDEFS(hpp::constraints_idl::Implicit, constraints::Implicit);
94
95 public:
96 ImplicitServant(Server* server, const Storage& s) : _ServantBase(server, s) {}
97
98 virtual ~ImplicitServant() {}
99
100 hpp::constraints_idl::DifferentiableFunction_ptr function() {
101 hpp::constraints_idl::DifferentiableFunction_var f =
102 makeServantDownCast<DifferentiableFunction>(server_,
103 get()->functionPtr());
104 return f._retn();
105 }
106
107 void setRightHandSideFromConfig(const floatSeq& config) {
108 get()->rightHandSideFromConfig(
109 floatSeqToVector(config, get()->function().inputSize()));
110 }
111
112 void setRightHandSide(const floatSeq& rhs) {
113 get()->rightHandSide(floatSeqToVector(rhs, get()->rhsSize()));
114 }
115
116 floatSeq* getRightHandSide() {
117 return vectorToFloatSeq(get()->rightHandSide());
118 }
119
120 hpp::size_type rhsSize() { return get()->rhsSize(); }
121
122 CORBA::Boolean constantRightHandSide() {
123 return get()->constantRightHandSide();
124 }
125
126 floatSeq* rightHandSideAt(value_type s) {
127 return vectorToFloatSeq(get()->rightHandSideAt(s));
128 }
129 };
130
131 typedef ImplicitServant<POA_hpp::constraints_idl::Implicit,
132 constraints::ImplicitPtr_t>
133 Implicit;
134 } // namespace constraints_idl
135 } // end of namespace corbaServer.
136 } // end of namespace hpp.
137
138 #endif // HPP_CONSTRAINTS_IDL_CONSTRAINTS_HH
floatSeqSeq
Definition: common-idl.hh:803
floatSeq
Definition: common-idl.hh:689
hpp::constraints::DifferentiableFunction
hpp::constraints::Implicit
hpp::corbaServer::AbstractServantBase::server_
Server * server_
Definition: servant-base.hh:118
hpp::corbaServer::ServantBase
Definition: servant-base.hh:122
hpp::corbaServer::ServantBase< constraints::DifferentiableFunction, _Storage >::Storage
_Storage Storage
Definition: servant-base.hh:124
hpp::corbaServer::ServantBase< constraints::DifferentiableFunction, _Storage >::get
virtual TShPtr_t get() const
Definition: servant-base.hh:132
hpp::corbaServer::Server
Implementation of Hpp module Corba server.
Definition: server.hh:78
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant
Definition: constraints.hh:50
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::DifferentiableFunctionServant
DifferentiableFunctionServant(Server *server, const Storage &s)
Definition: constraints.hh:55
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::str
char * str()
Definition: constraints.hh:77
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::name
char * name()
Definition: constraints.hh:75
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::inputSize
size_type inputSize()
Definition: constraints.hh:71
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::outputDerivativeSize
size_type outputDerivativeSize()
Definition: constraints.hh:74
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::inputDerivativeSize
size_type inputDerivativeSize()
Definition: constraints.hh:72
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::value
floatSeq * value(const floatSeq &arg)
Definition: constraints.hh:60
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::~DifferentiableFunctionServant
virtual ~DifferentiableFunctionServant()
Definition: constraints.hh:58
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::jacobian
floatSeqSeq * jacobian(const floatSeq &arg)
Definition: constraints.hh:65
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::outputSize
size_type outputSize()
Definition: constraints.hh:73
hpp::corbaServer::constraints_idl::ImplicitServant
Definition: constraints.hh:92
hpp::corbaServer::constraints_idl::ImplicitServant::setRightHandSideFromConfig
void setRightHandSideFromConfig(const floatSeq &config)
Definition: constraints.hh:107
hpp::corbaServer::constraints_idl::ImplicitServant::constantRightHandSide
CORBA::Boolean constantRightHandSide()
Definition: constraints.hh:122
hpp::corbaServer::constraints_idl::ImplicitServant::setRightHandSide
void setRightHandSide(const floatSeq &rhs)
Definition: constraints.hh:112
hpp::corbaServer::constraints_idl::ImplicitServant::getRightHandSide
floatSeq * getRightHandSide()
Definition: constraints.hh:116
hpp::corbaServer::constraints_idl::ImplicitServant::rhsSize
hpp::size_type rhsSize()
Definition: constraints.hh:120
hpp::corbaServer::constraints_idl::ImplicitServant::rightHandSideAt
floatSeq * rightHandSideAt(value_type s)
Definition: constraints.hh:126
hpp::corbaServer::constraints_idl::ImplicitServant::ImplicitServant
ImplicitServant(Server *server, const Storage &s)
Definition: constraints.hh:96
hpp::corbaServer::constraints_idl::ImplicitServant::~ImplicitServant
virtual ~ImplicitServant()
Definition: constraints.hh:98
constraints-idl.hh
DifferentiableFunction_ptr
_objref_DifferentiableFunction * DifferentiableFunction_ptr
Definition: constraints-idl.hh:71
DifferentiableFunction_var
_CORBA_ObjRef_Var< _objref_DifferentiableFunction, DifferentiableFunction_Helper > DifferentiableFunction_var
Definition: constraints-idl.hh:88
conversions.hh
differentiable-function.hh
fwd.hh
implicit.hh
hpp::constraints_idl::DifferentiableFunction
Definition: constraints.idl:20
hpp::constraints_idl::Implicit
Definition: constraints.idl:41
hpp::constraints::DifferentiableFunctionPtr_t
shared_ptr< DifferentiableFunction > DifferentiableFunctionPtr_t
hpp::constraints::ImplicitPtr_t
shared_ptr< Implicit > ImplicitPtr_t
hpp::corbaServer::constraints_idl::DifferentiableFunction
DifferentiableFunctionServant< POA_hpp::constraints_idl::DifferentiableFunction, constraints::DifferentiableFunctionPtr_t > DifferentiableFunction
Definition: constraints.hh:88
hpp::corbaServer::constraints_idl::Implicit
ImplicitServant< POA_hpp::constraints_idl::Implicit, constraints::ImplicitPtr_t > Implicit
Definition: constraints.hh:133
hpp::corbaServer::size_type
pinocchio::size_type size_type
Definition: fwd.hh:110
hpp::corbaServer::floatSeqToVector
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
hpp::corbaServer::c_str
char * c_str(const std::string &in)
Definition: conversions.hh:87
hpp::corbaServer::vectorToFloatSeq
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
hpp::corbaServer::value_type
pinocchio::value_type value_type
Definition: fwd.hh:104
hpp::corbaServer::matrix_t
pinocchio::matrix_t matrix_t
Definition: fwd.hh:105
hpp::corbaServer::matrixToFloatSeqSeq
floatSeqSeq * matrixToFloatSeqSeq(core::matrixIn_t input)
Returns a sequence of the rows of the input matrix.
hpp
Implement CORBA interface `‘Obstacle’'.
hpp::size_type
long long size_type
Definition: common.idl:19
servant-base.hh