iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tests/test-PointCloud2Normals.C
/*! @file
@author Unknown
@copyright GNU Public License (GPL v3)
@section License
@verbatim
// ////////////////////////////////////////////////////////////////////////
// The iLab Neuromorphic Robotics Toolkit (NRT) //
// Copyright 2010-2012 by the University of Southern California (USC) //
// and the iLab at USC. //
// //
// iLab - University of Southern California //
// Hedco Neurociences Building, Room HNB-10 //
// Los Angeles, Ca 90089-2520 - USA //
// //
// See http://ilab.usc.edu for information about this project. //
// ////////////////////////////////////////////////////////////////////////
// This file is part of The iLab Neuromorphic Robotics Toolkit. //
// //
// The iLab Neuromorphic Robotics Toolkit is free software: you can //
// redistribute it and/or modify it under the terms of the GNU General //
// Public License as published by the Free Software Foundation, either //
// version 3 of the License, or (at your option) any later version. //
// //
// The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
// that it will be useful, but WITHOUT ANY WARRANTY; without even the //
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
// PURPOSE. See the GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with The iLab Neuromorphic Robotics Toolkit. If not, see //
// <http://www.gnu.org/licenses/>. //
// ////////////////////////////////////////////////////////////////////////
@endverbatim */
#include <nrt/config.h>
#if defined(NRT_HAVE_CLOUD) && defined(NRT_HAVE_FLANN)
using namespace nrt;
void createPlanarCloud( PointCloud2 & cloud )
{
cloud.clear();
for ( float xLoc = -0.5; xLoc < 0.5; xLoc += 0.2 )
for ( float yLoc = -0.5; yLoc < 0.5; yLoc += 0.2 )
cloud.insert( PointCloud2Data<>( PointCloud2::Geometry(xLoc, yLoc, 0.0f) ) );
}
void createPlanarCloud2( PointCloud2 & cloud )
{
cloud.clear();
for ( float xLoc = -0.5; xLoc < 0.5; xLoc += 0.2 )
for ( float zLoc = -0.5; zLoc < 0.5; zLoc += 0.2 )
cloud.insert( PointCloud2Data<>( PointCloud2::Geometry(xLoc, 0.0f, zLoc) ) );
}
int main()
{
PointCloud2 cloud, features;
createPlanarCloud( cloud );
// Test point normal calculation
NRT_INFO("Testing Point normal calculation - expected normals along Z axis");
Normals normalWorker( PointCloudSearchMethod::knn, 5 );
features = normalWorker.computeFeatures( cloud );
for( auto i = features.const_begin<PointNormal>(), end = features.const_end<PointNormal>(); i != end; ++i )
NRT_INFO( *i );
NRT_INFO("Testing Point normal calculation - expected normals along Y axis");
createPlanarCloud2( cloud );
features = normalWorker.computeFeatures( cloud );
for( auto i = features.const_begin<PointNormal>(), end = features.const_end<PointNormal>(); i != end; ++i )
NRT_INFO( *i );
return 0;
}
#else // NRT_HAVE_CLOUD
int main()
{ return -1; }
#endif // NRT_HAVE_CLOUD