From 69ffcd8af99465ecfb339c74608e61f385161a7f Mon Sep 17 00:00:00 2001 From: Prajwal Date: Wed, 21 Jun 2023 14:02:53 -0400 Subject: [PATCH 1/5] CMakelists for costing library; Interface class for cost calculator --- .../domain/CMakeLists.txt | 21 +++++++++++++++++++ .../cost_trajectory/i_cost_calculator.hpp | 8 +++++++ 2 files changed, 29 insertions(+) create mode 100644 src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp diff --git a/src/modules/trajectory_generation/domain/CMakeLists.txt b/src/modules/trajectory_generation/domain/CMakeLists.txt index 83c62ee..33c8678 100644 --- a/src/modules/trajectory_generation/domain/CMakeLists.txt +++ b/src/modules/trajectory_generation/domain/CMakeLists.txt @@ -9,20 +9,25 @@ find_package(Eigen3 REQUIRED) set(SPLINE_GENERATION spline_generation) set(TRAJECTORY_GENERATION trajectory_generation) set(GRAPH_GENERATION graph_generation) +set(COST_TRAJECTORY cost_trajectory) # Store all .cpp and .hpp files in a variable file(GLOB spline_cpp_files "${SPLINE_GENERATION}/*.cpp") file(GLOB trajectory_cpp_files "${TRAJECTORY_GENERATION}/*.cpp") file(GLOB graph_cpp_files "${GRAPH_GENERATION}/*.cpp") +file(GLOB cost_cpp_files "${COST_TRAJECTORY}/*.cpp") + file(GLOB spline_hpp_files "${SPLINE_GENERATION}/*.hpp") file(GLOB trajectory_hpp_files "${TRAJECTORY_GENERATION}/*.hpp") file(GLOB graph_hpp_files "${GRAPH_GENERATION}/*.hpp") +file(GLOB cost_hpp_files "${COST_TRAJECTORY}/*.hpp") # Add library add_library(${SPLINE_GENERATION} ${spline_cpp_files}) add_library(${TRAJECTORY_GENERATION} ${trajectory_cpp_files}) add_library(${GRAPH_GENERATION} ${graph_cpp_files}) +add_library(${COST_TRAJECTORY} ${cost_cpp_files}) # Link Dependencies target_link_libraries(${TRAJECTORY_GENERATION} ${SPLINE_GENERATION}) @@ -33,6 +38,7 @@ target_link_libraries(${GRAPH_GENERATION} ${TRAJECTORY_GENERATION}) ament_target_dependencies(${SPLINE_GENERATION} common_domain) ament_target_dependencies(${TRAJECTORY_GENERATION} common_domain) ament_target_dependencies(${GRAPH_GENERATION} common_domain) +ament_target_dependencies(${COST_TRAJECTORY} common_domain) # Export target and also its dependencies so that you don't have to call # find_package() for each of the dependencies @@ -42,6 +48,8 @@ ament_export_targets(${TRAJECTORY_GENERATION}Targets HAS_LIBRARY_TARGET) ament_export_dependencies(common_domain) ament_export_targets(${GRAPH_GENERATION}Targets HAS_LIBRARY_TARGET) ament_export_dependencies(common_domain) +ament_export_targets(${COST_TRAJECTORY}Targets HAS_LIBRARY_TARGET) +ament_export_dependencies(common_domain) # Specify the include directories to enable cmake to build and install target_include_directories(${SPLINE_GENERATION} PUBLIC @@ -56,6 +64,10 @@ target_include_directories(${GRAPH_GENERATION} PUBLIC $ $ # /include/mylib ) +target_include_directories(${COST_TRAJECTORY} PUBLIC + $ + $ # /include/mylib +) # Install all header files to the desired location install( @@ -70,6 +82,10 @@ install( FILES ${graph_hpp_files} DESTINATION include/${GRAPH_GENERATION} ) +install( + FILES ${cost_hpp_files} + DESTINATION include/${COST_TRAJECTORY} +) # Install the library install(TARGETS ${SPLINE_GENERATION} @@ -87,5 +103,10 @@ install(TARGETS ${GRAPH_GENERATION} LIBRARY DESTINATION lib/ INCLUDES DESTINATION include/ ) +install(TARGETS ${COST_TRAJECTORY} + EXPORT ${COST_TRAJECTORY}Targets + LIBRARY DESTINATION lib/ + INCLUDES DESTINATION include/ +) ament_package() \ No newline at end of file diff --git a/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp b/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp new file mode 100644 index 0000000..5094241 --- /dev/null +++ b/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp @@ -0,0 +1,8 @@ + + + + +class ICostCalculator { + public: + virtual double get_cost() const = 0; +}; \ No newline at end of file From 9cf3aedec1100ec4b6ca908ec345315a291958a9 Mon Sep 17 00:00:00 2001 From: Prajwal Date: Wed, 21 Jun 2023 14:07:40 -0400 Subject: [PATCH 2/5] Updated documentation --- .../domain/cost_trajectory/i_cost_calculator.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp b/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp index 5094241..e083ec0 100644 --- a/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp +++ b/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp @@ -4,5 +4,10 @@ class ICostCalculator { public: + /** + * @brief Get the overall cost for an object + * + * @return double + */ virtual double get_cost() const = 0; }; \ No newline at end of file From edf8a76a1bc94d6b3cea31c87da1333167a1ba87 Mon Sep 17 00:00:00 2001 From: Prajwal Date: Wed, 21 Jun 2023 14:23:30 -0400 Subject: [PATCH 3/5] changes to naming convention --- .../domain/CMakeLists.txt | 24 +++++++++---------- .../cost_calculation/i_cost_calculator.hpp | 18 ++++++++++++++ 2 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 src/modules/trajectory_generation/domain/cost_calculation/i_cost_calculator.hpp diff --git a/src/modules/trajectory_generation/domain/CMakeLists.txt b/src/modules/trajectory_generation/domain/CMakeLists.txt index 33c8678..8d63b48 100644 --- a/src/modules/trajectory_generation/domain/CMakeLists.txt +++ b/src/modules/trajectory_generation/domain/CMakeLists.txt @@ -9,25 +9,25 @@ find_package(Eigen3 REQUIRED) set(SPLINE_GENERATION spline_generation) set(TRAJECTORY_GENERATION trajectory_generation) set(GRAPH_GENERATION graph_generation) -set(COST_TRAJECTORY cost_trajectory) +set(COST_CALCULATION COST_CALCULATION) # Store all .cpp and .hpp files in a variable file(GLOB spline_cpp_files "${SPLINE_GENERATION}/*.cpp") file(GLOB trajectory_cpp_files "${TRAJECTORY_GENERATION}/*.cpp") file(GLOB graph_cpp_files "${GRAPH_GENERATION}/*.cpp") -file(GLOB cost_cpp_files "${COST_TRAJECTORY}/*.cpp") +file(GLOB cost_cpp_files "${COST_CALCULATION}/*.cpp") file(GLOB spline_hpp_files "${SPLINE_GENERATION}/*.hpp") file(GLOB trajectory_hpp_files "${TRAJECTORY_GENERATION}/*.hpp") file(GLOB graph_hpp_files "${GRAPH_GENERATION}/*.hpp") -file(GLOB cost_hpp_files "${COST_TRAJECTORY}/*.hpp") +file(GLOB cost_hpp_files "${COST_CALCULATION}/*.hpp") # Add library add_library(${SPLINE_GENERATION} ${spline_cpp_files}) add_library(${TRAJECTORY_GENERATION} ${trajectory_cpp_files}) add_library(${GRAPH_GENERATION} ${graph_cpp_files}) -add_library(${COST_TRAJECTORY} ${cost_cpp_files}) +add_library(${COST_CALCULATION} ${cost_cpp_files}) # Link Dependencies target_link_libraries(${TRAJECTORY_GENERATION} ${SPLINE_GENERATION}) @@ -38,7 +38,7 @@ target_link_libraries(${GRAPH_GENERATION} ${TRAJECTORY_GENERATION}) ament_target_dependencies(${SPLINE_GENERATION} common_domain) ament_target_dependencies(${TRAJECTORY_GENERATION} common_domain) ament_target_dependencies(${GRAPH_GENERATION} common_domain) -ament_target_dependencies(${COST_TRAJECTORY} common_domain) +ament_target_dependencies(${COST_CALCULATION} common_domain) # Export target and also its dependencies so that you don't have to call # find_package() for each of the dependencies @@ -48,7 +48,7 @@ ament_export_targets(${TRAJECTORY_GENERATION}Targets HAS_LIBRARY_TARGET) ament_export_dependencies(common_domain) ament_export_targets(${GRAPH_GENERATION}Targets HAS_LIBRARY_TARGET) ament_export_dependencies(common_domain) -ament_export_targets(${COST_TRAJECTORY}Targets HAS_LIBRARY_TARGET) +ament_export_targets(${COST_CALCULATION}Targets HAS_LIBRARY_TARGET) ament_export_dependencies(common_domain) # Specify the include directories to enable cmake to build and install @@ -64,9 +64,9 @@ target_include_directories(${GRAPH_GENERATION} PUBLIC $ $ # /include/mylib ) -target_include_directories(${COST_TRAJECTORY} PUBLIC - $ - $ # /include/mylib +target_include_directories(${COST_CALCULATION} PUBLIC + $ + $ # /include/mylib ) # Install all header files to the desired location @@ -84,7 +84,7 @@ install( ) install( FILES ${cost_hpp_files} - DESTINATION include/${COST_TRAJECTORY} + DESTINATION include/${COST_CALCULATION} ) # Install the library @@ -103,8 +103,8 @@ install(TARGETS ${GRAPH_GENERATION} LIBRARY DESTINATION lib/ INCLUDES DESTINATION include/ ) -install(TARGETS ${COST_TRAJECTORY} - EXPORT ${COST_TRAJECTORY}Targets +install(TARGETS ${COST_CALCULATION} + EXPORT ${COST_CALCULATION}Targets LIBRARY DESTINATION lib/ INCLUDES DESTINATION include/ ) diff --git a/src/modules/trajectory_generation/domain/cost_calculation/i_cost_calculator.hpp b/src/modules/trajectory_generation/domain/cost_calculation/i_cost_calculator.hpp new file mode 100644 index 0000000..0a982e8 --- /dev/null +++ b/src/modules/trajectory_generation/domain/cost_calculation/i_cost_calculator.hpp @@ -0,0 +1,18 @@ +#ifndef TRAJECTORY_GENERATION__COST_CALCULATION__I_COST_CALCULATOR_HPP +#define TRAJECTORY_GENERATION__COST_CALCULATION__I_COST_CALCULATOR_HPP + + +namespace trajectory_generation::cost_calculation { + + class ICostCalculator { + public: + /** + * @brief Get the overall cost for an object + * + * @return double + */ + virtual double get_cost() const = 0; + }; +} + +#endif /*TRAJECTORY_GENERATION__COST_CALCULATION__I_COST_CALCULATOR_HPP*/ \ No newline at end of file From 3f241f156f72c60bb6582829d11fba0652d8302f Mon Sep 17 00:00:00 2001 From: Prajwal Date: Wed, 21 Jun 2023 14:27:51 -0400 Subject: [PATCH 4/5] minor fix --- .../domain/cost_trajectory/i_cost_calculator.hpp | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp diff --git a/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp b/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp deleted file mode 100644 index e083ec0..0000000 --- a/src/modules/trajectory_generation/domain/cost_trajectory/i_cost_calculator.hpp +++ /dev/null @@ -1,13 +0,0 @@ - - - - -class ICostCalculator { - public: - /** - * @brief Get the overall cost for an object - * - * @return double - */ - virtual double get_cost() const = 0; -}; \ No newline at end of file From 52935f1c509c7892d8d8ed7b12a7b9e64e8af2ff Mon Sep 17 00:00:00 2001 From: Prajwal Date: Wed, 21 Jun 2023 14:59:34 -0400 Subject: [PATCH 5/5] Cmake bug fix --- src/modules/trajectory_generation/domain/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/trajectory_generation/domain/CMakeLists.txt b/src/modules/trajectory_generation/domain/CMakeLists.txt index 8d63b48..a67790c 100644 --- a/src/modules/trajectory_generation/domain/CMakeLists.txt +++ b/src/modules/trajectory_generation/domain/CMakeLists.txt @@ -9,7 +9,7 @@ find_package(Eigen3 REQUIRED) set(SPLINE_GENERATION spline_generation) set(TRAJECTORY_GENERATION trajectory_generation) set(GRAPH_GENERATION graph_generation) -set(COST_CALCULATION COST_CALCULATION) +set(COST_CALCULATION cost_calculation) # Store all .cpp and .hpp files in a variable file(GLOB spline_cpp_files "${SPLINE_GENERATION}/*.cpp")