hpp-corbaserver: include/hpp/corbaserver/conversions.hh Source File

hpp-corbaserver 9.0.2 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
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28
29 #ifndef HPP_CORBASERVER_CONVERSIONS_HH
30 #define HPP_CORBASERVER_CONVERSIONS_HH
31
32 #include <hpp/common-idl.hh>
33 #include <hpp/corbaserver/fwd.hh>
34 #include <hpp/core/parameter.hh>
35 #include <hpp/util/exception-factory.hh>
36
37 namespace hpp {
38 namespace corbaServer {
39 typedef Eigen::Matrix<CORBA::Long, Eigen::Dynamic, Eigen::Dynamic> IntMatrix_t;
40
41 void toTransform3s(const Transform_ in, Transform3s& out);
42
43 Transform3s toTransform3s(const Transform_ in);
44
45 std::vector<Transform3s> toTransform3s(const TransformSeq in);
46
47 void toHppTransform(const Transform3s& in, Transform_ out);
48
49 Transform__slice* toHppTransform(const Transform3s& in);
50
51 void toIntSeq(std::vector<int> const& in, intSeq& out);
52
53 floatSeq* vectorToFloatSeq(core::vectorIn_t input);
54
55 void vectorToFloatSeq(core::vectorIn_t input, floatSeq& output);
56
58 // Return [ [input.row(0)], [input.row(1)], ...]
59 floatSeqSeq* matrixToFloatSeqSeq(core::matrixIn_t input);
60
61 intSeqSeq* matrixToIntSeqSeq(Eigen::Ref<const IntMatrix_t> input);
62
63 std::vector<int> intSeqToVector(const intSeq& dofArray);
64
65 vector3_t floatSeqToVector3(const floatSeq& dofArray);
66
67 vector_t floatSeqToVector(const floatSeq& dofArray,
68 const size_type expectedSize = -1);
69
70 Configuration_t floatSeqToConfig(const DevicePtr_t& robot,
71 const floatSeq& dofArray,
72 bool throwIfNotNormalized);
73
74 core::matrix_t floatSeqSeqToMatrix(const floatSeqSeq& input,
75 const size_type expectedRows = -1,
76 const size_type expectedCols = -1);
77
78 IntMatrix_t intSeqSeqToMatrix(const intSeqSeq& input,
79 const size_type expectedRows = -1,
80 const size_type expectedCols = -1);
81
82 std::vector<bool> boolSeqToVector(const hpp::boolSeq& mask,
83 unsigned int length = 3);
84
85 stringSeqSeq* vectorToStringSeqSeq(std::vector<std::vector<std::string>> input);
86
87 inline char* c_str(const std::string& in) {
88 char* out = new char[in.length() + 1];
89 strcpy(out, in.c_str());
90 return out;
91 }
92
93 template <typename InputIt>
94 inline Names_t* toNames_t(InputIt begin, InputIt end) {
95 std::size_t len = std::distance(begin, end);
96 char** nameList = Names_t::allocbuf((CORBA::ULong)len);
97 Names_t* ret =
98 new Names_t((CORBA::ULong)len, (CORBA::ULong)len, nameList, true);
99
100 std::size_t i = 0;
101 while (begin != end) {
102 nameList[i] = c_str(*begin);
103 ++begin;
104 ++i;
105 }
106 return ret;
107 }
108
109 template <typename Iterable>
110 inline Names_t* toNames_t(const Iterable& iterable) {
111 return toNames_t(iterable.begin(), iterable.end());
112 }
113
114 template <typename InputIt>
115 inline intSeq* toIntSeq(InputIt begin, InputIt end) {
116 std::size_t len = std::distance(begin, end);
117 intSeq* indexes = new intSeq();
118 indexes->length((CORBA::ULong)len);
119
120 std::size_t i = 0;
121 while (begin != end) {
122 (*indexes)[(CORBA::ULong)i] = *begin;
123 ++begin;
124 ++i;
125 }
126 return indexes;
127 }
128
129 intSeq* toIntSeq(std::vector<int> const& in);
130
131 template <typename InputIt>
132 inline boolSeq* toBoolSeq(InputIt begin, InputIt end) {
133 std::size_t len = std::distance(begin, end);
134 boolSeq* indexes = new boolSeq();
135 indexes->length((CORBA::ULong)len);
136
137 std::size_t i = 0;
138 while (begin != end) {
139 (*indexes)[(CORBA::ULong)i] = *begin;
140 ++begin;
141 ++i;
142 }
143 return indexes;
144 }
145
146 template <typename OutputType>
147 inline OutputType toStrings(const Names_t& names) {
148 OutputType ret;
149 for (CORBA::ULong i = 0; i < names.length(); ++i)
150 ret.push_back(std::string(names[i]));
151 return ret;
152 }
153
155 constraints::ComparisonTypes_t convertComparison(hpp::ComparisonTypes_t comp);
156
158 hpp::ComparisonTypes_t* convertComparison(constraints::ComparisonTypes_t comp);
159
160 core::Parameter toParameter(const CORBA::Any& any);
161
162 CORBA::Any toCorbaAny(const core::Parameter& parameter);
163
164 inline CORBA::Any* toCorbaAnyPtr(const core::Parameter& parameter) {
165 CORBA::Any* ap = new CORBA::Any;
166 *ap = toCorbaAny(parameter);
167 return ap;
168 }
169
170 } // namespace corbaServer
171 } // namespace hpp
172
173 #endif // HPP_CORBASERVER_CONVERSIONS_HH
Names_t
Definition: common-idl.hh:78
TransformSeq
Definition: common-idl.hh:965
boolSeq
Definition: common-idl.hh:347
floatSeqSeq
Definition: common-idl.hh:803
floatSeq
Definition: common-idl.hh:689
hpp::core::Parameter
intSeqSeq
Definition: common-idl.hh:575
intSeq
Definition: common-idl.hh:461
stringSeqSeq
Definition: common-idl.hh:192
common-idl.hh
Transform__slice
::CORBA::Double Transform__slice
Definition: common-idl.hh:916
exception-factory.hh
fwd.hh
hpp::constraints::ComparisonTypes_t
std::vector< ComparisonType > ComparisonTypes_t
hpp::corbaServer::toIntSeq
void toIntSeq(std::vector< int > const &in, intSeq &out)
hpp::corbaServer::floatSeqToConfig
Configuration_t floatSeqToConfig(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
hpp::corbaServer::intSeqSeqToMatrix
IntMatrix_t intSeqSeqToMatrix(const intSeqSeq &input, const size_type expectedRows=-1, const size_type expectedCols=-1)
hpp::corbaServer::floatSeqSeqToMatrix
core::matrix_t floatSeqSeqToMatrix(const floatSeqSeq &input, const size_type expectedRows=-1, const size_type expectedCols=-1)
hpp::corbaServer::intSeqToVector
std::vector< int > intSeqToVector(const intSeq &dofArray)
hpp::corbaServer::toHppTransform
void toHppTransform(const Transform3s &in, Transform_ out)
hpp::corbaServer::toNames_t
Names_t * toNames_t(InputIt begin, InputIt end)
Definition: conversions.hh:94
hpp::corbaServer::vector_t
pinocchio::vector_t vector_t
Definition: fwd.hh:107
hpp::corbaServer::vectorToStringSeqSeq
stringSeqSeq * vectorToStringSeqSeq(std::vector< std::vector< std::string >> input)
hpp::corbaServer::Configuration_t
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:65
hpp::corbaServer::toBoolSeq
boolSeq * toBoolSeq(InputIt begin, InputIt end)
Definition: conversions.hh:132
hpp::corbaServer::matrixToIntSeqSeq
intSeqSeq * matrixToIntSeqSeq(Eigen::Ref< const IntMatrix_t > input)
hpp::corbaServer::floatSeqToVector3
vector3_t floatSeqToVector3(const floatSeq &dofArray)
hpp::corbaServer::size_type
pinocchio::size_type size_type
Definition: fwd.hh:110
hpp::corbaServer::toStrings
OutputType toStrings(const Names_t &names)
Definition: conversions.hh:147
hpp::corbaServer::vector3_t
pinocchio::vector3_t vector3_t
Definition: fwd.hh:108
hpp::corbaServer::boolSeqToVector
std::vector< bool > boolSeqToVector(const hpp::boolSeq &mask, unsigned int length=3)
hpp::corbaServer::toTransform3s
void toTransform3s(const Transform_ in, Transform3s &out)
hpp::corbaServer::floatSeqToVector
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
hpp::corbaServer::toCorbaAny
CORBA::Any toCorbaAny(const core::Parameter &parameter)
hpp::corbaServer::Transform3s
pinocchio::Transform3s Transform3s
Definition: fwd.hh:101
hpp::corbaServer::convertComparison
constraints::ComparisonTypes_t convertComparison(hpp::ComparisonTypes_t comp)
Convert CORBA comparison types to C++ comparison type.
hpp::corbaServer::c_str
char * c_str(const std::string &in)
Definition: conversions.hh:87
hpp::corbaServer::vectorToFloatSeq
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
hpp::corbaServer::DevicePtr_t
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:72
hpp::corbaServer::IntMatrix_t
Eigen::Matrix< CORBA::Long, Eigen::Dynamic, Eigen::Dynamic > IntMatrix_t
Definition: conversions.hh:39
hpp::corbaServer::matrixToFloatSeqSeq
floatSeqSeq * matrixToFloatSeqSeq(core::matrixIn_t input)
Returns a sequence of the rows of the input matrix.
hpp::corbaServer::toCorbaAnyPtr
CORBA::Any * toCorbaAnyPtr(const core::Parameter &parameter)
Definition: conversions.hh:164
hpp::corbaServer::toParameter
core::Parameter toParameter(const CORBA::Any &any)
hpp::core::vectorIn_t
pinocchio::vectorIn_t vectorIn_t
hpp::core::matrixIn_t
constraints::matrixIn_t matrixIn_t
hpp::core::matrix_t
pinocchio::matrix_t matrix_t
hpp
Implement CORBA interface `‘Obstacle’'.
hpp::boolSeq
sequence< boolean > boolSeq
Definition: common.idl:30
hpp::Transform_
double Transform_[7]
Element of SE(3) represented by a vector and a unit quaternion.
Definition: common.idl:38
hpp::Names_t
sequence< string > Names_t
Sequence of names.
Definition: common.idl:23
hpp::ComparisonTypes_t
sequence< ComparisonType > ComparisonTypes_t
Definition: common.idl:50
hpp::intSeq
sequence< long > intSeq
Definition: common.idl:31
parameter.hh
size_t
_CORBA_MODULE hpp _CORBA_MODULE_BEG _CORBA_MODULE core_idl _CORBA_MODULE_BEG typedef ::CORBA::ULongLong size_t
Definition: paths-idl.hh:75