hpp-corbaserver  4.9.0
Corba server for Humanoid Path Planner applications
distances.hh
Go to the documentation of this file.
1 // Copyright (C) 2019 by Joseph Mirabel, LAAS-CNRS.
2 //
3 // This file is part of the hpp-corbaserver.
4 //
5 // This software is provided "as is" without warranty of any kind,
6 // either expressed or implied, including but not limited to the
7 // implied warranties of fitness for a particular purpose.
8 //
9 // See the COPYING file for more information.
10 
11 #ifndef HPP_CORE_IDL_DISTANCES_HH
12 # define HPP_CORE_IDL_DISTANCES_HH
13 
14 # include <vector>
15 # include <stdlib.h>
16 
17 # include "hpp/core/distance.hh"
19 
20 # include <hpp/corbaserver/fwd.hh>
22 # include "hpp/core_idl/distances-idl.hh"
23 
25 
26 namespace hpp
27 {
28  namespace corbaServer
29  {
30  namespace core_idl
31  {
32  template <typename D>
33  class DistanceStorage : public AbstractStorage <D, core::Distance>
34  {
35  public:
37  using parent_t::element;
38  using typename parent_t::ptr_t;
39 
41  DistanceStorage (const core::DevicePtr_t& _r, const ptr_t& _d)
42  : parent_t(_d), r(_r) {}
43 
44  template <typename T> DistanceStorage<T> cast () const
45  {
46  return DistanceStorage<T> (r, HPP_DYNAMIC_PTR_CAST(T, element.lock()));
47  }
48  };
49 
50  template <typename _Base, typename _Storage>
51  class DistanceServant : public ServantBase<core::Distance, _Storage>, public virtual _Base
52  {
54  public:
55  DistanceServant (Server* server, const Storage& s)
56  : _ServantBase (server, s) {}
57 
58  virtual ~DistanceServant () {}
59 
60  CORBA::Double value (const floatSeq& q1, const floatSeq& q2)
61  {
62  Configuration_t qq1 (floatSeqToConfig(getS().r, q1, true)),
63  qq2 (floatSeqToConfig(getS().r, q2, true));
64  return (*get()) (qq1,qq2);
65  }
66  };
67 
69 
70  template <typename _Base, typename _Storage>
71  class WeighedDistanceServant : public DistanceServant<_Base, _Storage>
72  {
74  public:
76 
78  : Parent(server, s) {}
79 
81 
83  {
84  return vectorToFloatSeq (getT()->weights());
85  }
86 
87  void setWeights (const floatSeq& weights)
88  {
89  try {
90  return getT()->weights(floatSeqToVector(weights));
91  } catch (const std::exception& e) {
92  throw Error (e.what ());
93  }
94  }
95  };
96 
98  } // end of namespace core.
99  } // end of namespace corbaServer.
100 } // end of namespace hpp.
101 
102 #endif // HPP_CORE_IDL_DISTANCES_HH
Definition: servant-base.hh:100
pinocchio::DevicePtr_t DevicePtr_t
boost::weak_ptr< T > ptr_t
Definition: servant-base.hh:209
CORBA::Double value(const floatSeq &q1, const floatSeq &q2)
Definition: distances.hh:60
Implement CORBA interface ``Obstacle&#39;&#39;.
#define SERVANT_BASE_TYPEDEFS(idlObj, hppObj)
Definition: servant-base.hh:54
boost::weak_ptr< D > ptr_t
Definition: servant-base.hh:209
ptr_t element
Definition: servant-base.hh:211
WeighedDistanceServant(Server *server, const Storage &s)
Definition: distances.hh:77
void setWeights(const floatSeq &weights)
Definition: distances.hh:87
#define HPP_DYNAMIC_PTR_CAST(t, x)
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
Definition: distances.idl:19
Corba exception travelling through the Corba channel.
Definition: common.idl:24
Definition: servant-base.hh:206
DistanceStorage(const core::DevicePtr_t &_r, const ptr_t &_d)
Definition: distances.hh:41
DistanceServant< POA_hpp::core_idl::Distance, DistanceStorage< core::Distance > > Distance
Definition: distances.hh:68
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:43
virtual ~DistanceServant()
Definition: distances.hh:58
To define and solve a path planning problem.
Definition: distances.idl:26
DistanceStorage< T > cast() const
Definition: distances.hh:44
DistanceServant(Server *server, const Storage &s)
Definition: distances.hh:55
Implementation of Hpp module Corba server.
Definition: server.hh:54
DistanceServant< Base, Storage > Parent
Definition: distances.hh:75
floatSeq * getWeights()
Definition: distances.hh:82
~WeighedDistanceServant()
Definition: distances.hh:80
core::DevicePtr_t r
Definition: distances.hh:40
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
_Storage Storage
Definition: servant-base.hh:103
Configuration_t floatSeqToConfig(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
sequence< double > floatSeq
Robot configuration is defined by a sequence of dof value.
Definition: common.idl:32
AbstractStorage< D, core::Distance > parent_t
Definition: distances.hh:36
WeighedDistanceServant< POA_hpp::core_idl::WeighedDistance, DistanceStorage< core::WeighedDistance > > WeighedDistance
Definition: distances.hh:97