Skip to content

Commit 0fa9842

Browse files
Fix package exports and Python binding ownership
This updates the installed CMake and Python package layouts so downstream consumers can find cddp headers and import pycddp after install. It also replaces the unsafe raw-pointer Python ownership handoff with Python-backed solver adapters, acquires the GIL for Python callbacks, and removes the legacy Matplot-driven build surface from the default configuration.
1 parent 277d523 commit 0fa9842

18 files changed

Lines changed: 649 additions & 510 deletions

CMakeLists.txt

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ project(
2525
HOMEPAGE_URL "https://github.com/astomodynamics/cddp-cpp"
2626
)
2727

28+
include(GNUInstallDirs)
29+
2830
set(CMAKE_CXX_STANDARD 17) # Enforce C++17 as the minimum standard
2931
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enforce C++17 as the minimum standard
3032
set(ABSL_PROPAGATE_CXX_STD ON) # Enforce C++17 for absl
@@ -44,7 +46,6 @@ endif()
4446
# Options
4547
option(CDDP_CPP_BUILD_TESTS "Whether to build tests." ON)
4648
option(CDDP_CPP_BUILD_EXAMPLES "Whether to build examples." ON)
47-
option(CDDP_CPP_ENABLE_PLOTTING "Enable matplotplusplus for visualization." ON)
4849

4950
# CasADi Configuration
5051
option(CDDP_CPP_CASADI "Whether to use CasADi" OFF)
@@ -94,18 +95,6 @@ endif()
9495
# Enable FetchContent for downloading dependencies
9596
include(FetchContent)
9697

97-
# Matplotplusplus (optional)
98-
if(CDDP_CPP_ENABLE_PLOTTING)
99-
FetchContent_Declare(matplotplusplus
100-
GIT_REPOSITORY https://github.com/alandefreitas/matplotplusplus
101-
GIT_TAG origin/master)
102-
FetchContent_GetProperties(matplotplusplus)
103-
if(NOT matplotplusplus_POPULATED)
104-
FetchContent_Populate(matplotplusplus)
105-
add_subdirectory(${matplotplusplus_SOURCE_DIR} ${matplotplusplus_BINARY_DIR} EXCLUDE_FROM_ALL)
106-
endif()
107-
endif()
108-
10998
# autodiff
11099
set(AUTODIFF_BUILD_TESTS OFF CACHE BOOL "Don't build autodiff tests")
111100
set(AUTODIFF_BUILD_EXAMPLES OFF CACHE BOOL "Don't build autodiff examples")
@@ -190,18 +179,13 @@ target_link_libraries(${PROJECT_NAME}
190179
autodiff
191180
)
192181

193-
if(CDDP_CPP_ENABLE_PLOTTING)
194-
target_link_libraries(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:matplot>)
195-
target_compile_definitions(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:CDDP_HAS_MATPLOT>)
196-
endif()
197-
198182
if(NOT Eigen3_FOUND)
199183
target_include_directories(${PROJECT_NAME} PUBLIC ${EIGEN3_INCLUDE_DIRS})
200184
endif()
201185

202186
target_include_directories(${PROJECT_NAME} PUBLIC
203187
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/cddp-cpp>
204-
$<INSTALL_INTERFACE:include>
188+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cddp-cpp>
205189
)
206190

207191
if (CDDP_CPP_CASADI)
@@ -281,7 +265,6 @@ if(CDDP_CPP_BUILD_PYTHON)
281265
endif()
282266

283267
# Install targets
284-
include(GNUInstallDirs)
285268
include(CMakePackageConfigHelpers)
286269

