iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test-PointCloud2Normals.C
Go to the documentation of this file.
1 /*! @file
2  @author Unknown
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 #include <nrt/config.h>
35 
36 #if defined(NRT_HAVE_CLOUD) && defined(NRT_HAVE_FLANN)
37 
38 #include <nrt/Core/Debugging/Log.H>
41 
42 using namespace nrt;
43 
44 void createPlanarCloud( PointCloud2 & cloud )
45 {
46  cloud.clear();
47  for ( float xLoc = -0.5; xLoc < 0.5; xLoc += 0.2 )
48  for ( float yLoc = -0.5; yLoc < 0.5; yLoc += 0.2 )
49  cloud.insert( PointCloud2Data<>( PointCloud2::Geometry(xLoc, yLoc, 0.0f) ) );
50 }
51 
52 void createPlanarCloud2( PointCloud2 & cloud )
53 {
54  cloud.clear();
55  for ( float xLoc = -0.5; xLoc < 0.5; xLoc += 0.2 )
56  for ( float zLoc = -0.5; zLoc < 0.5; zLoc += 0.2 )
57  cloud.insert( PointCloud2Data<>( PointCloud2::Geometry(xLoc, 0.0f, zLoc) ) );
58 }
59 
60 
61 int main()
62 {
63  PointCloud2 cloud, features;
64 
65  createPlanarCloud( cloud );
66 
67  // Test point normal calculation
68  NRT_INFO("Testing Point normal calculation - expected normals along Z axis");
69 
70  Normals normalWorker( PointCloudSearchMethod::knn, 5 );
71 
72  features = normalWorker.computeFeatures( cloud );
73 
74  for( auto i = features.const_begin<PointNormal>(), end = features.const_end<PointNormal>(); i != end; ++i )
75  NRT_INFO( *i );
76 
77  NRT_INFO("Testing Point normal calculation - expected normals along Y axis");
78  createPlanarCloud2( cloud );
79 
80  features = normalWorker.computeFeatures( cloud );
81 
82  for( auto i = features.const_begin<PointNormal>(), end = features.const_end<PointNormal>(); i != end; ++i )
83  NRT_INFO( *i );
84 
85  return 0;
86 }
87 #else // NRT_HAVE_CLOUD
88 int main()
89 { return -1; }
90 #endif // NRT_HAVE_CLOUD