hpp-corbaserver  4.11.0
Corba server for Humanoid Path Planner applications
conversions.hh
Go to the documentation of this file.
1 // Copyright (c) 2016, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-corbaserver.
5 // hpp-corbaserver is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-corbaserver is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-corbaserver. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_CORBASERVER_CONVERSIONS_HH
18 #define HPP_CORBASERVER_CONVERSIONS_HH
19 
20 # include <hpp/util/exception-factory.hh>
21 
22 # include <hpp/corbaserver/fwd.hh>
23 # include <hpp/core/parameter.hh>
24 # include <hpp/common-idl.hh>
25 
26 namespace hpp {
27  namespace corbaServer {
28  typedef Eigen::Matrix<CORBA::Long, Eigen::Dynamic, Eigen::Dynamic> IntMatrix_t;
29 
30  void toTransform3f (const Transform_ in, Transform3f& out);
31 
33 
34  std::vector<Transform3f> toTransform3f (const TransformSeq in);
35 
36  void toHppTransform (const Transform3f& in, Transform_ out);
37 
39 
40  floatSeq* vectorToFloatSeq (core::vectorIn_t input);
41 
42  void vectorToFloatSeq (core::vectorIn_t input, floatSeq& output);
43 
45  {
46  if (!input) return NULL;
47  return vectorToFloatSeq (*input);
48  }
49 
51  // Return [ [input.row(0)], [input.row(1)], ...]
52  floatSeqSeq* matrixToFloatSeqSeq (core::matrixIn_t input);
53 
54  intSeqSeq* matrixToIntSeqSeq (Eigen::Ref<const IntMatrix_t > input);
55 
56  vector3_t floatSeqToVector3 (const floatSeq& dofArray);
57 
58  vector_t floatSeqToVector (const floatSeq& dofArray, const size_type expectedSize = -1);
59 
60  Configuration_t floatSeqToConfig (const DevicePtr_t& robot, const floatSeq& dofArray, bool throwIfNotNormalized);
61 
62  ConfigurationPtr_t floatSeqToConfigPtr (const DevicePtr_t& robot, const floatSeq& dofArray, bool throwIfNotNormalized);
63 
64  core::matrix_t floatSeqSeqToMatrix (const floatSeqSeq& input, const size_type expectedRows = -1, const size_type expectedCols = -1);
65 
66  IntMatrix_t intSeqSeqToMatrix (const intSeqSeq& input, const size_type expectedRows = -1, const size_type expectedCols = -1);
67 
68  std::vector<bool> boolSeqToVector (const hpp::boolSeq& mask,
69  unsigned int length = 3);
70 
71  inline char* c_str (const std::string& in)
72  {
73  char* out = new char[in.length()+1];
74  strcpy (out, in.c_str());
75  return out;
76  }
77 
78  template <typename InputIt> inline Names_t* toNames_t (InputIt begin, InputIt end)
79  {
80  std::size_t len = std::distance (begin, end);
81  char** nameList = Names_t::allocbuf((CORBA::ULong) len);
82  Names_t *ret = new Names_t ((CORBA::ULong) len, (CORBA::ULong) len, nameList);
83 
84  std::size_t i = 0;
85  while (begin != end) {
86  nameList[i] = c_str (*begin);
87  ++begin;
88  ++i;
89  }
90  return ret;
91  }
92 
93  template <typename Iterable> inline Names_t* toNames_t (const Iterable& iterable)
94  {
95  return toNames_t(iterable.begin(), iterable.end());
96  }
97 
98  template <typename InputIt> inline intSeq* toIntSeq (InputIt begin, InputIt end)
99  {
100  std::size_t len = std::distance (begin, end);
101  intSeq* indexes = new intSeq ();
102  indexes->length ((CORBA::ULong) len);
103 
104  std::size_t i = 0;
105  while (begin != end) {
106  (*indexes)[i] = *begin;
107  ++begin;
108  ++i;
109  }
110  return indexes;
111  }
112 
113  template <typename InputIt> inline boolSeq* toBoolSeq (InputIt begin, InputIt end)
114  {
115  std::size_t len = std::distance (begin, end);
116  boolSeq* indexes = new boolSeq ();
117  indexes->length ((CORBA::ULong) len);
118 
119  std::size_t i = 0;
120  while (begin != end) {
121  (*indexes)[(CORBA::ULong)i] = *begin;
122  ++begin;
123  ++i;
124  }
125  return indexes;
126  }
127 
128  template <typename OutputType> inline OutputType toStrings (const Names_t& names)
129  {
130  OutputType ret;
131  for (CORBA::ULong i = 0; i < names.length(); ++i)
132  ret.push_back (std::string(names[i]));
133  return ret;
134  }
135 
138 
141 
142  core::Parameter toParameter (const CORBA::Any& any);
143 
144  CORBA::Any toCorbaAny (const core::Parameter& parameter);
145 
146  inline CORBA::Any* toCorbaAnyPtr (const core::Parameter& parameter)
147  {
148  CORBA::Any* ap = new CORBA::Any;
149  *ap = toCorbaAny(parameter);
150  return ap;
151  }
152 
153  } // namespace corbaServer
154 } // namespace hpp
155 
156 #endif // HPP_CORBASERVER_CONVERSIONS_HH
CORBA::Any * toCorbaAnyPtr(const core::Parameter &parameter)
Definition: conversions.hh:146
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:51
boolSeq * toBoolSeq(InputIt begin, InputIt end)
Definition: conversions.hh:113
Definition: common-idl.hh:851
core::matrix_t floatSeqSeqToMatrix(const floatSeqSeq &input, const size_type expectedRows=-1, const size_type expectedCols=-1)
ConfigurationPtr_t floatSeqToConfigPtr(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
Definition: common-idl.hh:347
Implement CORBA interface ``Obstacle&#39;&#39;.
Definition: basic-server.hh:27
std::vector< bool > boolSeqToVector(const hpp::boolSeq &mask, unsigned int length=3)
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
char * c_str(const std::string &in)
Definition: conversions.hh:71
sequence< string > Names_t
Sequence of names.
Definition: common.idl:23
sequence< long > intSeq
Definition: common.idl:30
constraints::ComparisonTypes_t convertComparison(ComparisonTypes_t comp)
Convert CORBA comparison types to C++ comparison type.
pinocchio::vector_t vector_t
Definition: fwd.hh:89
Definition: common-idl.hh:78
Eigen::Matrix< CORBA::Long, Eigen::Dynamic, Eigen::Dynamic > IntMatrix_t
Definition: conversions.hh:28
Definition: common-idl.hh:689
core::ConfigurationPtr_t ConfigurationPtr_t
Definition: fwd.hh:44
Definition: common-idl.hh:233
sequence< boolean > boolSeq
Definition: common.idl:29
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:43
void toHppTransform(const Transform3f &in, Transform_ out)
Names_t * toNames_t(InputIt begin, InputIt end)
Definition: conversions.hh:78
intSeqSeq * matrixToIntSeqSeq(Eigen::Ref< const IntMatrix_t > input)
OutputType toStrings(const Names_t &names)
Definition: conversions.hh:128
Definition: common-idl.hh:1024
core::Parameter toParameter(const CORBA::Any &any)
Definition: common-idl.hh:461
IntMatrix_t intSeqSeqToMatrix(const intSeqSeq &input, const size_type expectedRows=-1, const size_type expectedCols=-1)
intSeq * toIntSeq(InputIt begin, InputIt end)
Definition: conversions.hh:98
double Transform_[7]
Element of SE(3) represented by a vector and a unit quaternion.
Definition: common.idl:37
pinocchio::matrix_t matrix_t
Definition: fwd.hh:87
pinocchio::vector3_t vector3_t
Definition: fwd.hh:90
vector3_t floatSeqToVector3(const floatSeq &dofArray)
floatSeqSeq * matrixToFloatSeqSeq(core::matrixIn_t input)
Returns a sequence of the rows of the input matrix.
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
_CORBA_MODULE hpp _CORBA_MODULE_BEG _CORBA_MODULE core_idl _CORBA_MODULE_BEG typedef ::CORBA::ULongLong size_t
Definition: paths-idl.hh:75
Definition: common-idl.hh:575
sequence< ComparisonType > ComparisonTypes_t
Definition: common.idl:49
Configuration_t floatSeqToConfig(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
void toTransform3f(const Transform_ in, Transform3f &out)
pinocchio::Transform3f Transform3f
Definition: fwd.hh:80
::CORBA::Double Transform__slice
Definition: common-idl.hh:802
pinocchio::size_type size_type
Definition: fwd.hh:92
CORBA::Any toCorbaAny(const core::Parameter &parameter)