Skip to content

Commit a929d5d

Browse files
committed
Fix state dim methods
1 parent 2f16918 commit a929d5d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/constraint_list.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ Base.zip(cons::ConstraintList) = zip(cons.inds, cons.constraints)
149149
@inline Base.getindex(cons::ConstraintList, i::Int) = cons.constraints[i]
150150
Base.getindex(cons::ConstraintList, I) = cons.constraints[I]
151151

152+
RD.state_dim(cons::ConstraintList, k) = cons.nx[k]
153+
RD.control_dim(cons::ConstraintList, k) = cons.nu[k]
154+
152155
"""
153156
functionsignature(::ConstraintList, i)
154157

src/problem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ of the trajectory, `N`.
146146
"""
147147
RD.dims(prob::Problem, i::Integer) = RD.dims(prob.model[i])..., prob.N
148148

149-
RD.state_dim(prob::Problem, k::Integer) = state_dim(prob.model[k])
149+
RD.state_dim(prob::Problem, k::Integer) = state_dim(prob.model[min(k, prob.N-1)])
150150
RD.control_dim(prob::Problem, k::Integer) = control_dim(prob.model[k])
151151

152152
"""
@@ -213,7 +213,7 @@ Returns Vector{`RobotDynamics.DiscreteDynamics`}.
213213
214214
Get the dynamics model at time step `k`.
215215
"""
216-
@inline get_model(prob::Problem, k) = prob.model[k]
216+
@inline get_model(prob::Problem, k) = prob.model[min(k,prob.N-1)]
217217

218218
"Get the objective. Returns an `AbstractObjective`."
219219
@inline get_objective(prob::Problem) = prob.obj

0 commit comments

Comments
 (0)