diff --git a/planning/freespace_planning_algorithms/CMakeLists.txt b/planning/freespace_planning_algorithms/CMakeLists.txt index 1288254ec1d15..3a0f21e3cce78 100644 --- a/planning/freespace_planning_algorithms/CMakeLists.txt +++ b/planning/freespace_planning_algorithms/CMakeLists.txt @@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 3.14) project(freespace_planning_algorithms) find_package(autoware_cmake REQUIRED) +find_package(python_cmake_module REQUIRED) + autoware_package() +ament_python_install_package(${PROJECT_NAME}) ament_auto_add_library(reeds_shepp SHARED src/reeds_shepp.cpp @@ -54,9 +57,9 @@ install(PROGRAMS ) find_package(Python3 REQUIRED COMPONENTS Interpreter Development) -# find_package(pybind11_vendor REQUIRED) -# find_package(pybind11 REQUIRED) -add_subdirectory(pybind11) +find_package(pybind11_vendor REQUIRED) +find_package(pybind11 REQUIRED) +# add_subdirectory(pybind11) pybind11_add_module(freespace_planning_algorithms_python SHARED scripts/module/astar_search_python.cpp @@ -67,4 +70,8 @@ include_directories(freespace_planning_algorithms_python PRIVATE ) target_link_libraries(freespace_planning_algorithms_python PRIVATE freespace_planning_algorithms +) + +install(TARGETS freespace_planning_algorithms_python + DESTINATION "${PYTHON_INSTALL_DIR}/${PROJECT_NAME}" ) \ No newline at end of file diff --git a/planning/freespace_planning_algorithms/freespace_planning_algorithms/__init__.py b/planning/freespace_planning_algorithms/freespace_planning_algorithms/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/planning/freespace_planning_algorithms/package.xml b/planning/freespace_planning_algorithms/package.xml index 372e623e101de..fbabf83e30d38 100644 --- a/planning/freespace_planning_algorithms/package.xml +++ b/planning/freespace_planning_algorithms/package.xml @@ -15,7 +15,8 @@ ament_cmake_auto autoware_cmake - + python_cmake_module + geometry_msgs nav_msgs nlohmann-json-dev diff --git a/planning/freespace_planning_algorithms/scripts/module/astar_search_python.cpp b/planning/freespace_planning_algorithms/scripts/module/astar_search_python.cpp index 3998b5d24b858..c3b7a4f6e1407 100644 --- a/planning/freespace_planning_algorithms/scripts/module/astar_search_python.cpp +++ b/planning/freespace_planning_algorithms/scripts/module/astar_search_python.cpp @@ -8,16 +8,13 @@ using namespace freespace_planning_algorithms; PYBIND11_MODULE(freespace_planning_algorithms_python, p) { - py::class_(p, "AbstractPlanningAlgorithm"); - - py::class_(p, "AstarSearch") - .def(py::init()); - - py::class_(p, "AstarParam", py::dynamic_attr()) + auto pyAstarParam = py::class_(p, "AstarParam", py::dynamic_attr()) + .def(py::init<>()) .def_readwrite("only_behind_solutions", &AstarParam::only_behind_solutions) .def_readwrite("use_back", &AstarParam::use_back) .def_readwrite("distance_heuristic_weight", &AstarParam::distance_heuristic_weight); - py::class_(p, "PlannerCommonParam", py::dynamic_attr()) + auto pyPlannerCommonParam = py::class_(p, "PlannerCommonParam", py::dynamic_attr()) + .def(py::init<>()) .def_readwrite("time_limit", &PlannerCommonParam::time_limit) .def_readwrite("minimum_tuning_radius", &PlannerCommonParam::time_limit) .def_readwrite("maximum_tuning_radius", &PlannerCommonParam::time_limit) @@ -29,10 +26,14 @@ PYBIND11_MODULE(freespace_planning_algorithms_python, p) .def_readwrite("longitudinal_goal_range", &PlannerCommonParam::longitudinal_goal_range) .def_readwrite("angle_goal_range", &PlannerCommonParam::angle_goal_range) .def_readwrite("obstacle_threshold", &PlannerCommonParam::obstacle_threshold); - py::class_(p, "VehicleShape", py::dynamic_attr()) + auto pyVSehicleShape = py::class_(p, "VehicleShape", py::dynamic_attr()) .def(py::init<>()) .def(py::init()) .def_readwrite("length", &VehicleShape::length) .def_readwrite("width", &VehicleShape::width) .def_readwrite("base2back", &VehicleShape::base2back); + + py::class_(p, "AbstractPlanningAlgorithm"); + py::class_(p, "AstarSearch") + .def(py::init()); } diff --git a/planning/freespace_planning_algorithms/scripts/parameter_tuning_tools/test.py b/planning/freespace_planning_algorithms/scripts/parameter_tuning_tools/test.py index 9581717df78ae..94075a2e0a1e1 100644 --- a/planning/freespace_planning_algorithms/scripts/parameter_tuning_tools/test.py +++ b/planning/freespace_planning_algorithms/scripts/parameter_tuning_tools/test.py @@ -1,11 +1,13 @@ import sys -sys.path.append("/home/takumiito/pilot-auto.freespace_param_tuning/build/freespace_planning_algorithms") +# sys.path.append("/home/takumiito/pilot-auto.freespace_param_tuning/build/freespace_planning_algorithms") -import freespace_planning_algorithms_python as fp +import freespace_planning_algorithms.freespace_planning_algorithms_python as fp vehicle_shape = fp.VehicleShape(3, 2, 1) -astar_param = fp.AstarParam -planner_param = fp.PlannerCommonParam +astar_param = fp.AstarParam() +planner_param = fp.PlannerCommonParam() -# astar = fp.AstarSearch(planner_param, vehicle_shape, astar_param) \ No newline at end of file +astar = fp.AstarSearch(planner_param, vehicle_shape, astar_param) + +print(astar) \ No newline at end of file