hpp-corbaserver 4.14.0
Corba server for Humanoid Path Planner applications
Loading...
Searching...
No Matches
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>
34#include <hpp/core/parameter.hh>
35#include <hpp/util/exception-factory.hh>
36
37namespace hpp {
38namespace corbaServer {
39typedef Eigen::Matrix<CORBA::Long, Eigen::Dynamic, Eigen::Dynamic> IntMatrix_t;
40
42
44
45std::vector<Transform3f> toTransform3f(const TransformSeq in);
46
48
50
51floatSeq* vectorToFloatSeq(core::vectorIn_t input);
52
53void vectorToFloatSeq(core::vectorIn_t input, floatSeq& output);
54
55inline floatSeq* vectorToFloatSeq(core::ConfigurationPtr_t input) {
56 if (!input) return NULL;
57 return vectorToFloatSeq(*input);
58}
59
61// Return [ [input.row(0)], [input.row(1)], ...]
62floatSeqSeq* matrixToFloatSeqSeq(core::matrixIn_t input);
63
64intSeqSeq* matrixToIntSeqSeq(Eigen::Ref<const IntMatrix_t> input);
65
67
69 const size_type expectedSize = -1);
70
72 const floatSeq& dofArray,
73 bool throwIfNotNormalized);
74
76 const floatSeq& dofArray,
77 bool throwIfNotNormalized);
78
79core::matrix_t floatSeqSeqToMatrix(const floatSeqSeq& input,
80 const size_type expectedRows = -1,
81 const size_type expectedCols = -1);
82
84 const size_type expectedRows = -1,
85 const size_type expectedCols = -1);
86
87std::vector<bool> boolSeqToVector(const hpp::boolSeq& mask,
88 unsigned int length = 3);
89
90stringSeqSeq* vectorToStringSeqSeq(std::vector<std::vector<std::string>> input);
91
92inline char* c_str(const std::string& in) {
93 char* out = new char[in.length() + 1];
94 strcpy(out, in.c_str());
95 return out;
96}
97
98template <typename InputIt>
99inline Names_t* toNames_t(InputIt begin, InputIt end) {
100 std::size_t len = std::distance(begin, end);
101 char** nameList = Names_t::allocbuf((CORBA::ULong)len);
102 Names_t* ret =
103 new Names_t((CORBA::ULong)len, (CORBA::ULong)len, nameList, true);
104
105 std::size_t i = 0;
106 while (begin != end) {
107 nameList[i] = c_str(*begin);
108 ++begin;
109 ++i;
110 }
111 return ret;
112}
113
114template <typename Iterable>
115inline Names_t* toNames_t(const Iterable& iterable) {
116 return toNames_t(iterable.begin(), iterable.end());
117}
118
119template <typename InputIt>
120inline intSeq* toIntSeq(InputIt begin, InputIt end) {
121 std::size_t len = std::distance(begin, end);
122 intSeq* indexes = new intSeq();
123 indexes->length((CORBA::ULong)len);
124
125 std::size_t i = 0;
126 while (begin != end) {
127 (*indexes)[i] = *begin;
128 ++begin;
129 ++i;
130 }
131 return indexes;
132}
133
134template <typename InputIt>
135inline boolSeq* toBoolSeq(InputIt begin, InputIt end) {
136 std::size_t len = std::distance(begin, end);
137 boolSeq* indexes = new boolSeq();
138 indexes->length((CORBA::ULong)len);
139
140 std::size_t i = 0;
141 while (begin != end) {
142 (*indexes)[(CORBA::ULong)i] = *begin;
143 ++begin;
144 ++i;
145 }
146 return indexes;
147}
148
149template <typename OutputType>
150inline OutputType toStrings(const Names_t& names) {
151 OutputType ret;
152 for (CORBA::ULong i = 0; i < names.length(); ++i)
153 ret.push_back(std::string(names[i]));
154 return ret;
155}
156
158constraints::ComparisonTypes_t convertComparison(hpp::ComparisonTypes_t comp);
159
161hpp::ComparisonTypes_t* convertComparison(constraints::ComparisonTypes_t comp);
162
163core::Parameter toParameter(const CORBA::Any& any);
164
165CORBA::Any toCorbaAny(const core::Parameter& parameter);
166
167inline CORBA::Any* toCorbaAnyPtr(const core::Parameter& parameter) {
168 CORBA::Any* ap = new CORBA::Any;
169 *ap = toCorbaAny(parameter);
170 return ap;
171}
172
173} // namespace corbaServer
174} // namespace hpp
175
176#endif // HPP_CORBASERVER_CONVERSIONS_HH
Definition: common-idl.hh:78
Definition: common-idl.hh:965
Definition: common-idl.hh:347
Definition: common-idl.hh:803
Definition: common-idl.hh:689
Definition: common-idl.hh:575
Definition: common-idl.hh:461
Definition: common-idl.hh:192
::CORBA::Double Transform__slice
Definition: common-idl.hh:916
void toHppTransform(const Transform3f &in, Transform_ out)
Configuration_t floatSeqToConfig(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
boolSeq * toBoolSeq(InputIt begin, InputIt end)
Definition: conversions.hh:135
std::vector< bool > boolSeqToVector(const hpp::boolSeq &mask, unsigned int length=3)
pinocchio::Transform3f Transform3f
Definition: fwd.hh:103
IntMatrix_t intSeqSeqToMatrix(const intSeqSeq &input, const size_type expectedRows=-1, const size_type expectedCols=-1)
core::matrix_t floatSeqSeqToMatrix(const floatSeqSeq &input, const size_type expectedRows=-1, const size_type expectedCols=-1)
pinocchio::vector_t vector_t
Definition: fwd.hh:112
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:66
vector3_t floatSeqToVector3(const floatSeq &dofArray)
intSeq * toIntSeq(InputIt begin, InputIt end)
Definition: conversions.hh:120
floatSeq * vectorToFloatSeq(core::vectorIn_t input)
CORBA::Any * toCorbaAnyPtr(const core::Parameter &parameter)
Definition: conversions.hh:167
ConfigurationPtr_t floatSeqToConfigPtr(const DevicePtr_t &robot, const floatSeq &dofArray, bool throwIfNotNormalized)
pinocchio::size_type size_type
Definition: fwd.hh:115
intSeqSeq * matrixToIntSeqSeq(Eigen::Ref< const IntMatrix_t > input)
core::ConfigurationPtr_t ConfigurationPtr_t
Definition: fwd.hh:67
OutputType toStrings(const Names_t &names)
Definition: conversions.hh:150
pinocchio::vector3_t vector3_t
Definition: fwd.hh:113
vector_t floatSeqToVector(const floatSeq &dofArray, const size_type expectedSize=-1)
CORBA::Any toCorbaAny(const core::Parameter &parameter)
floatSeqSeq * matrixToFloatSeqSeq(core::matrixIn_t input)
Returns a sequence of the rows of the input matrix.
stringSeqSeq * vectorToStringSeqSeq(std::vector< std::vector< std::string > > input)
Names_t * toNames_t(InputIt begin, InputIt end)
Definition: conversions.hh:99
void toTransform3f(const Transform_ in, Transform3f &out)
constraints::ComparisonTypes_t convertComparison(hpp::ComparisonTypes_t comp)
Convert CORBA comparison types to C++ comparison type.
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:74
Eigen::Matrix< CORBA::Long, Eigen::Dynamic, Eigen::Dynamic > IntMatrix_t
Definition: conversions.hh:39
char * c_str(const std::string &in)
Definition: conversions.hh:92
core::Parameter toParameter(const CORBA::Any &any)
Implement CORBA interface `‘Obstacle’'.
Definition: basic-server.hh:35
sequence< boolean > boolSeq
Definition: common.idl:30
double Transform_[7]
Element of SE(3) represented by a vector and a unit quaternion.
Definition: common.idl:38
sequence< string > Names_t
Sequence of names.
Definition: common.idl:23
sequence< ComparisonType > ComparisonTypes_t
Definition: common.idl:50
sequence< long > intSeq
Definition: common.idl:31