Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vtk_viewer CMake #93

Merged
merged 3 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ env:
global:
- NOT_TEST_BUILD=true
- UPSTREAM_WORKSPACE='dependencies_ros1.rosinstall'
- ROSDEP_SKIP_KEYS='iwyu cmake_common_scripts'
- ADDITIONAL_DEBS='iwyu'

matrix:
include:
Expand Down
1 change: 1 addition & 0 deletions dependencies_ros1.rosinstall
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# PCL ros tools, this is required because using custom version of PCL and VTK
- git: {local-name: perception_pcl, uri: 'https://github.com/ros-perception/perception_pcl.git', version: 1.7.1}
- git: {local-name: cmake_common_scripts, uri: 'https://github.com/ros-industrial/cmake_common_scripts.git', version: master}
5 changes: 4 additions & 1 deletion mesh_segmenter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ else()
endif()

find_package(catkin REQUIRED)
find_package(vtk_viewer REQUIRED)

catkin_package(
INCLUDE_DIRS
Expand All @@ -21,6 +22,7 @@ catkin_package(
${PROJECT_NAME}
DEPENDS
VTK
vtk_viewer
)

include_directories(
Expand All @@ -34,6 +36,7 @@ add_library(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
${VTK_LIBRARIES}
noether::vtk_viewer
)
add_dependencies(${PROJECT_NAME}
${catkin_EXPORTED_TARGETS}
Expand All @@ -58,7 +61,7 @@ install(DIRECTORY include/${PROJECT_NAME}/
## Testing ##
#############
if(CATKIN_ENABLE_TESTING)
find_package(catkin REQUIRED COMPONENTS vtk_viewer)
find_package(vtk_viewer REQUIRED)
include_directories(
include
${catkin_INCLUDE_DIRS}
Expand Down
2 changes: 1 addition & 1 deletion mesh_segmenter/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

<buildtool_depend>catkin</buildtool_depend>

<test_depend>vtk_viewer</test_depend>
<depend>vtk_viewer</depend>

</package>
30 changes: 8 additions & 22 deletions mesh_segmenter/src/mesh_segmenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,10 @@

#include <mesh_segmenter/mesh_segmenter.h>

#include <log4cxx/basicconfigurator.h>
#include <log4cxx/patternlayout.h>
#include <log4cxx/consoleappender.h>

log4cxx::LoggerPtr createConsoleLogger(const std::string& logger_name)
{
using namespace log4cxx;
PatternLayoutPtr pattern_layout(new PatternLayout("[\%-5p] [\%c](L:\%L): \%m\%n"));
ConsoleAppenderPtr console_appender(new ConsoleAppender(pattern_layout));
log4cxx::LoggerPtr logger(Logger::getLogger(logger_name));
logger->addAppender(console_appender);
logger->setLevel(Level::getInfo());
return logger;
}
#include <console_bridge/console.h>

namespace mesh_segmenter
{
static log4cxx::LoggerPtr SEGMENTATION_LOGGER = createConsoleLogger("SegmentationLogger");

void MeshSegmenter::setInputMesh(vtkSmartPointer<vtkPolyData> mesh)
{
Expand All @@ -48,9 +34,9 @@ std::vector<vtkSmartPointer<vtkPolyData> > MeshSegmenter::getMeshSegments()
vtkSmartPointer<vtkPolyData> input_copy = vtkSmartPointer<vtkPolyData>::New();
input_copy->DeepCopy(input_mesh_);
std::vector<vtkSmartPointer<vtkPolyData> > meshes;
for (int i = 0; i < included_indices_.size(); ++i)
for (std::size_t i = 0; i < included_indices_.size(); ++i)
{
LOG4CXX_INFO(SEGMENTATION_LOGGER, "Segment " << i << " size: " << included_indices_.at(i)->GetNumberOfIds());
CONSOLE_BRIDGE_logInform(("Segment " + std::to_string(i) + " size: " + std::to_string(included_indices_.at(i)->GetNumberOfIds())).c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why console bridge over log4cxx?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were getting log4cxx from rosconsole. Switching to console_bridge seemed like the thing to do to make this ROS agnostic.

Copy link
Member

@Levi-Armstrong Levi-Armstrong Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I believe when using the ROS agnostic package within the ros ecosystem you can pipe console bridge output to ros log files.


vtkSmartPointer<vtkPolyData> mesh = vtkSmartPointer<vtkPolyData>::New();
// Create new pointer to a new copy of input_mesh_
Expand All @@ -72,7 +58,7 @@ std::vector<vtkSmartPointer<vtkPolyData> > MeshSegmenter::getMeshSegments()

if (mesh->GetNumberOfCells() <= 1)
{
LOG4CXX_WARN(SEGMENTATION_LOGGER, "NOT ENOUGH CELLS FOR SEGMENTATION");
CONSOLE_BRIDGE_logWarn("NOT ENOUGH CELLS FOR SEGMENTATION");
continue;
}
meshes.push_back(mesh);
Expand Down Expand Up @@ -138,10 +124,10 @@ void MeshSegmenter::segmentMesh()
}
included_indices_.push_back(edge_cells);

LOG4CXX_INFO(SEGMENTATION_LOGGER, "Found " << included_indices_.size() << " segments");
LOG4CXX_INFO(SEGMENTATION_LOGGER, "Total mesh size: " << size);
LOG4CXX_INFO(SEGMENTATION_LOGGER, "Used cells size: " << used_cells->GetNumberOfIds());
LOG4CXX_INFO(SEGMENTATION_LOGGER, "Edge cells size: " << edge_cells->GetNumberOfIds());
CONSOLE_BRIDGE_logInform("Found %d segments", included_indices_.size());
CONSOLE_BRIDGE_logInform("Total mesh size: %d", size);
CONSOLE_BRIDGE_logInform("Used cells size: %d", used_cells->GetNumberOfIds());
CONSOLE_BRIDGE_logInform("Edge cells size: %d", edge_cells->GetNumberOfIds());
}

vtkSmartPointer<vtkIdList> MeshSegmenter::segmentMesh(int start_cell)
Expand Down
12 changes: 10 additions & 2 deletions noether/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ find_package(catkin REQUIRED COMPONENTS
pcl_conversions
roscpp
tool_path_planner
vtk_viewer
)

find_package(vtk_viewer REQUIRED)

find_package(noether_filtering)
if(NOT noether_filtering_FOUND)
message(WARNING "noether_filtering not found. mesh_filter_server will not be compiled")
Expand All @@ -53,10 +54,10 @@ catkin_package(
pcl_conversions
roscpp
tool_path_planner
vtk_viewer
DEPENDS
VTK
PCL
vtk_viewer
)

include_directories(include ${catkin_INCLUDE_DIRS})
Expand All @@ -68,6 +69,7 @@ add_executable(surface_raster_planner_server
target_link_libraries(surface_raster_planner_server
${catkin_LIBRARIES}
${VTK_LIBRARIES}
noether::vtk_viewer
)

add_executable(surface_raster_planner_application
Expand All @@ -76,6 +78,7 @@ add_executable(surface_raster_planner_application
target_link_libraries(surface_raster_planner_application
${catkin_LIBRARIES}
${VTK_LIBRARIES}
noether::vtk_viewer
)

add_executable(segmentation_server
Expand All @@ -84,6 +87,7 @@ add_executable(segmentation_server
target_link_libraries(segmentation_server
${catkin_LIBRARIES}
${VTK_LIBRARIES}
noether::vtk_viewer
)
#There needs to be a better pathing to the library
add_executable(convex_hull_node
Expand All @@ -94,6 +98,7 @@ add_executable(convex_hull_node
target_link_libraries(convex_hull_node
${catkin_LIBRARIES}
${VTK_LIBRARIES}
noether::vtk_viewer
)

if(noether_filtering_FOUND)
Expand All @@ -103,6 +108,7 @@ if(noether_filtering_FOUND)
target_link_libraries(mesh_filter_server PUBLIC
${catkin_LIBRARIES}
noether_filtering::noether_filtering
noether::vtk_viewer
)
endif()

Expand All @@ -111,13 +117,15 @@ add_executable(edge_generator_server
)
target_link_libraries(edge_generator_server
${catkin_LIBRARIES}
noether::vtk_viewer
)

add_executable(halfedge_boundary_finder_server
src/halfedge_boundary_finder_server.cpp
)
target_link_libraries(halfedge_boundary_finder_server
${catkin_LIBRARIES}
noether::vtk_viewer
)

#############
Expand Down
6 changes: 5 additions & 1 deletion noether/src/surface_raster_planner_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vtkPointData.h>
#include <ros/ros.h>
#include <ros/file_log.h>
#include <console_bridge/console.h>

namespace noether {

Expand Down Expand Up @@ -148,7 +149,10 @@ int main(int argc, char **argv)
pnh.param<double>("centroid_y", center[1], 0.0);
pnh.param<double>("centroid_z", center[2], 0.0);

vtk_viewer::VTK_LOGGER->setLevel(console_debug_on ? log4cxx::Level::getDebug(): log4cxx::Level::getInfo());
if (console_debug_on)
console_bridge::setLogLevel(console_bridge::LogLevel::CONSOLE_BRIDGE_LOG_DEBUG);
else
console_bridge::setLogLevel(console_bridge::LogLevel::CONSOLE_BRIDGE_LOG_INFO);

// load tool config
tool_path_planner::ProcessTool tool = loadTool(pnh);
Expand Down
15 changes: 8 additions & 7 deletions noether_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ find_package(catkin REQUIRED COMPONENTS
roscpp
roslib
tool_path_planner
vtk_viewer
)

find_package(vtk_viewer REQUIRED)

catkin_package(
INCLUDE_DIRS
include
Expand All @@ -48,10 +49,10 @@ catkin_package(
roscpp
roslib
tool_path_planner
vtk_viewer
DEPENDS
VTK
PCL
vtk_viewer
)

include_directories(
Expand All @@ -61,23 +62,23 @@ include_directories(
)

add_executable(mesh_segmenter_client_node src/mesh_segmenter_client.cpp)
target_link_libraries(mesh_segmenter_client_node ${catkin_LIBRARIES} ${VTK_LIBRARIES})
target_link_libraries(mesh_segmenter_client_node ${catkin_LIBRARIES} ${VTK_LIBRARIES} noether::vtk_viewer)
list (APPEND PACKAGE_TARGETS mesh_segmenter_client_node)

add_executable(mesh_segmenter_node src/mesh_segmenter_node.cpp)
target_link_libraries(mesh_segmenter_node ${catkin_LIBRARIES} ${VTK_LIBRARIES})
target_link_libraries(mesh_segmenter_node ${catkin_LIBRARIES} ${VTK_LIBRARIES} noether::vtk_viewer)
list (APPEND PACKAGE_TARGETS mesh_segmenter_node)

add_executable(mesh_filtering_client src/mesh_filtering_client.cpp)
target_link_libraries(mesh_filtering_client ${catkin_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(mesh_filtering_client ${catkin_LIBRARIES} ${PCL_LIBRARIES} noether::vtk_viewer)
list (APPEND PACKAGE_TARGETS mesh_filtering_client)

add_executable(edge_generator_client src/edge_generator_client.cpp)
target_link_libraries(edge_generator_client ${catkin_LIBRARIES})
target_link_libraries(edge_generator_client ${catkin_LIBRARIES} noether::vtk_viewer)
list (APPEND PACKAGE_TARGETS edge_generator_client)

add_executable(halfedge_finder_node src/halfedge_finder_node.cpp)
target_link_libraries(halfedge_finder_node ${catkin_LIBRARIES})
target_link_libraries(halfedge_finder_node ${catkin_LIBRARIES} noether::vtk_viewer)
list (APPEND PACKAGE_TARGETS halfedge_finder_node)

#############
Expand Down
2 changes: 1 addition & 1 deletion noether_filtering/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<license>Apache 2.0</license>
<author email="[email protected]">Jorge Nicho</author>

<buildtool_depend>catkin</buildtool_depend>
<depend>libconsole-bridge-dev</depend>
<depend>pluginlib</depend>
<depend>libpcl-all-dev</depend>
<export>
Expand Down
5 changes: 4 additions & 1 deletion path_sequence_planner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ endif()

find_package(catkin REQUIRED COMPONENTS
tool_path_planner
vtk_viewer
)

find_package(vtk_viewer REQUIRED)

catkin_package(
INCLUDE_DIRS
include
LIBRARIES
simple_path_sequence_planner
CATKIN_DEPENDS
tool_path_planner
DEPENDS
vtk_viewer
)

Expand All @@ -39,6 +41,7 @@ add_library(simple_path_sequence_planner
target_link_libraries(simple_path_sequence_planner
${catkin_LIBRARIES}
${VTK_LIBRARIES}
noether::vtk_viewer
)

#############
Expand Down
2 changes: 1 addition & 1 deletion path_sequence_planner/test/utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ TEST(IntersectTest, TestCase1)

#ifdef NDEBUG
// release build stuff goes here
LOG4CXX_ERROR(vtk_viewer::VTK_LOGGER,"noether/path_sequence_planner test: visualization is only available in debug mode");
CONSOLE_BRIDGE_logError("noether/path_sequence_planner test: visualization is only available in debug mode");
#else
// Debug-specific code goes here
viz.renderDisplay();
Expand Down
6 changes: 4 additions & 2 deletions tool_path_planner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ find_package(catkin REQUIRED COMPONENTS
rosconsole
roslib
shape_msgs
vtk_viewer
)

find_package(vtk_viewer REQUIRED)

find_package(VTK REQUIRED NO_MODULE)
if(VTK_FOUND AND ("${VTK_VERSION}" VERSION_LESS 7.1))
message(FATAL_ERROR "The minimum required version of VTK is 7.1, but found ${VTK_VERSION}")
Expand Down Expand Up @@ -47,11 +48,11 @@ catkin_package(
noether_msgs
rosconsole
shape_msgs
vtk_viewer
DEPENDS
EIGEN3
PCL
VTK
vtk_viewer
)

include_directories(
Expand All @@ -71,6 +72,7 @@ target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}
${PCL_LIBRARIES}
${VTK_LIBRARIES}
noether::vtk_viewer
)
add_dependencies(${PROJECT_NAME}
${catkin_EXPORTED_TARGETS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include <vtkKdTreePointLocator.h>
#include <vtkCellLocator.h>
#include <vtkModifiedBSPTree.h>
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <vtk_viewer/vtk_viewer.h>
#include "tool_path_planner/tool_path_planner_base.h"

Expand All @@ -39,9 +37,6 @@ namespace tool_path_planner
class RasterToolPathPlanner : public ToolPathPlannerBase
{
public:

static log4cxx::LoggerPtr RASTER_PATH_PLANNER_LOGGER;

/**
* @brief constructor
* @param use_ransac set flag to use ransac plane estimation to determine path normals
Expand Down
Loading