hpp-corbaserver  4.13.0
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>
41 #include <hpp/corbaserver/fwd.hh>
43 
44 namespace hpp {
45 namespace corbaServer {
46 namespace constraints_idl {
47 template <typename _Base, typename _Storage>
49  : public ServantBase<constraints::DifferentiableFunction, _Storage>,
50  public virtual _Base {
53 
54  public:
56  : _ServantBase(server, s) {}
57 
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) {
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<
87  constraints::DifferentiableFunctionPtr_t>
89 
90 template <typename _Base, typename _Storage>
91 class ImplicitServant : public ServantBase<constraints::Implicit, _Storage>,
92  public virtual _Base {
94 
95  public:
96  ImplicitServant(Server* server, const Storage& s) : _ServantBase(server, s) {}
97 
98  virtual ~ImplicitServant() {}
99 
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 
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 
127  return vectorToFloatSeq(get()->rightHandSideAt(s));
128  }
129 };
130 
131 typedef ImplicitServant<POA_hpp::constraints_idl::Implicit,
132  constraints::ImplicitPtr_t>
134 } // namespace constraints_idl
135 } // end of namespace corbaServer.
136 } // end of namespace hpp.
137 
138 #endif // HPP_CONSTRAINTS_IDL_CONSTRAINTS_HH
hpp::corbaServer::constraints_idl::DifferentiableFunction
DifferentiableFunctionServant< POA_hpp::constraints_idl::DifferentiableFunction, constraints::DifferentiableFunctionPtr_t > DifferentiableFunction
Definition: constraints.hh:88
floatSeq
Definition: common-idl.hh:689
servant-base.hh
hpp::corbaServer::c_str
char * c_str(const std::string &in)
Definition: conversions.hh:92
conversions.hh
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::jacobian
floatSeqSeq * jacobian(const floatSeq &arg)
Definition: constraints.hh:65
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::inputDerivativeSize
size_type inputDerivativeSize()
Definition: constraints.hh:72
hpp::corbaServer::Server
Implementation of Hpp module Corba server.
Definition: server.hh:77
hpp::corbaServer::constraints_idl::ImplicitServant::setRightHandSide
void setRightHandSide(const floatSeq &rhs)
Definition: constraints.hh:112
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant
Definition: constraints.hh:48
hpp::corbaServer::constraints_idl::ImplicitServant::~ImplicitServant
virtual ~ImplicitServant()
Definition: constraints.hh:98
hpp::corbaServer::constraints_idl::ImplicitServant::rhsSize
hpp::size_type rhsSize()
Definition: constraints.hh:120
hpp::constraints_idl::DifferentiableFunction
Definition: constraints.idl:19
DifferentiableFunction_ptr
_objref_DifferentiableFunction * DifferentiableFunction_ptr
Definition: constraints-idl.hh:71
hpp::corbaServer::floatSeqToVector
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
floatSeqSeq
Definition: common-idl.hh:803
hpp::corbaServer::value_type
pinocchio::value_type value_type
Definition: fwd.hh:109
hpp::corbaServer::AbstractServantBase< constraints::Implicit >::server_
Server * server_
Definition: servant-base.hh:116
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::outputSize
size_type outputSize()
Definition: constraints.hh:73
hpp::corbaServer::constraints_idl::ImplicitServant::getRightHandSide
floatSeq * getRightHandSide()
Definition: constraints.hh:116
hpp::constraints_idl::Implicit
Definition: constraints.idl:40
hpp::corbaServer::constraints_idl::ImplicitServant::setRightHandSideFromConfig
void setRightHandSideFromConfig(const floatSeq &config)
Definition: constraints.hh:107
fwd.hh
constraints-idl.hh
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::~DifferentiableFunctionServant
virtual ~DifferentiableFunctionServant()
Definition: constraints.hh:58
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::value
floatSeq * value(const floatSeq &arg)
Definition: constraints.hh:60
hpp
Implement CORBA interface `‘Obstacle’'.
Definition: basic-server.hh:35
hpp::corbaServer::constraints_idl::ImplicitServant::rightHandSideAt
floatSeq * rightHandSideAt(value_type s)
Definition: constraints.hh:126
hpp::size_type
long long size_type
Definition: common.idl:19
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::inputSize
size_type inputSize()
Definition: constraints.hh:71
hpp::corbaServer::matrixToFloatSeqSeq
floatSeqSeq * matrixToFloatSeqSeq(core::matrixIn_t input)
Returns a sequence of the rows of the input matrix.
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::name
char * name()
Definition: constraints.hh:75
hpp::corbaServer::constraints_idl::ImplicitServant
Definition: constraints.hh:91
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::outputDerivativeSize
size_type outputDerivativeSize()
Definition: constraints.hh:74
hpp::corbaServer::constraints_idl::ImplicitServant::ImplicitServant
ImplicitServant(Server *server, const Storage &s)
Definition: constraints.hh:96
hpp::corbaServer::matrix_t
pinocchio::matrix_t matrix_t
Definition: fwd.hh:110
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::DifferentiableFunctionServant
DifferentiableFunctionServant(Server *server, const Storage &s)
Definition: constraints.hh:55
hpp::corbaServer::size_type
pinocchio::size_type size_type
Definition: fwd.hh:115
hpp::corbaServer::constraints_idl::Implicit
ImplicitServant< POA_hpp::constraints_idl::Implicit, constraints::ImplicitPtr_t > Implicit
Definition: constraints.hh:133
hpp::corbaServer::ServantBase< constraints::DifferentiableFunction, _Storage >::get
virtual TShPtr_t get() const
Definition: servant-base.hh:130
hpp::corbaServer::ServantBase< constraints::DifferentiableFunction, _Storage >::Storage
_Storage Storage
Definition: servant-base.hh:122
hpp::corbaServer::vectorToFloatSeq
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
hpp::corbaServer::constraints_idl::ImplicitServant::constantRightHandSide
CORBA::Boolean constantRightHandSide()
Definition: constraints.hh:122
hpp::corbaServer::ServantBase
Definition: servant-base.hh:120
hpp::corbaServer::constraints_idl::DifferentiableFunctionServant::str
char * str()
Definition: constraints.hh:77
DifferentiableFunction_var
_CORBA_ObjRef_Var< _objref_DifferentiableFunction, DifferentiableFunction_Helper > DifferentiableFunction_var
Definition: constraints-idl.hh:88