Skip to content

Commit f5ba105

Browse files
Guard IPDDP rollout helper on empty inputs
Avoid dereferencing empty linearized dynamics arrays in the zero-horizon rollout helper. This keeps IPDDP initialization and helper paths safe when no linearized stages are present.
1 parent 9c9242f commit f5ba105

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/cddp_core/ipddp_solver.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ namespace cddp
276276
std::vector<Eigen::VectorXd> &dX,
277277
std::vector<Eigen::VectorXd> &dU)
278278
{
279+
if (A.empty() || B.empty())
280+
{
281+
const int state_dim = !K.empty() ? K.front().cols() : 0;
282+
dX.assign(1, Eigen::VectorXd::Zero(state_dim));
283+
dU.clear();
284+
return;
285+
}
279286
rolloutLinearPolicy(A, B, d, K, k,
280287
Eigen::VectorXd::Zero(A.front().rows()), dX, dU);
281288
}

0 commit comments

Comments
 (0)