PCLConverter.h
Go to the documentation of this file.
1
/*
2
* This file is part of ArmarX.
3
*
4
* ArmarX is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation.
7
*
8
* ArmarX is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*
16
* @author Fabian Peller (fabian dot peller at kit dot edu)
17
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18
* GNU General Public License
19
*/
20
21
#pragma once
22
23
#include <numeric>
24
#include <string>
25
26
#include <pcl/point_cloud.h>
27
#include <pcl/point_types.h>
28
29
#include <
ArmarXCore/core/exceptions/local/ExpressionException.h
>
30
31
#include <RobotAPI/interface/aron.h>
32
#include <
RobotAPI/libraries/aron/core/data/variant/complex/NDArray.h
>
33
34
namespace
armarx::aron::data::converter
35
{
36
class
AronPCLConverter
37
{
38
AronPCLConverter() =
delete
;
39
40
public
:
41
template
<
typename
T>
42
static
pcl::PointCloud<T>
43
ConvertToPointClout
(
const
data::NDArrayPtr
&
nav
)
44
{
45
ARMARX_CHECK_NOT_NULL
(
nav
);
46
47
if
(
nav
->getShape().size() != 3)
// +1 for bytes per pixel
48
{
49
throw
error::AronException
(
"AronIVTConverter"
,
50
"ConvertToCByteImage"
,
51
"The size of an NDArray does not match."
,
52
nav
->getPath());
53
}
54
auto
dims =
nav
->getShape();
55
56
pcl::PointCloud<T> ret(dims[0], dims[1]);
57
memcpy(
reinterpret_cast<
unsigned
char
*
>
(ret.points.data()),
58
nav
->getData(),
59
std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()));
60
return
ret;
61
}
62
};
63
64
}
// namespace armarx::aron::data::converter
65
66
// legacy
67
namespace
armarx::aron::converter
68
{
69
using
AronPCLConverter
=
::armarx::aron::data::converter::AronPCLConverter
;
70
}
ExpressionException.h
armarx::aron::data::converter::AronPCLConverter
Definition
PCLConverter.h:37
armarx::aron::data::converter::AronPCLConverter::ConvertToPointClout
static pcl::PointCloud< T > ConvertToPointClout(const data::NDArrayPtr &nav)
Definition
PCLConverter.h:43
armarx::aron::error::AronException
A base class for aron exceptions.
Definition
Exception.h:37
NDArray.h
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition
ExpressionException.h:206
armarx::aron::converter
Definition
EigenConverter.h:236
armarx::aron::converter::AronPCLConverter
::armarx::aron::data::converter::AronPCLConverter AronPCLConverter
Definition
PCLConverter.h:69
armarx::aron::data::converter
Definition
aron_conversions.cpp:4
armarx::aron::data::NDArrayPtr
std::shared_ptr< NDArray > NDArrayPtr
Definition
NDArray.h:46
armarx::nav
Definition
client.h:7
RobotAPI
libraries
aron
converter
pcl
PCLConverter.h
Generated by
1.13.2