Skip to content

Commit

Permalink
success to initialize AstarSearch instance
Browse files Browse the repository at this point in the history
Signed-off-by: Takumi Ito <[email protected]>
  • Loading branch information
Takumi Ito committed Jan 31, 2024
1 parent b40c161 commit 86f8bc1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
13 changes: 10 additions & 3 deletions planning/freespace_planning_algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}"
)
Empty file.
3 changes: 2 additions & 1 deletion planning/freespace_planning_algorithms/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<buildtool_depend>python_cmake_module</buildtool_depend>

<depend>geometry_msgs</depend>
<depend>nav_msgs</depend>
<depend>nlohmann-json-dev</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ using namespace freespace_planning_algorithms;

PYBIND11_MODULE(freespace_planning_algorithms_python, p)
{
py::class_<AbstractPlanningAlgorithm>(p, "AbstractPlanningAlgorithm");

py::class_<AstarSearch, AbstractPlanningAlgorithm>(p, "AstarSearch")
.def(py::init<PlannerCommonParam &, VehicleShape &, AstarParam &>());

py::class_<AstarParam>(p, "AstarParam", py::dynamic_attr())
auto pyAstarParam = py::class_<AstarParam>(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_<PlannerCommonParam>(p, "PlannerCommonParam", py::dynamic_attr())
auto pyPlannerCommonParam = py::class_<PlannerCommonParam>(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)
Expand All @@ -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_<VehicleShape>(p, "VehicleShape", py::dynamic_attr())
auto pyVSehicleShape = py::class_<VehicleShape>(p, "VehicleShape", py::dynamic_attr())
.def(py::init<>())
.def(py::init<double, double, double>())
.def_readwrite("length", &VehicleShape::length)
.def_readwrite("width", &VehicleShape::width)
.def_readwrite("base2back", &VehicleShape::base2back);

py::class_<AbstractPlanningAlgorithm>(p, "AbstractPlanningAlgorithm");
py::class_<AstarSearch, AbstractPlanningAlgorithm>(p, "AstarSearch")
.def(py::init<PlannerCommonParam &, VehicleShape &, AstarParam &>());
}
Original file line number Diff line number Diff line change
@@ -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)
astar = fp.AstarSearch(planner_param, vehicle_shape, astar_param)

print(astar)

0 comments on commit 86f8bc1

Please sign in to comment.