287270
install(TARGETS ${PROJECT_NAME}

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
99
curl \
1010
git \
1111
wget \
12-
libjpeg-dev \
13-
libpng-dev \
14-
gnuplot \
1512
libeigen3-dev && \
1613
rm -rf /var/lib/apt/lists/*
1714

README.md

Lines changed: 7 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -29,119 +29,15 @@ $$
2929
$$
3030

3131
## Examples
32-
### Unicycle
33-
34-
Simple car-like robot with velocity and steering control:
35-
36-
```bash
37-
./examples/cddp_unicycle // after building
38-
```
39-
40-
<img src="results/tests/unicycle.gif" width="300" alt="Unicycle Model CDDP">
41-
42-
### Unicycle with Obstacle Avoidance
43-
44-
Simple car-like robot with velocity and steering control:
45-
46-
```bash
47-
./examples/cddp_unicycle_safe // after building
48-
```
49-
50-
<img src="results/tests/unicycle_trajectory_comparison.png" width="300" alt="Unicycle Model CDDP with Obstacle Avoidance">
51-
52-
### Unicycle with Obstacle Avoidance (infeasible initial guess)
53-
54-
```bash
55-
./examples/cddp_unicycle_safe_ipddp // after building
56-
```
57-
58-
<img src="results/tests/trajectory_comparison_ipddp.png" width="300" alt="Unicycle Model CDDP with Obstacle Avoidance">
59-
60-
### Bicycle Model
61-
62-
Bicycle model with velocity and steering control:
32+
The default C++ build currently includes a barrier-strategy comparison example:
6333

6434
```bash
65-
./examples/cddp_bicycle // after building
35+
./examples/test_barrier_strategies
6636
```
6737

68-
<img src="results/tests/bicycle.gif" width="300" alt="Bicycle Model CDDP">
69-
70-
### Control-limited Car
71-
72-
Car model with limited velocity and steering control:
73-
74-
```bash
75-
./examples/cddp_car // after building
76-
```
77-
78-
<img src="results/tests/car_parking.gif" width="300" alt="Car Model CDDP">
79-
80-
```bash
81-
./examples/cddp_car_ipddp // after building
82-
```
83-
84-
<img src="results/tests/car_parking_ipddp.gif" width="300" alt="Car Model CDDP">
85-
86-
### Pendulum
87-
88-
Simple pendulum with torque control:
89-
90-
```bash
91-
./examples/cddp_pendulum // after building
92-
```
93-
94-
95-
<img src="results/tests/pendulum.gif" width="300" alt="Pendulum CDDP">
96-
97-
### Cartpole
98-
99-
Cartpole with cart control:
100-
101-
```bash
102-
./examples/cddp_cartpole // after building
103-
```
104-
105-
<img src="results/tests/cartpole.gif" width="300" alt="Cartpole CDDP">
106-
<img src="results/tests/cartpole_results.png" width="300" alt="Cartpole CDDP">
107-
108-
109-
### Quadrotor
110-
111-
Quadrotor with thrust control:
112-
113-
```bash
114-
./examples/cddp_quadrotor_point // after building
115-
```
116-
117-
<img src="results/tests/quadrotor.gif" width="300" alt="Quadrotor CDDP">
118-
119-
```bash
120-
./examples/cddp_quadrotor_circle // after building
121-
```
122-
123-
<img src="results/tests/quadrotor_circle.gif" width="300" alt="Quadrotor CDDP">
124-
125-
126-
```bash
127-
./examples/cddp_quadrotor_figure_eight_horizontal // after building
128-
```
129-
<img src="results/tests/quadrotor_figure_eight_horizontal.gif" width="300" alt="Quadrotor CDDP">
130-
131-
```bash
132-
./examples/cddp_quadrotor_figure_eight_vertical // after building
133-
```
134-
<img src="results/tests/quadrotor_figure_eight_vertical.gif" width="300" alt="Quadrotor CDDP">
135-
136-
### Manipulator
137-
138-
Manipulator with joint torque control:
139-
140-
```bash
141-
./examples/cddp_manipulator // after building
142-
```
143-
144-
<img src="results/tests/manipulator.gif" width="300" alt="Manipulator CDDP">
38+
Legacy visualization-heavy C++ examples remain in the repository as reference
39+
material, but they are no longer part of the default build. Python bindings are
40+
the supported plotting and notebook workflow.
14541

14642
## Installation
14743
### Dependencies
@@ -157,18 +53,6 @@ sudo apt-get install libeigen3-dev # For Ubuntu
15753
brew install eigen # For macOS
15854
```
15955

160-
* [gnuplot](http://www.gnuplot.info/) (Plotting Library)
161-
```bash
162-
sudo apt-get install gnuplot # For Ubuntu
163-
brew install gnuplot # For macOS
164-
```
165-
* [imagemagick](https://imagemagick.org/) (Image Processing Library)
166-
```bash
167-
sudo apt-get install imagemagick # For Ubuntu
168-
brew install imagemagick # For macOS
169-
```
170-
171-
17256
### Building
17357
```bash
17458
git clone -b v0.3.2 https://github.com/astomodynamics/cddp-cpp
@@ -192,7 +76,6 @@ If you want to use this library for ROS2 MPC node, please refer [CDDP MPC Packag
19276

19377
This library uses the following open-source libraries as core dependencies:
19478

195-
* [matplotplusplus](https://github.com/alandefreitas/matplotplusplus) (MIT License)
19679
* [autodiff](https://github.com/autodiff/autodiff) (MIT License)
19780

19881
This library also uses the following open-source libraries for optional features:
@@ -221,9 +104,9 @@ If you'd like to contribute:
221104
If you have ideas for collaboration, want to discuss potential research applications, or have any questions, please feel free to open an issue on GitHub or reach out to the @astomodynamics. We are particularly interested in exploring its use in novel robotic systems and complex motion planning scenarios.
222105

223106
## TODO
224-
* add **python binding**
107+
* improve python binding ergonomics
225108
* improve parallelization
226-
* add simulation and its plots
109+
* add simulation examples and Python visualizations
227110
* Quadruped robot
228111
* Manipulator
229112
* Humanoid

cmake/cddpConfig.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
include(CMakeFindDependencyMacro)
44
find_dependency(Eigen3)
5+
find_dependency(autodiff)
56

67
include("${CMAKE_CURRENT_LIST_DIR}/cddpTargets.cmake")
78
check_required_components(cddp)

examples/CMakeLists.txt

Lines changed: 4 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -13,111 +13,10 @@
1313
# limitations under the License.
1414

1515
# CMakeLists.txt for the CDDP examples
16+
#
17+
# The legacy visualization-heavy C++ examples are kept in the repository as
18+
# reference material, but they no longer participate in the default build.
19+
# Python bindings are the supported plotting workflow going forward.
1620

1721
add_executable(test_barrier_strategies test_barrier_strategies.cpp)
1822
target_link_libraries(test_barrier_strategies cddp)
19-
20-
add_executable(cddp_bicycle cddp_bicycle.cpp)
21-
target_link_libraries(cddp_bicycle cddp)
22-
23-
add_executable(cddp_car cddp_car.cpp)
24-
target_link_libraries(cddp_car cddp)
25-
26-
add_executable(cddp_car_ipddp cddp_car_ipddp.cpp)
27-
target_link_libraries(cddp_car_ipddp cddp)
28-
29-
add_executable(cddp_forklift_ipddp cddp_forklift_ipddp.cpp)
30-
target_link_libraries(cddp_forklift_ipddp cddp)
31-
32-
add_executable(cddp_cartpole cddp_cartpole.cpp)
33-
target_link_libraries(cddp_cartpole cddp)
34-
35-
add_executable(cddp_hcw cddp_hcw.cpp)
36-
target_link_libraries(cddp_hcw cddp)
37-
38-
add_executable(cddp_lti_system cddp_lti_system.cpp)
39-
target_link_libraries(cddp_lti_system cddp)
40-
41-
add_executable(cddp_manipulator cddp_manipulator.cpp)
42-
target_link_libraries(cddp_manipulator cddp)
43-
44-
add_executable(cddp_pendulum cddp_pendulum.cpp)
45-
target_link_libraries(cddp_pendulum cddp)
46-
47-
add_executable(cddp_acrobot cddp_acrobot.cpp)
48-
target_link_libraries(cddp_acrobot cddp)
49-
50-
add_executable(cddp_quadrotor_circle cddp_quadrotor_circle.cpp)
51-
target_link_libraries(cddp_quadrotor_circle cddp)
52-
53-
add_executable(cddp_quadrotor_figure_eight_horizontal cddp_quadrotor_figure_eight_horizontal.cpp)
54-
target_link_libraries(cddp_quadrotor_figure_eight_horizontal cddp)
55-
56-
add_executable(cddp_quadrotor_figure_eight_vertical cddp_quadrotor_figure_eight_vertical.cpp)
57-
target_link_libraries(cddp_quadrotor_figure_eight_vertical cddp)
58-
59-
add_executable(cddp_quadrotor_point cddp_quadrotor_point.cpp)
60-
target_link_libraries(cddp_quadrotor_point cddp)
61-
62-
add_executable(cddp_quadrotor_figure_eight_horizontal_safe cddp_quadrotor_figure_eight_horizontal_safe.cpp)
63-
target_link_libraries(cddp_quadrotor_figure_eight_horizontal_safe cddp)
64-
65-
add_executable(cddp_unicycle cddp_unicycle.cpp)
66-
target_link_libraries(cddp_unicycle cddp)
67-
68-
add_executable(cddp_unicycle_safe cddp_unicycle_safe.cpp)
69-
target_link_libraries(cddp_unicycle_safe cddp)
70-
71-
add_executable(cddp_unicycle_safe_ipddp cddp_unicycle_safe_ipddp.cpp)
72-
target_link_libraries(cddp_unicycle_safe_ipddp cddp)
73-
74-
add_executable(cddp_unicycle_safe_ipddp_v2 cddp_unicycle_safe_ipddp_v2.cpp)
75-
target_link_libraries(cddp_unicycle_safe_ipddp_v2 cddp)
76-
77-
add_executable(cddp_unicycle_safe_ipddp_v3 cddp_unicycle_safe_ipddp_v3.cpp)
78-
target_link_libraries(cddp_unicycle_safe_ipddp_v3 cddp)
79-
80-
add_executable(cddp_spacecraft_linear_docking cddp_spacecraft_linear_docking.cpp)
81-
target_link_libraries(cddp_spacecraft_linear_docking cddp)
82-
83-
add_executable(cddp_spacecraft_linear_rpo cddp_spacecraft_linear_rpo.cpp)
84-
target_link_libraries(cddp_spacecraft_linear_rpo cddp)
85-
86-
add_executable(cddp_spacecraft_nonlinear_rpo cddp_spacecraft_nonlinear_rpo.cpp)
87-
target_link_libraries(cddp_spacecraft_nonlinear_rpo cddp)
88-
89-
add_executable(cddp_spacecraft_rpo cddp_spacecraft_rpo.cpp)
90-
target_link_libraries(cddp_spacecraft_rpo cddp)
91-
92-
add_executable(cddp_spacecraft_rpo_mc cddp_spacecraft_rpo_mc.cpp)
93-
target_link_libraries(cddp_spacecraft_rpo_mc cddp)
94-
95-
add_executable(cddp_spacecraft_rpo_fuel cddp_spacecraft_rpo_fuel.cpp)
96-
target_link_libraries(cddp_spacecraft_rpo_fuel cddp)
97-
98-
add_executable(cddp_spacecraft_roe_rpo cddp_spacecraft_roe_rpo.cpp)
99-
target_link_libraries(cddp_spacecraft_roe_rpo cddp)
100-
101-
add_executable(mpc_hcw mpc_hcw.cpp)
102-
target_link_libraries(mpc_hcw cddp)
103-
104-
add_executable(cddp_unicycle_mpc cddp_unicycle_mpc.cpp)
105-
target_link_libraries(cddp_unicycle_mpc cddp)
106-
107-
# Ipopt examples
108-
if (CDDP_CPP_CASADI)
109-
add_executable(ipopt_car ipopt_car.cpp)
110-
target_link_libraries(ipopt_car cddp)
111-
112-
add_executable(ipopt_unicycle ipopt_unicycle.cpp)
113-
target_link_libraries(ipopt_unicycle cddp)
114-
115-
add_executable(ipopt_cartpole ipopt_cartpole.cpp)
116-
target_link_libraries(ipopt_cartpole cddp)
117-
118-
add_executable(ipopt_quadrotor ipopt_quadrotor.cpp)
119-
target_link_libraries(ipopt_quadrotor cddp)
120-
121-
add_executable(ipopt_spacecrat_linear_fuel ipopt_spacecrat_linear_fuel.cpp)
122-
target_link_libraries(ipopt_spacecrat_linear_fuel cddp)
123-
endif()

include/cddp-cpp/cddp.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,4 @@
5757
#include "dynamics_model/quaternion_attitude.hpp"
5858
#include "dynamics_model/mrp_attitude.hpp"
5959

60-
#ifdef CDDP_HAS_MATPLOT
61-
#include "matplot/matplot.h"
62-
#endif
63-
6460
#endif // CDDP_HPP

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ viz = ["matplotlib>=3.5"]
1919
dev = ["pytest>=7.0", "matplotlib>=3.5"]
2020

2121
[tool.scikit-build]
22-
cmake.args = ["-DCDDP_CPP_BUILD_PYTHON=ON", "-DCDDP_CPP_BUILD_TESTS=OFF", "-DCDDP_CPP_BUILD_EXAMPLES=OFF", "-DCDDP_CPP_ENABLE_PLOTTING=OFF"]
22+
cmake.args = ["-DCDDP_CPP_BUILD_PYTHON=ON", "-DCDDP_CPP_BUILD_TESTS=OFF", "-DCDDP_CPP_BUILD_EXAMPLES=OFF"]
2323
wheel.packages = ["python/pycddp"]

python/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
2+
13
find_package(pybind11 CONFIG QUIET)
24
if(NOT pybind11_FOUND)
35
message(STATUS "pybind11 not found, fetching...")
@@ -23,4 +25,14 @@ target_include_directories(_pycddp_core PRIVATE
2325
${CMAKE_SOURCE_DIR}/include/cddp-cpp
2426
)
2527

26-
install(TARGETS _pycddp_core DESTINATION pycddp)
28+
set(PYCDDP_INSTALL_DIR
29+
"${CMAKE_INSTALL_LIBDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/pycddp"
30+
)
31+
32+
install(TARGETS _pycddp_core DESTINATION "${PYCDDP_INSTALL_DIR}")
33+
install(
34+
FILES
35+
${CMAKE_CURRENT_SOURCE_DIR}/pycddp/__init__.py
36+
${CMAKE_CURRENT_SOURCE_DIR}/pycddp/_version.py
37+
DESTINATION "${PYCDDP_INSTALL_DIR}"
38+
)

0 commit comments

Comments
 (0)