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 // STD/STL
24 #include <memory>
25 #include <numeric>
26 #include <string>
27 
28 // Eigen
29 #include <pcl/point_cloud.h>
30 #include <pcl/point_types.h>
31 
32 // ArmarX
34 
35 #include <RobotAPI/interface/aron.h>
37 
39 {
41  {
42  AronPCLConverter() = delete;
43 
44  public:
45  template <typename T>
46  static pcl::PointCloud<T>
48  {
50 
51  if (nav->getShape().size() != 3) // +1 for bytes per pixel
52  {
53  throw error::AronException("AronIVTConverter",
54  "ConvertToCByteImage",
55  "The size of an NDArray does not match.",
56  nav->getPath());
57  }
58  auto dims = nav->getShape();
59 
60  pcl::PointCloud<T> ret(dims[0], dims[1]);
61  memcpy(reinterpret_cast<unsigned char*>(ret.points.data()),
62  nav->getData(),
63  std::accumulate(std::begin(dims), std::end(dims), 1, std::multiplies<int>()));
64  return ret;
65  }
66  };
67 
68 } // namespace armarx::aron::data::converter
69 
70 // legacy
72 {
74 }
armarx::aron::error::AronException
A base class for aron exceptions.
Definition: Exception.h:42
armarx::aron::converter::AronPCLConverter
::armarx::aron::data::converter::AronPCLConverter AronPCLConverter
Definition: PCLConverter.h:73
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
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::data::NDArrayPtr
std::shared_ptr< NDArray > NDArrayPtr
Definition: NDArray.h:46
armarx::aron::converter
Definition: EigenConverter.h:235
ExpressionException.h
armarx::aron::data::converter::AronPCLConverter::ConvertToPointClout
static pcl::PointCloud< T > ConvertToPointClout(const data::NDArrayPtr &nav)
Definition: PCLConverter.h:47
armarx::aron::data::converter::AronPCLConverter
Definition: PCLConverter.h:40
armarx::aron::data::converter
Definition: aron_conversions.cpp:3
NDArray.h