You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
flowing from gh-1101, which complains about the code in question,
solve_flat_ocp argument timepts is advertised in the docstring as being allowed to be scalar:
timepts : float or 1D array_like
The list of points for evaluating cost and constraints, as well as
the time horizon. If given as a float, indicates the final time for
the trajectory (corresponding to xf)
Traceback (most recent call last):
File "/home/rory/projects/pycontrol/pyflakes/flatbug2.py", line 13, in <module>
traj2 = fs.solve_flat_ocp(f, 1, x0=[23],
terminal_cost=terminal_cost)
File "/home/rory/src/python-control/control/flatsys/flatsys.py", line 725, in solve_flat_ocp
T0 = timepts[0] if len(timepts) > 1 else T0
^^
UnboundLocalError: cannot access local variable 'T0' where it is not associated with a value
I think the fix is as below. Diff also removes Tf, which is not used in the function. With this diff the test script runs with error.
@@ -721,8 +721,7 @@ def solve_flat_ocp(
# Process final time
timepts = np.atleast_1d(timepts)
- Tf = timepts[-1]- T0 = timepts[0] if len(timepts) > 1 else T0+ T0 = timepts[0] if len(timepts) > 1 else 0
# Process keyword arguments
if trajectory_constraints is None:
Activity
Handle scalar `timepts` arg in `solve_flat_ocp`