File Exchange

## iLQG/DDP trajectory optimization

version 1.2.0.0 (13.8 KB) by
Solve the deterministic finite-horizon optimal control problem with iLQG/DDP

Updated 14 Oct 2015

View Version History

Solve the deterministic finite-horizon optimal control problem with the iLQG (iterative Linear Quadratic Gaussian) or modified DDP (Differential Dynamic Programming) algorithm. Includes two demos, a linear control-constrained problem and a car-parking problem. For details see
Tassa, Mansard and Todorov, 'Control-Limited Differential Dynamic Programming', ICRA 2014

### Cite As

Yuval (2021). iLQG/DDP trajectory optimization (https://www.mathworks.com/matlabcentral/fileexchange/52069-ilqg-ddp-trajectory-optimization), MATLAB Central File Exchange. Retrieved .

Dongdong Lee

@Mayuran Surendran

I change the part of code to
% dynamics second derivatives
if full_DDP
xu_Jcst = @(xu) finite_difference(xu_dyn, xu);
JJ = finite_difference(xu_Jcst, [x; u]);
JJ = reshape(JJ, [4 6 size(J,2) size(J,3)]);
JJ = 0.5*(JJ + permute(JJ,[1 3 2 4])); %symmetrize
fxx = JJ(:,ix,ix,:);
fxu = JJ(:,ix,iu,:);
fuu = JJ(:,iu,iu,:);
else
[fxx,fxu,fuu] = deal([]);
end

Mayuran Surendran

"You only need to update the follow code where you can easily locate it:
% dynamics second derivatives
N_J = size(J);
if full_DDP
xu_Jcst = @(xu) finite_diff(xu_dyn, xu);
JJ = finite_diff(xu_Jcst, [x; u]);
if length(N_J) <= 2
JJ = reshape(JJ,[4 6 N_J(2)]);
else
JJ = reshape(JJ, [4 6 N_J(2) N_J(3)]);
end"

This does not work for me, anybody has the solution to this problem? Thanks.

Aykut Onol

Yanran Ding

Longsheng Cai

You only need to update the follow code where you can easily locate it:
% dynamics second derivatives
N_J = size(J);
if full_DDP
xu_Jcst = @(xu) finite_diff(xu_dyn, xu);
JJ = finite_diff(xu_Jcst, [x; u]);
if length(N_J) <= 2
JJ = reshape(JJ,[4 6 N_J(2)]);
else
JJ = reshape(JJ, [4 6 N_J(2) N_J(3)]);
end

I am not able to run the demo_car.m example with full_DDP = true;
Then I get an error on line 151 saying that reshaping needs to preserve size.
I've been trying to figure out what would fix the bug but no luck, anyone else?

Chen Yuying

lau

Lingfeng Zhang

Wisdom Agboh

##### MATLAB Release Compatibility
Created with R2011a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux