Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance CDDP with barrier and constraint improvements #63

Merged
merged 23 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
430388e
update constraint header
astomodynamics Dec 26, 2024
f8cc0e2
update cddp header
astomodynamics Dec 26, 2024
4938ca9
Create barrier header
astomodynamics Dec 26, 2024
7a22f46
remove barrier from constraint object
astomodynamics Dec 26, 2024
239bc52
add barrier to cmake
astomodynamics Dec 26, 2024
a5869d6
Test control-limited log ddp
astomodynamics Dec 26, 2024
e5ee80d
Add ipopt_car example for comparison
astomodynamics Dec 26, 2024
1340b80
Update ipopt_car.cpp
astomodynamics Dec 26, 2024
1ab893e
Test control-limited log ddp
astomodynamics Dec 26, 2024
5eab204
Organize solver options (solver is selectable by string)
astomodynamics Dec 26, 2024
b43ad6e
Add clddp solver to cmake
astomodynamics Dec 26, 2024
061d241
Add computeViolation to constraint.hpp
astomodynamics Dec 26, 2024
27f3f5d
Add unit test for StateBoxConstraint evaluation
astomodynamics Dec 26, 2024
4c59c1e
Update CDDP options and change solver method in cddp_dubins_car example
astomodynamics Dec 26, 2024
682c11e
Add computeViolationFromValue method to constraint interface
astomodynamics Dec 26, 2024
0e04010
Update CDDP options and enhance iteration logging with constraint vio…
astomodynamics Dec 26, 2024
e9ed96b
Enhance CDDP options with filter acceptance and constraint tolerance;…
astomodynamics Dec 26, 2024
89bacee
Update CDDP options with adjusted regularization parameters and enhan…
astomodynamics Dec 26, 2024
645c214
Add early termination option to CDDP options and update solver checks
astomodynamics Dec 26, 2024
a32f52b
Implement early termination logic in CDDP solvers based on regulariza…
astomodynamics Dec 26, 2024
03bcfc6
Initialize constraint violation tracking in CDDP solver
astomodynamics Dec 26, 2024
86484c1
Enhance CDDP solver with ball constraint support and improve regulari…
astomodynamics Dec 27, 2024
09afbc1
Comment out plotting code in CDDP test to streamline output and focus…
astomodynamics Dec 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ set(cddp_core_srcs
src/cddp_core/dynamical_system.cpp
src/cddp_core/objective.cpp
src/cddp_core/constraint.cpp
src/cddp_core/barrier.cpp
src/cddp_core/helper.cpp
src/cddp_core/boxqp.cpp
src/cddp_core/qp_solver.cpp
src/cddp_core/cddp_core.cpp
src/cddp_core/clddp_core.cpp
src/cddp_core/asddp_core.cpp
src/cddp_core/logddp_core.cpp
src/cddp_core/neural_dynamical_system.cpp
Expand Down
9 changes: 7 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

# CMakeLists.txt for the CDDP examples

add_executable(cddp_bicycle cddp_bicycle.cpp)
target_link_libraries(cddp_bicycle cddp)

Expand All @@ -38,7 +37,13 @@ target_link_libraries(cddp_pendulum cddp)
add_executable(cddp_quadrotor cddp_quadrotor.cpp)
target_link_libraries(cddp_quadrotor cddp)

# Neural dynamics example
# Ipopt examples
if (CDDP_CPP_CASADI)
add_executable(ipopt_car ipopt_car.cpp)
target_link_libraries(ipopt_car cddp)
endif()

# Neural dynamics examples
add_executable(prepare_pendulum neural_dynamics/prepare_pendulum.cpp)
target_link_libraries(prepare_pendulum cddp)

Expand Down
33 changes: 24 additions & 9 deletions examples/cddp_car.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ int main() {
Animation::AnimationConfig config;
config.width = 800;
config.height = 800;
config.frame_skip = 5; // Save every 5th frame
config.frame_delay = 10; // 10/100 = 0.1 seconds between frames
config.frame_skip = 5;
config.frame_delay = 10;
Animation animation(config);

// Problem parameters
int state_dim = 4; // [x y theta v]
int control_dim = 2; // [wheel_angle acceleration]
int horizon = 500; // Same as MATLAB example
double timestep = 0.03; // h = 0.03 from MATLAB
int horizon = 500;
double timestep = 0.03;
std::string integration_type = "euler";

// Random number generator setup
Expand All @@ -152,13 +152,13 @@ int main() {
std::normal_distribution<double> d(0.0, 0.1);

// Create car instance
double wheelbase = 2.0; // d = 2.0 from MATLAB example
double wheelbase = 2.0;
std::unique_ptr<cddp::DynamicalSystem> system =
std::make_unique<cddp::Car>(timestep, wheelbase, integration_type);

// Initial and goal states
Eigen::VectorXd initial_state(state_dim);
initial_state << 1.0, 1.0, 1.5*M_PI, 0.0; // [1; 1; pi*3/2; 0] from MATLAB
initial_state << 1.0, 1.0, 1.5*M_PI, 0.0;

Eigen::VectorXd goal_state(state_dim);
goal_state << 0.0, 0.0, 0.0, 0.0; // NOT USED IN THIS EXAMPLE
Expand Down Expand Up @@ -189,7 +189,7 @@ int main() {
options.grad_tolerance = 1e-4;
options.regularization_type = "control";
// options.regularization_control = 1.0;
options.debug = true;
options.debug = false;
options.use_parallel = true;
options.num_threads = 10;
cddp_solver.setOptions(options);
Expand Down Expand Up @@ -225,8 +225,23 @@ int main() {

// Solve the problem
cddp::CDDPSolution solution = cddp_solver.solve();
// cddp::CDDPSolution solution = cddp_solver.solveCLDDP();
// cddp::CDDPSolution solution = cddp_solver.solveLogCDDP();
// ========================================
// CDDP Solution
// ========================================
// Converged: Yes
// Iterations: 157
// Solve Time: 5.507e+05 micro sec
// Final Cost: 1.90517
// ========================================
// cddp::CDDPSolution solution = cddp_solver.solveLogCDDP();
// ========================================
// CDDP Solution
// ========================================
// Converged: Yes
// Iterations: 153
// Solve Time: 5.441e+05 micro sec
// Final Cost: 1.90517
// ========================================

// Extract solution trajectories
auto X_sol = solution.state_sequence;
Expand Down
5 changes: 4 additions & 1 deletion examples/cddp_dubins_car.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ int main() {
// Set options
cddp::CDDPOptions options;
options.max_iterations = 10;
options.barrier_coeff = 1e-2;
options.barrier_factor = 0.1;
cddp_solver.setOptions(options);

// Set initial trajectory
Expand All @@ -78,7 +80,8 @@ int main() {
cddp_solver.setInitialTrajectory(X, U);

// Solve the problem
cddp::CDDPSolution solution = cddp_solver.solve();
// cddp::CDDPSolution solution = cddp_solver.solve("CLCDDP");
cddp::CDDPSolution solution = cddp_solver.solve("LogCDDP");

// Extract solution
auto X_sol = solution.state_sequence; // size: horizon + 1
Expand Down
Loading
Loading