Skip to content

Commit

Permalink
Revise organization (#84)
Browse files Browse the repository at this point in the history
* Moved samplers, edge/state evaluators into core subdirectory

* Moved ladder graph solver into core directory; moved BGL solvers into separate directory

* Updated build files

* Updated unit test

* Force build with specified c++ version
  • Loading branch information
marip8 authored Sep 13, 2021
1 parent 9c9d0e5 commit 0eeeaf2
Show file tree
Hide file tree
Showing 55 changed files with 107 additions and 181 deletions.
5 changes: 1 addition & 4 deletions descartes_light/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ initialize_code_coverage(ENABLE ${DESCARTES_ENABLE_CODE_COVERAGE})
add_code_coverage_all_targets(ENABLE ${DESCARTES_ENABLE_CODE_COVERAGE})

add_subdirectory(core)
add_subdirectory(edge_evaluators)
add_subdirectory(samplers)
add_subdirectory(solvers)
add_subdirectory(state_evaluators)
add_subdirectory(bgl)

if(DESCARTES_ENABLE_TESTING)
enable_testing()
Expand Down
25 changes: 25 additions & 0 deletions descartes_light/bgl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
find_package(Boost REQUIRED COMPONENTS graph)

add_library(${PROJECT_NAME}_bgl src/bgl_solver.cpp)
target_link_libraries(${PROJECT_NAME}_bgl PUBLIC ${PROJECT_NAME} Boost::graph)
target_cxx_version(${PROJECT_NAME}_bgl PUBLIC VERSION ${DESCARTES_CXX_VERSION})
target_compile_options(${PROJECT_NAME}_bgl PUBLIC ${DESCARTES_COMPILE_OPTIONS})
target_compile_definitions(${PROJECT_NAME}_bgl PUBLIC ${DESCARTES_COMPILE_DEFINITIONS})
target_clang_tidy(
${PROJECT_NAME}_bgl
ENABLE ${DESCARTES_ENABLE_CLANG_TIDY}
WARNINGS_AS_ERRORS ${DESCARTES_ENABLE_TESTING}
CHECKS ${DEFAULT_CLANG_TIDY_CHECKS})
target_code_coverage(${PROJECT_NAME}_bgl ALL ENABLE ${DESCARTES_ENABLE_CODE_COVERAGE})
target_include_directories(${PROJECT_NAME}_bgl PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

install(
TARGETS ${PROJECT_NAME}_bgl
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

# Install headers
install(DIRECTORY include/ DESTINATION include/)
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#ifndef DESCARTES_LIGHT_SOLVERS_BGL_BGL_DFS_SOLVER_H
#define DESCARTES_LIGHT_SOLVERS_BGL_BGL_DFS_SOLVER_H

#include <descartes_light/solvers/bgl/bgl_solver.h>
#include <descartes_light/solvers/bgl/event_visitors.h>
#include <descartes_light/bgl/bgl_solver.h>
#include <descartes_light/bgl/event_visitors.h>

namespace descartes_light
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef DESCARTES_LIGHT_SOLVERS_BGL_BGL_DIJKSTRA_SOLVER_H
#define DESCARTES_LIGHT_SOLVERS_BGL_BGL_DIJKSTRA_SOLVER_H

#include <descartes_light/solvers/bgl/bgl_solver.h>
#include <descartes_light/solvers/bgl/event_visitors.h>
#include <descartes_light/bgl/bgl_solver.h>
#include <descartes_light/bgl/event_visitors.h>

namespace descartes_light
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ DESCARTES_IGNORE_WARNINGS_PUSH
#include <vector>
DESCARTES_IGNORE_WARNINGS_POP

#include <descartes_light/solvers/bgl/boost_graph_types.h>
#include <descartes_light/core/solver.h>
#include <descartes_light/bgl/boost_graph_types.h>

namespace descartes_light
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DESCARTES_LIGHT_SOLVERS_BGL_EVENT_VISITORS
#define DESCARTES_LIGHT_SOLVERS_BGL_EVENT_VISITORS

#include <descartes_light/solvers/bgl/boost_graph_types.h>
#include <descartes_light/bgl/boost_graph_types.h>

#include <descartes_light/descartes_macros.h>
DESCARTES_IGNORE_WARNINGS_PUSH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#ifndef DESCARTES_LIGHT_SOLVERS_BGL_IMPL_DFS_SOLVER_HPP
#define DESCARTES_LIGHT_SOLVERS_BGL_IMPL_DFS_SOLVER_HPP

#include <descartes_light/solvers/bgl/bgl_dfs_solver.h>
#include <descartes_light/solvers/bgl/impl/event_visitors.hpp>
#include <descartes_light/bgl/bgl_dfs_solver.h>
#include <descartes_light/bgl/impl/event_visitors.hpp>

#include <descartes_light/descartes_macros.h>
DESCARTES_IGNORE_WARNINGS_PUSH
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef DESCARTES_LIGHT_SOLVERS_BGL_IMPL_BGL_DIJKSTRA_SOLVER_HPP
#define DESCARTES_LIGHT_SOLVERS_BGL_IMPL_BGL_DIJKSTRA_SOLVER_HPP

#include <descartes_light/solvers/bgl/bgl_dijkstra_solver.h>
#include <descartes_light/solvers/bgl/impl/event_visitors.hpp>
#include <descartes_light/bgl/bgl_dijkstra_solver.h>
#include <descartes_light/bgl/impl/event_visitors.hpp>

#include <descartes_light/descartes_macros.h>
DESCARTES_IGNORE_WARNINGS_PUSH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ DESCARTES_IGNORE_WARNINGS_PUSH
#include <omp.h>
DESCARTES_IGNORE_WARNINGS_POP

#include <descartes_light/solvers/bgl/bgl_solver.h>
#include <descartes_light/solvers/bgl/utils.h>
#include <descartes_light/bgl/bgl_solver.h>
#include <descartes_light/bgl/utils.h>
#include <descartes_light/types.h>

#define UNUSED(x) (void)(x)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DESCARTES_LIGHT_SOLVERS_BGL_IMPL_EVENT_VISITORS_HPP
#define DESCARTES_LIGHT_SOLVERS_BGL_IMPL_EVENT_VISITORS_HPP

#include <descartes_light/solvers/bgl/event_visitors.h>
#include <descartes_light/bgl/event_visitors.h>

namespace descartes_light
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DESCARTES_IGNORE_WARNINGS_PUSH
#include <fstream>
DESCARTES_IGNORE_WARNINGS_POP

#include <descartes_light/solvers/bgl/utils.h>
#include <descartes_light/bgl/utils.h>

namespace descartes_light
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <descartes_light/solvers/bgl/boost_graph_types.h>
#include <descartes_light/bgl/boost_graph_types.h>

namespace descartes_light
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <descartes_light/solvers/bgl/impl/bgl_solver.hpp>
#include <descartes_light/solvers/bgl/impl/bgl_dijkstra_solver.hpp>
#include <descartes_light/solvers/bgl/impl/bgl_dfs_solver.hpp>
#include <descartes_light/solvers/bgl/impl/utils.hpp>
#include <descartes_light/bgl/impl/bgl_solver.hpp>
#include <descartes_light/bgl/impl/bgl_dijkstra_solver.hpp>
#include <descartes_light/bgl/impl/bgl_dfs_solver.hpp>
#include <descartes_light/bgl/impl/utils.hpp>

#include <descartes_light/descartes_macros.h>
DESCARTES_IGNORE_WARNINGS_PUSH
Expand Down
1 change: 1 addition & 0 deletions descartes_light/cmake/descartes_light_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ macro(descartes_variables)
endif()
endif()

set(CXX_STANDARD_REQUIRED ON)
set(DESCARTES_CXX_VERSION 14)
endmacro()
62 changes: 50 additions & 12 deletions descartes_light/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,74 @@
# Find dependency packages
find_package(Eigen3 REQUIRED)
find_package(ros_industrial_cmake_boilerplate REQUIRED)
find_package(OpenMP REQUIRED)
find_package(console_bridge)

# Create targets if necessary
if(NOT TARGET OpenMP::OpenMP_CXX)
find_package(Threads REQUIRED)
add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE)
set_property(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_COMPILE_OPTIONS ${OpenMP_CXX_FLAGS})
# Only works if the same flag is passed to the linker; use CMake 3.9+ otherwise (Intel, AppleClang)
set_property(TARGET OpenMP::OpenMP_CXX PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS} Threads::Threads)
endif()

if(NOT TARGET console_bridge::console_bridge)
add_library(console_bridge::console_bridge INTERFACE IMPORTED)
set_target_properties(console_bridge::console_bridge PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${console_bridge_INCLUDE_DIRS})
set_target_properties(console_bridge::console_bridge PROPERTIES INTERFACE_LINK_LIBRARIES ${console_bridge_LIBRARIES})
else()
get_target_property(CHECK_INCLUDE_DIRECTORIES console_bridge::console_bridge INTERFACE_INCLUDE_DIRECTORIES)
if(NOT ${CHECK_INCLUDE_DIRECTORIES})
set_target_properties(console_bridge::console_bridge PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${console_bridge_INCLUDE_DIRS})
endif()
endif()

if(NOT TARGET Eigen3::Eigen)
find_package(Threads REQUIRED)
add_library(Eigen3::Eigen IMPORTED INTERFACE)
set_property(TARGET Eigen3::Eigen PROPERTY INTERFACE_COMPILE_DEFINITIONS ${EIGEN3_DEFINITIONS})
set_property(TARGET Eigen3::Eigen PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${EIGEN3_INCLUDE_DIRS})
endif()

# Interface Library
add_library(${PROJECT_NAME}_core INTERFACE)
target_link_libraries(${PROJECT_NAME}_core INTERFACE Eigen3::Eigen)
target_cxx_version(${PROJECT_NAME}_core INTERFACE VERSION ${DESCARTES_CXX_VERSION})
target_compile_options(${PROJECT_NAME}_core INTERFACE ${DESCARTES_COMPILE_OPTIONS})
target_compile_definitions(${PROJECT_NAME}_core INTERFACE ${DESCARTES_COMPILE_DEFINITIONS})
add_library(
${PROJECT_NAME}
# Edge Evaluators
src/edge_evaluators/timing_edge_evaluator.cpp
src/edge_evaluators/euclidean_distance_edge_evaluator.cpp
src/edge_evaluators/compound_edge_evaluator.cpp
src/edge_evaluators/normalized_edge_evaluator.cpp
# State Evaluators
src/state_evaluators/euclidean_distance_state_evaluator.cpp
src/state_evaluators/normalized_state_evaluator.cpp
# Samplers
src/samplers/fixed_joint_pose_sampler.cpp
# Solvers
src/solvers/ladder_graph/ladder_graph_solver.cpp
src/solvers/ladder_graph/ladder_graph.cpp
src/solvers/ladder_graph/ladder_graph_dag_search.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen OpenMP::OpenMP_CXX console_bridge::console_bridge)
target_cxx_version(${PROJECT_NAME} PUBLIC VERSION ${DESCARTES_CXX_VERSION})
target_compile_options(${PROJECT_NAME} PUBLIC -std=c++${DESCARTES_CXX_VERSION})
target_compile_options(${PROJECT_NAME} PUBLIC ${DESCARTES_COMPILE_OPTIONS})
target_compile_definitions(${PROJECT_NAME} PUBLIC ${DESCARTES_COMPILE_DEFINITIONS})
target_clang_tidy(
${PROJECT_NAME}_core
${PROJECT_NAME}
ENABLE ${DESCARTES_ENABLE_CLANG_TIDY}
WARNINGS_AS_ERRORS ${DESCARTES_ENABLE_TESTING}
CHECKS ${DEFAULT_CLANG_TIDY_CHECKS})
target_code_coverage(
${PROJECT_NAME}_core
INTERFACE
${PROJECT_NAME}
PUBLIC
ALL
ENABLE ${DESCARTES_ENABLE_TESTING})
target_include_directories(${PROJECT_NAME}_core INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

install(
TARGETS ${PROJECT_NAME}_core
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
Expand Down
29 changes: 0 additions & 29 deletions descartes_light/edge_evaluators/CMakeLists.txt

This file was deleted.

23 changes: 0 additions & 23 deletions descartes_light/samplers/CMakeLists.txt

This file was deleted.

58 changes: 0 additions & 58 deletions descartes_light/solvers/CMakeLists.txt

This file was deleted.

25 changes: 0 additions & 25 deletions descartes_light/state_evaluators/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 0eeeaf2

Please sign in to comment.