hpp-corbaserver  4.9.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/common-idl.hh>
24 
25 namespace hpp {
26  namespace corbaServer {
27  typedef Eigen::Matrix<CORBA::Long, Eigen::Dynamic, Eigen::Dynamic> IntMatrix_t;
28 
29  void toTransform3f (const Transform_ in, Transform3f& out);
30 
32 
33  std::vector<Transform3f> toTransform3f (const TransformSeq in);
34 
35  void toHppTransform (const Transform3f& in, Transform_ out);
36 
37  Transform__slice* toHppTransform (const Transform3f& in);
38 
40 
41  void vectorToFloatSeq (core::vectorIn_t input, floatSeq& output);
42 
44  {
45  if (!input) return NULL;
46  return vectorToFloatSeq (*input);
47  }
48 
50  // Return [ [input.row(0)], [input.row(1)], ...]
52 
53  intSeqSeq* matrixToIntSeqSeq (Eigen::Ref<const IntMatrix_t > input);
54 
55  vector3_t floatSeqToVector3 (const floatSeq& dofArray);
56 
57  vector_t floatSeqToVector (const floatSeq& dofArray, const size_type expectedSize = -1);
58 
59  Configuration_t floatSeqToConfig (const DevicePtr_t& robot, const floatSeq& dofArray, bool throwIfNotNormalized);
60 
61  ConfigurationPtr_t floatSeqToConfigPtr (const DevicePtr_t& robot, const floatSeq& dofArray, bool throwIfNotNormalized);
62 
63  core::matrix_t floatSeqSeqToMatrix (const floatSeqSeq& input, const size_type expectedRows = -1, const size_type expectedCols = -1);
64 
65  std::vector<bool> boolSeqToVector (const hpp::boolSeq& mask,
66  unsigned int length = 3);
67 
68  inline char* c_str (const std::string& in)
69  {
70  char* out = new char[in.length()+1];
71  strcpy (out, in.c_str());
72  return out;
73  }
74 
75  template <typename InputIt> inline Names_t* toNames_t (InputIt begin, InputIt end)
76  {
77  std::size_t len = std::distance (begin, end);
78  char** nameList = Names_t::allocbuf((CORBA::ULong) len);
79  Names_t *ret = new Names_t ((CORBA::ULong) len, (CORBA::ULong) len, nameList);
80 
81  std::size_t i = 0;
82  while (begin != end) {
83  nameList[i] = c_str (*begin);
84  ++begin;
85  ++i;
86  }
87  return ret;
88  }
89 
90  template <typename Iterable> inline Names_t* toNames_t (const Iterable& iterable)
91  {
92  return toNames_t(iterable.begin(), iterable.end());
93  }
94 
95  template <typename InputIt> inline intSeq* toIntSeq (InputIt begin, InputIt end)
96  {
97  std::size_t len = std::distance (begin, end);
98  intSeq* indexes = new intSeq ();
99  indexes->length ((CORBA::ULong) len);
100 
101  std::size_t i = 0;
102  while (begin != end) {
103  (*indexes)[i] = *begin;
104  ++begin;
105  ++i;
106  }
107  return indexes;
108  }
109 
110  template <typename InputIt> inline boolSeq* toBoolSeq (InputIt begin, InputIt end)
111  {
112  std::size_t len = std::distance (begin, end);
113  boolSeq* indexes = new boolSeq ();
114  indexes->length ((CORBA::ULong) len);
115 
116  std::size_t i = 0;
117  while (begin != end) {
118  (*indexes)[(CORBA::ULong)i] = *begin;
119  ++begin;
120  ++i;
121  }
122  return indexes;
123  }
124 
125  template <typename OutputType> inline OutputType toStrings (const Names_t& names)
126  {
127  OutputType ret;
128  for (CORBA::ULong i = 0; i < names.length(); ++i)
129  ret.push_back (std::string(names[i]));
130  return ret;
131  }
132  } // namespace corbaServer
133 } // namespace hpp
134 
135 #endif // HPP_CORBASERVER_CONVERSIONS_HH
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:51
boolSeq * toBoolSeq(InputIt begin, InputIt end)
Definition: conversions.hh:110
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)
Implement CORBA interface ``Obstacle&#39;&#39;.
std::vector< bool > boolSeqToVector(const hpp::boolSeq &mask, unsigned int length=3)
unsigned long long size_t
Definition: paths.idl:18
sequence< floatSeq > floatSeqSeq
Definition: common.idl:33
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
char * c_str(const std::string &in)
Definition: conversions.hh:68
sequence< string > Names_t
Sequence of names.
Definition: common.idl:22
sequence< long > intSeq
Definition: common.idl:29
pinocchio::vector_t vector_t
Definition: fwd.hh:83
Eigen::Matrix< CORBA::Long, Eigen::Dynamic, Eigen::Dynamic > IntMatrix_t
Definition: conversions.hh:27
core::ConfigurationPtr_t ConfigurationPtr_t
Definition: fwd.hh:44
pinocchio::vectorIn_t vectorIn_t
constraints::matrixIn_t matrixIn_t
sequence< boolean > boolSeq
Definition: common.idl:28
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:43
pinocchio::matrix_t matrix_t
void toHppTransform(const Transform3f &in, Transform_ out)
Names_t * toNames_t(InputIt begin, InputIt end)
Definition: conversions.hh:75
intSeqSeq * matrixToIntSeqSeq(Eigen::Ref< const IntMatrix_t > input)
OutputType toStrings(const Names_t &names)
Definition: conversions.hh:125
sequence< Transform_ > TransformSeq
Definition: common.idl:37
intSeq * toIntSeq(InputIt begin, InputIt end)
Definition: conversions.hh:95
double Transform_[7]
Element of SE(3) represented by a vector and a unit quaternion.
Definition: common.idl:36
pinocchio::ConfigurationPtr_t ConfigurationPtr_t
pinocchio::vector3_t vector3_t
Definition: fwd.hh:84
vector3_t floatSeqToVector3(const floatSeq &dofArray)
floatSeqSeq * matrixToFloatSeqSeq(core::matrixIn_t input)
Returns a sequence of the rows of the input matrix.
FCL_REAL length[2]
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
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
void toTransform3f(const Transform_ in, Transform3f &out)
pinocchio::Transform3f Transform3f
Definition: fwd.hh:74
sequence< intSeq > intSeqSeq
Definition: common.idl:30
pinocchio::size_type size_type
Definition: fwd.hh:86
FCL_REAL distance(const KDOP< N > &other, Vec3f *P=NULL, Vec3f *Q=NULL) const