0

In compass_gait_limit_cycle.ipynb, I followed the instruction and added five groups of constraints:

for t in range(T):
    vars = q[t]
    prog.AddConstraint(swing_foot_height, lb=[0]*nq, ub=[np.inf]*nq, vars=vars)

However, I got the error information:

RuntimeError                              Traceback (most recent call last)
<ipython-input-24-5cf4d7a05da1> in <module>()
      1 # solve mathematical program with initial guess
      2 solver = SnoptSolver()
----> 3 result = solver.Solve(prog, initial_guess)
      4 
      5 # ensure solution is found
RuntimeError: PyFunctionConstraint: Output must be of .ndim = 1 or 2 (vector) and .size = 4. Got .ndim = 1 and .size = 1 instead.
Axebobby
  • 31
  • 4

1 Answers1

1

When you imposed the constraint through

prog.AddConstraint(swing_foot_height, lb=[0]*nq, ub=[np.inf]*nq, vars=vars)

The dimensionality of the swing_foot_height doesn't match with lb and ub. The constraint you want is lb <= swing_foot_height(q[t]) <= ub. If your swing_foot_height returns a numpy array containing the scaled valued swing foot height, then both lb and ub should be of size 1, namely you should change lb and ub to lb=[0], ub=[np.inf].

Hongkai Dai
  • 2,546
  • 11
  • 12