Skip to content

Commit

Permalink
Add tests for individual components in test_package
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Aug 3, 2023
1 parent 00575e3 commit 63e6fbc
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/cupoch/kinematics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(CUPOCH_MODULES ${CUPOCH_MODULES} cupoch_kinematics PARENT_SCOPE)
find_package(urdfdom REQUIRED CONFIG)

file(GLOB_RECURSE KINEMATICS_SOURCE_FILES "*.cpp")
set_source_files_properties(${KINEMATICS_SOURCE_FILES} PROPERTIES LANGUAGE CUDA)

# Create object library
add_library(cupoch_kinematics ${KINEMATICS_SOURCE_FILES})
Expand Down
16 changes: 14 additions & 2 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,17 @@ project(PackageTest LANGUAGES CXX CUDA)

find_package(cupoch REQUIRED)

add_executable(test_registration test_registration.cpp)
target_link_libraries(test_registration PRIVATE cupoch::registration)
if (TARGET cupoch::registration)
add_executable(test_registration test_registration.cpp)
target_link_libraries(test_registration PRIVATE cupoch::registration)
endif()

if (TARGET cupoch::kinematics)
add_executable(test_kinematics test_kinematics.cpp)
target_link_libraries(test_kinematics PRIVATE cupoch::kinematics)
endif()

if (TARGET cupoch::io)
add_executable(test_io test_io.cpp)
target_link_libraries(test_io PRIVATE cupoch::io)
endif()
11 changes: 10 additions & 1 deletion test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ def build(self):
cmake.build()

def test(self):
if can_run(self):
if not can_run(self):
return
cupoch_opts = self.dependencies["cupoch"].options
if cupoch_opts.registration:
cmd = os.path.join(self.cpp.build.bindir, "test_registration")
self.run(cmd, env="conanrun")
if cupoch_opts.kinematics:
cmd = os.path.join(self.cpp.build.bindir, "test_kinematics")
self.run(cmd, env="conanrun")
if cupoch_opts.io:
cmd = os.path.join(self.cpp.build.bindir, "test_io")
self.run(cmd, env="conanrun")
69 changes: 69 additions & 0 deletions test_package/test_io.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright (c) 2020 Neka-Nat
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
**/

#include <cupoch/geometry/image.h>
#include <cupoch/geometry/pointcloud.h>
#include <cupoch/geometry/trianglemesh.h>
#include <cupoch/geometry/voxelgrid.h>
#include <cupoch/io/class_io/image_io.h>
#include <cupoch/io/class_io/pointcloud_io.h>
#include <cupoch/io/class_io/trianglemesh_io.h>
#include <cupoch/io/class_io/voxelgrid_io.h>
#include <cupoch/utility/console.h>

using namespace cupoch;

void downsampleImage() {
auto color_image_8bit = io::CreateImageFromFile("test.png");
utility::LogDebug("RGB image size : {:d} x {:d}", color_image_8bit->width_,
color_image_8bit->height_);
io::WriteImage("copy.png", *color_image_8bit);
auto float_image = color_image_8bit->CreateFloatImage();
io::WriteImage("floatimage.png",
*float_image->CreateImageFromFloatImage<uint8_t>());
auto downsampled_image = float_image->Downsample();
io::WriteImage("downsample.png",
*downsampled_image->CreateImageFromFloatImage<uint8_t>());
}

void estimateNormals() {
auto pcd = io::CreatePointCloudFromFile("test.ply");
pcd->EstimateNormals();
}

void loadMesh() {
auto mesh = io::CreateMeshFromFile("test.ply");
utility::LogDebug("Vertices size : {:d}", mesh->vertices_.size());
}

void toVoxelGrid() {
auto pcd = io::CreatePointCloudFromFile("test.ply");
auto voxel = geometry::VoxelGrid::CreateFromPointCloud(*pcd, 0.05);
io::WriteVoxelGrid("result.ply", *voxel, true);
auto voxel_read = io::CreateVoxelGridFromFile("result.ply");
}

int main() {
utility::InitializeAllocator();
utility::SetVerbosityLevel(utility::VerbosityLevel::Debug);
// Only testing that the code compiles and links.
return 0;
}
18 changes: 18 additions & 0 deletions test_package/test_kinematics.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <cupoch/kinematics/kinematic_chain.h>

using namespace cupoch;

void testKinematics() {
auto kin = kinematics::KinematicChain();
auto poses = kin.ForwardKinematics();
auto meshes = kin.GetTransformedVisualGeometryMap(poses);
std::vector<std::shared_ptr<const geometry::Geometry>> geoms;
for (const auto& m : meshes) {
geoms.push_back(m.second);
}
}

int main() {
// Only testing that the code compiles and links.
return 0;
}

0 comments on commit 63e6fbc

Please sign in to comment.