hpp-corbaserver  4.9.0
Corba server for Humanoid Path Planner applications
paths.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_PATHS_HH
12 # define HPP_CORE_IDL_PATHS_HH
13 # include <vector>
14 # include <stdlib.h>
15 
16 # include "hpp/core/path.hh"
17 # include "hpp/core/path-vector.hh"
18 
19 # include <hpp/corbaserver/fwd.hh>
21 # include "hpp/core_idl/paths-idl.hh"
22 
24 
25 namespace hpp
26 {
27  namespace corbaServer
28  {
29  namespace core_idl
30  {
31  hpp::core_idl::Path_ptr makePathServant (Server* server, const PathPtr_t& path);
32 
33  template <typename _Base, typename _Storage>
34  class PathServant : public ServantBase<core::Path, _Storage>, public virtual _Base
35  {
36  SERVANT_BASE_TYPEDEFS(hpp::core_idl::Path, core::Path);
37 
38  public:
39  PathServant (Server* server, const Storage& s)
40  : _ServantBase (server, s) {}
41 
42  virtual ~PathServant () {}
43 
45  {
46  return get()->outputSize();
47  }
48 
50  {
51  return get()->outputDerivativeSize();
52  }
53 
55  {
56  return get()->length ();
57  }
58 
59  char* str ()
60  {
61  std::ostringstream oss; oss << *get();
62  std::string res = oss.str();
63  return CORBA::string_dup(res.c_str());
64  }
65 
66  floatSeq* value (value_type t, CORBA::Boolean& success)
67  {
68  return vectorToFloatSeq (get()->operator() (t, success));
69  }
70 
71  floatSeq* derivative (value_type t, CORBA::Short order)
72  {
73  vector_t res (get()->outputDerivativeSize());
74  get()->derivative (res, t, order);
75  return vectorToFloatSeq (res);
76  }
77 
78  hpp::core_idl::Path_ptr extract (value_type tmin, value_type tmax)
79  {
80  return makePathServant (server_, get()->extract(core::interval_t(tmin, tmax)));
81  }
82 
83  hpp::core_idl::PathVector_ptr asVector ();
84  };
85 
87 
88  template <typename _Base, typename _Storage>
89  class PathVectorServant : public PathServant<_Base, _Storage>
90  {
92 
93  public:
95 
96  PathVectorServant (Server* server, const Storage& s) : Parent (server, s) {}
97 
99  {
100  return getT()->numberPaths();
101  }
102 
103  hpp::core_idl::Path_ptr pathAtRank (std::size_t rank)
104  {
105  return makePathServant (server_, getT()->pathAtRank(rank));
106  }
107 
108  void appendPath (hpp::core_idl::Path_ptr path)
109  {
110  getT()->appendPath(reference_to_servant_base<core::Path>(server_, path)->get());
111  }
112 
113  void concatenate (hpp::core_idl::PathVector_ptr path)
114  {
115  getT()->concatenate (reference_to_servant<PathVectorServant>(server_, path)->getT());
116  }
117  };
118 
120 
121 
122  template <typename _Base, typename _Storage>
123  hpp::core_idl::PathVector_ptr PathServant<_Base,_Storage>::asVector ()
124  {
125  PathPtr_t p = get();
126  PathVectorPtr_t pv =
127  core::PathVector::create (p->outputSize(), p->outputDerivativeSize());
128  pv->appendPath (p);
129 
130  return makeServant<hpp::core_idl::PathVector_ptr>
131  (server_, new PathVector (server_, pv));
132  }
133 
134  } // end of namespace core.
135  } // end of namespace corbaServer.
136 } // end of namespace hpp.
137 
138 #endif // HPP_CORE_IDL_PATHS_HH
Definition: servant-base.hh:100
boost::shared_ptr< Path > PathPtr_t
std::size_t numberPaths()
Definition: paths.hh:98
hpp::core_idl::Path_ptr pathAtRank(std::size_t rank)
Definition: paths.hh:103
PathVectorServant< POA_hpp::core_idl::PathVector, core::PathVectorPtr_t > PathVector
Definition: paths.hh:119
hpp::core_idl::PathVector_ptr asVector()
Definition: paths.hh:123
Implement CORBA interface ``Obstacle&#39;&#39;.
size_type outputDerivativeSize()
Definition: paths.hh:49
PathVectorServant(Server *server, const Storage &s)
Definition: paths.hh:96
#define SERVANT_BASE_TYPEDEFS(idlObj, hppObj)
Definition: servant-base.hh:54
std::pair< value_type, value_type > interval_t
unsigned long long size_t
Definition: paths.idl:18
PathServant< POA_hpp::core_idl::Path, core::PathPtr_t > Path
Definition: paths.hh:86
pinocchio::value_type value_type
Definition: fwd.hh:80
Server * server_
Definition: servant-base.hh:97
pinocchio::vector_t vector_t
Definition: fwd.hh:83
floatSeq * value(value_type t, CORBA::Boolean &success)
Definition: paths.hh:66
Storage s
Definition: servant-base.hh:171
PathServant(Server *server, const Storage &s)
Definition: paths.hh:39
void concatenate(hpp::core_idl::PathVector_ptr path)
Definition: paths.hh:113
size_type outputSize()
Definition: paths.hh:44
core::PathVectorPtr_t PathVectorPtr_t
Definition: fwd.hh:71
Implementation of Hpp module Corba server.
Definition: server.hh:54
floatSeq * derivative(value_type t, CORBA::Short order)
Definition: paths.hh:71
PathServant< Base, Storage > Parent
Definition: paths.hh:94
hpp::core_idl::Path_ptr makePathServant(Server *server, const PathPtr_t &path)
virtual ~PathServant()
Definition: paths.hh:42
Definition: paths.idl:21
Transform3f t
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
_Storage Storage
Definition: servant-base.hh:103
StorageElementShPtr_t getT() const
Definition: servant-base.hh:121
void appendPath(hpp::core_idl::Path_ptr path)
Definition: paths.hh:108
hpp::core_idl::Path_ptr extract(value_type tmin, value_type tmax)
Definition: paths.hh:78
sequence< double > floatSeq
Robot configuration is defined by a sequence of dof value.
Definition: common.idl:32
char * str()
Definition: paths.hh:59
core::PathPtr_t PathPtr_t
Definition: fwd.hh:68
static PathVectorPtr_t create(size_type outputSize, size_type outputDerivativeSize)
value_type length()
Definition: paths.hh:54
Definition: paths.idl:64
pinocchio::size_type size_type
Definition: fwd.hh:86