Skip to content

Commit

Permalink
Match tesseract_ros#233 for tesseract_rosutils/test
Browse files Browse the repository at this point in the history
  • Loading branch information
rjoomen committed May 1, 2024
1 parent 0683f16 commit 32022c0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 34 deletions.
24 changes: 4 additions & 20 deletions tesseract_rosutils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,7 @@ install(

ament_package()

if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
find_package(GTest REQUIRED)
find_package(std_msgs REQUIRED)
find_package(tesseract_support REQUIRED)

ament_add_gtest(${PROJECT_NAME}_unit test/tesseract_rosutils_unit.cpp)
target_link_libraries(${PROJECT_NAME}_unit
GTest::GTest
GTest::Main
tesseract::tesseract_support
${PROJECT_NAME}
)
target_compile_options(${PROJECT_NAME}_unit PRIVATE ${TESSERACT_COMPILE_OPTIONS})
target_clang_tidy(${PROJECT_NAME}_unit ARGUMENTS ${TESSERACT_CLANG_TIDY_ARGS} ENABLE ${TESSERACT_ENABLE_CLANG_TIDY})
target_cxx_version(${PROJECT_NAME}_unit PUBLIC VERSION ${TESSERACT_CXX_VERSION})
target_include_directories(${PROJECT_NAME}_unit PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
endif()
if(TESSERACT_ENABLE_TESTING)
enable_testing()
add_subdirectory(test)
endif()
16 changes: 16 additions & 0 deletions tesseract_rosutils/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
find_gtest()
find_package(tesseract_support REQUIRED)

add_executable(${PROJECT_NAME}_unit tesseract_rosutils_unit.cpp)
target_link_libraries(${PROJECT_NAME}_unit GTest::GTest GTest::Main Eigen3::Eigen tesseract::tesseract_support tesseract::tesseract_scene_graph tesseract::tesseract_geometry tesseract::tesseract_collision_core tesseract::tesseract_visualization tesseract::tesseract_common tesseract::tesseract_motion_planners_core ${PROJECT_NAME})
target_compile_options(${PROJECT_NAME}_unit PRIVATE ${TESSERACT_COMPILE_OPTIONS})
target_clang_tidy(${PROJECT_NAME}_unit ARGUMENTS ${TESSERACT_CLANG_TIDY_ARGS} ENABLE ${TESSERACT_ENABLE_CLANG_TIDY})
target_cxx_version(${PROJECT_NAME}_unit PUBLIC VERSION 17)
add_gtest_discover_tests(${PROJECT_NAME}_unit)

add_executable(${PROJECT_NAME}_geometry_msg_conversions tesseract_rosutils_geometry_msg_conversions.cpp)
target_link_libraries(${PROJECT_NAME}_geometry_msg_conversions GTest::GTest GTest::Main Eigen3::Eigen tesseract::tesseract_support tesseract::tesseract_scene_graph tesseract::tesseract_geometry tesseract::tesseract_collision_core tesseract::tesseract_visualization tesseract::tesseract_common tesseract::tesseract_motion_planners_core ${PROJECT_NAME})
target_compile_options(${PROJECT_NAME}_geometry_msg_conversions PRIVATE ${TESSERACT_COMPILE_OPTIONS})
target_clang_tidy(${PROJECT_NAME}_geometry_msg_conversions ARGUMENTS ${TESSERACT_CLANG_TIDY_ARGS} ENABLE ${TESSERACT_ENABLE_CLANG_TIDY})
target_cxx_version(${PROJECT_NAME}_geometry_msg_conversions PUBLIC VERSION 17)
add_gtest_discover_tests(${PROJECT_NAME}_geometry_msg_conversions)
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_common/unit_test_utils.h>
#include <tesseract_common/utils.h>
#include <tesseract_geometry/geometries.h>
#include <tesseract_geometry/impl/octree_utils.h>
#include <tesseract_geometry/mesh_parser.h>
#include <tesseract_support/tesseract_support_resource_locator.h>

#include <tesseract_msgs/msg/geometry.h>
#include <tesseract_rosutils/utils.h>

using namespace tesseract_geometry;
Expand All @@ -44,7 +47,7 @@ using namespace tesseract_rosutils;
inline void testToMsgFromMsg(const tesseract_geometry::Geometry& object)
{
// Serialize to ros message
tesseract_msgs::Geometry msg;
tesseract_msgs::msg::Geometry msg;
EXPECT_TRUE(toMsg(msg, object));

// Deserialize to object
Expand Down Expand Up @@ -117,13 +120,15 @@ TEST(TesseractRosutilsGeometryMsgConversions, Octree) // NOLINT
pc.points.emplace_back(-.5, -0.5, -0.5);
pc.points.emplace_back(-.5, 0.5, 0.5);
{
auto object =
std::make_shared<tesseract_geometry::Octree>(pc, 1, tesseract_geometry::Octree::SubType::BOX, false, true);
std::unique_ptr<octomap::OcTree> ot = createOctree(pc, 1, false, true);
auto object = std::make_shared<tesseract_geometry::Octree>(
std::move(ot), tesseract_geometry::OctreeSubType::BOX, false, true);
testToMsgFromMsg(*object);
}
{
auto object =
std::make_shared<tesseract_geometry::Octree>(pc, 1, tesseract_geometry::Octree::SubType::BOX, false, false);
std::unique_ptr<octomap::OcTree> ot = createOctree(pc, 1, false, true);
auto object = std::make_shared<tesseract_geometry::Octree>(
std::move(ot), tesseract_geometry::OctreeSubType::BOX, false, false);
testToMsgFromMsg(*object);
}
}
Expand Down
22 changes: 13 additions & 9 deletions tesseract_rosutils/test/tesseract_rosutils_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <gtest/gtest.h>
#include <algorithm>
#include <memory>
#include <Eigen/Eigen>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_rosutils/conversions.h>
#include <tesseract_rosutils/plotting.h>
#include <tesseract_rosutils/utils.h>
#include <tesseract_environment/environment.h>
#include <tesseract_common/resource_locator.h>
#include <tesseract_srdf/kinematics_information.h>

#include <tesseract_msgs/msg/environment_state.hpp>
#include <tesseract_common/types.h>
#include <Eigen/Eigen>

#include <tesseract_scene_graph/joint.h>
#include <tesseract_common/joint_state.h>
#include <tesseract_common/resource_locator.h>
#include <tesseract_srdf/kinematics_information.h>
#include <tesseract_scene_graph/link.h>

#include <tesseract_scene_graph/joint.h>
#include <tesseract_scene_graph/scene_state.h>
#include <tesseract_environment/environment.h>
#include <tesseract_environment/command.h>
#include <tesseract_environment/commands.h>
#include <tesseract_environment/commands/add_link_command.h>

#include <tesseract_msgs/msg/environment.h>
#include <tesseract_msgs/msg/environment_state.h>
#include <tesseract_msgs/msg/joint_trajectory.h>
#include <trajectory_msgs/msg/joint_trajectory.h>

using namespace tesseract_environment;
using namespace tesseract_scene_graph;
Expand Down

0 comments on commit 32022c0

Please sign in to comment.