Skip to content

Commit

Permalink
Merge pull request #643 from basicmachines/master
Browse files Browse the repository at this point in the history
Various docstring edits + fixed plot legends on cruise control example
  • Loading branch information
murrayrm committed Aug 7, 2021
2 parents da27d35 + cc97f4b commit 6b7a9c7
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 142 deletions.
6 changes: 3 additions & 3 deletions control/bdalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def append(*sys):
Parameters
----------
sys1, sys2, ..., sysn: StateSpace or Transferfunction
sys1, sys2, ..., sysn: StateSpace or TransferFunction
LTI systems to combine
Expand All @@ -275,7 +275,7 @@ def append(*sys):
Examples
--------
>>> sys1 = ss([[1., -2], [3., -4]], [[5.], [7]]", [[6., 8]], [[9.]])
>>> sys1 = ss([[1., -2], [3., -4]], [[5.], [7]], [[6., 8]], [[9.]])
>>> sys2 = ss([[-1.]], [[1.]], [[1.]], [[0.]])
>>> sys = append(sys1, sys2)
Expand All @@ -299,7 +299,7 @@ def connect(sys, Q, inputv, outputv):
Parameters
----------
sys : StateSpace Transferfunction
sys : StateSpace or TransferFunction
System to be connected
Q : 2D array
Interconnection matrix. First column gives the input to be connected.
Expand Down
12 changes: 6 additions & 6 deletions control/iosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(self, inputs=None, outputs=None, states=None, params={},
name=None, **kwargs):
"""Create an input/output system.
The InputOutputSystem contructor is used to create an input/output
The InputOutputSystem constructor is used to create an input/output
object with the core information required for all input/output
systems. Instances of this class are normally created by one of the
input/output subclasses: :class:`~control.LinearICSystem`,
Expand Down Expand Up @@ -661,7 +661,7 @@ def copy(self, newname=None):
class LinearIOSystem(InputOutputSystem, StateSpace):
"""Input/output representation of a linear (state space) system.
This class is used to implementat a system that is a linear state
This class is used to implement a system that is a linear state
space system (defined by the StateSpace system object).
Parameters
Expand Down Expand Up @@ -1675,7 +1675,7 @@ def find_eqpt(sys, x0, u0=[], y0=None, t=0, params={},
return_y=False, return_result=False, **kw):
"""Find the equilibrium point for an input/output system.
Returns the value of an equlibrium point given the initial state and
Returns the value of an equilibrium point given the initial state and
either input value or desired output value for the equilibrium point.
Parameters
Expand Down Expand Up @@ -1926,15 +1926,15 @@ def linearize(sys, xeq, ueq=[], t=0, params={}, **kw):
This function computes the linearization of an input/output system at a
given state and input value and returns a :class:`~control.StateSpace`
object. The eavaluation point need not be an equilibrium point.
object. The evaluation point need not be an equilibrium point.
Parameters
----------
sys : InputOutputSystem
The system to be linearized
xeq : array
The state at which the linearization will be evaluated (does not need
to be an equlibrium state).
to be an equilibrium state).
ueq : array
The input at which the linearization will be evaluated (does not need
to correspond to an equlibrium state).
Expand Down Expand Up @@ -2055,7 +2055,7 @@ def interconnect(syslist, connections=None, inplist=[], outlist=[],
('sys', 'sig') are also recognized.
Similarly, each output-spec should describe an output signal from one
of the susystems. The lowest level representation is a tuple of the
of the subsystems. The lowest level representation is a tuple of the
form `(subsys_i, out_j, gain)`. The input will be constructed by
summing the listed outputs after multiplying by the gain term. If the
gain term is omitted, it is assumed to be 1. If the system has a
Expand Down
24 changes: 12 additions & 12 deletions control/optimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class OptimalControlProblem():
"""Description of a finite horizon, optimal control problem.
The `OptimalControlProblem` class holds all of the information required to
specify and optimal control problem: the system dynamics, cost function,
specify an optimal control problem: the system dynamics, cost function,
and constraints. As much as possible, the information used to specify an
optimal control problem matches the notation and terminology of the SciPy
`optimize.minimize` module, with the hope that this makes it easier to
Expand Down Expand Up @@ -94,13 +94,13 @@ class OptimalControlProblem():
The `_cost_function` method takes the information computes the cost of the
trajectory generated by the proposed input. It does this by calling a
user-defined function for the integral_cost given the current states and
inputs at each point along the trajetory and then adding the value of a
inputs at each point along the trajectory and then adding the value of a
user-defined terminal cost at the final pint in the trajectory.
The `_constraint_function` method evaluates the constraint functions along
the trajectory generated by the proposed input. As in the case of the
cost function, the constraints are evaluated at the state and input along
each point on the trjectory. This information is compared against the
each point on the trajectory. This information is compared against the
constraint upper and lower bounds. The constraint function is processed
in the class initializer, so that it only needs to be computed once.
Expand Down Expand Up @@ -567,7 +567,7 @@ def _process_initial_guess(self, initial_guess):
#
# Initially guesses from the user are passed as input vectors as a
# function of time, but internally we store the guess in terms of the
# basis coefficients. We do this by solving a least squares probelm to
# basis coefficients. We do this by solving a least squares problem to
# find coefficients that match the input functions at the time points (as
# much as possible, if the problem is under-determined).
#
Expand Down Expand Up @@ -880,7 +880,7 @@ def solve_ocp(
Function that returns the terminal cost given the current state
and input. Called as terminal_cost(x, u).
terminal_constraint : list of tuples, optional
terminal_constraints : list of tuples, optional
List of constraints that should hold at the end of the trajectory.
Same format as `constraints`.
Expand Down Expand Up @@ -914,7 +914,7 @@ def solve_ocp(
res : OptimalControlResult
Bundle object with the results of the optimal control problem.
res.success: bool
res.success : bool
Boolean flag indicating whether the optimization was successful.
res.time : array
Expand Down Expand Up @@ -982,7 +982,7 @@ def create_mpc_iosystem(
Function that returns the terminal cost given the current state
and input. Called as terminal_cost(x, u).
terminal_constraint : list of tuples, optional
terminal_constraints : list of tuples, optional
List of constraints that should hold at the end of the trajectory.
Same format as `constraints`.
Expand All @@ -992,7 +992,7 @@ def create_mpc_iosystem(
Returns
-------
ctrl : InputOutputSystem
An I/O system taking the currrent state of the model system and
An I/O system taking the current state of the model system and
returning the current input to be applied that minimizes the cost
function while satisfying the constraints.
Expand Down Expand Up @@ -1039,9 +1039,9 @@ def quadratic_cost(sys, Q, R, x0=0, u0=0):
R : 2D array_like
Weighting matrix for input cost. Dimensions must match system input.
x0 : 1D array
Nomimal value of the system state (for which cost should be zero).
Nominal value of the system state (for which cost should be zero).
u0 : 1D array
Nomimal value of the system input (for which cost should be zero).
Nominal value of the system input (for which cost should be zero).
Returns
-------
Expand Down Expand Up @@ -1082,7 +1082,7 @@ def quadratic_cost(sys, Q, R, x0=0, u0=0):
# As in the cost function evaluation, the main "trick" in creating a constrain
# on the state or input is to properly evaluate the constraint on the stacked
# state and input vector at the current time point. The constraint itself
# will be called at each poing along the trajectory (or the endpoint) via the
# will be called at each point along the trajectory (or the endpoint) via the
# constrain_function() method.
#
# Note that these functions to not actually evaluate the constraint, they
Expand Down Expand Up @@ -1250,7 +1250,7 @@ def input_range_constraint(sys, lb, ub):
def output_poly_constraint(sys, A, b):
"""Create output constraint from polytope
Creates a linear constraint on the system ouput of the form A y <= b that
Creates a linear constraint on the system output of the form A y <= b that
can be used as an optimal control constraint (trajectory or terminal).
Parameters
Expand Down
8 changes: 4 additions & 4 deletions control/statefbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ def lqe(A, G, C, QN, RN, NN=None):
.. math:: x_e = A x_e + B u + L(y - C x_e - D u)
produces a state estimate that x_e that minimizes the expected squared
error using the sensor measurements y. The noise cross-correlation `NN`
is set to zero when omitted.
produces a state estimate x_e that minimizes the expected squared error
using the sensor measurements y. The noise cross-correlation `NN` is
set to zero when omitted.
Parameters
----------
Expand Down Expand Up @@ -617,7 +617,7 @@ def gram(sys, type):
if type not in ['c', 'o', 'cf', 'of']:
raise ValueError("That type is not supported!")

# TODO: Check for continous or discrete, only continuous supported for now
# TODO: Check for continuous or discrete, only continuous supported for now
# if isCont():
# dico = 'C'
# elif isDisc():
Expand Down

0 comments on commit 6b7a9c7

Please sign in to comment.