Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda27d35

Browse files
authored
Merge pull request#633 from murrayrm/docstring_updates
Documentation updates:* Make documentation for classes more consistent* Include documentation for __call__* Correct documentation for iosys updfcn and outfcn
2 parents618ea45 +866a07c commitda27d35

23 files changed

+745
-443
lines changed

‎control/descfcn.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# Class for nonlinearities with a built-in describing function
2828
classDescribingFunctionNonlinearity():
29-
"""Base class for nonlinear systems with a describing function
29+
"""Base class for nonlinear systems with a describing function.
3030
3131
This class is intended to be used as a base class for nonlinear functions
3232
that have an analytically defined describing function. Subclasses should
@@ -36,16 +36,16 @@ class DescribingFunctionNonlinearity():
3636
3737
"""
3838
def__init__(self):
39-
"""Initailize a describing function nonlinearity (optional)"""
39+
"""Initailize a describing function nonlinearity (optional)."""
4040
pass
4141

4242
def__call__(self,A):
43-
"""Evaluate the nonlinearity at a (scalar) input value"""
43+
"""Evaluate the nonlinearity at a (scalar) input value."""
4444
raiseNotImplementedError(
4545
"__call__() not implemented for this function (internal error)")
4646

4747
defdescribing_function(self,A):
48-
"""Return the describing function for a nonlinearity
48+
"""Return the describing function for a nonlinearity.
4949
5050
This method is used to allow analytical representations of the
5151
describing function for a nonlinearity. It turns the (complex) value
@@ -56,7 +56,7 @@ def describing_function(self, A):
5656
"describing function not implemented for this function")
5757

5858
def_isstatic(self):
59-
"""Return True if the function has no internal state (memoryless)
59+
"""Return True if the function has no internal state (memoryless).
6060
6161
This internal function is used to optimize numerical computation of
6262
the describing function. It can be set to `True` if the instance
@@ -329,7 +329,7 @@ def _find_intersection(L1a, L1b, L2a, L2b):
329329

330330
# Saturation nonlinearity
331331
classsaturation_nonlinearity(DescribingFunctionNonlinearity):
332-
"""Createasaturation nonlinearity for use in describing function analysis
332+
"""Create saturation nonlinearity for use in describing function analysis.
333333
334334
This class creates a nonlinear function representing a saturation with
335335
given upper and lower bounds, including the describing function for the
@@ -381,7 +381,7 @@ def describing_function(self, A):
381381

382382
# Relay with hysteresis (FBS2e, Example 10.12)
383383
classrelay_hysteresis_nonlinearity(DescribingFunctionNonlinearity):
384-
"""Relay w/ hysteresis nonlinearity foruse indescribing function analysis
384+
"""Relay w/ hysteresis nonlinearity for describing function analysis.
385385
386386
This class creates a nonlinear function representing a a relay with
387387
symmetric upper and lower bounds of magnitude `b` and a hysteretic region
@@ -437,7 +437,7 @@ def describing_function(self, A):
437437

438438
# Friction-dominated backlash nonlinearity (#48 in Gelb and Vander Velde, 1968)
439439
classfriction_backlash_nonlinearity(DescribingFunctionNonlinearity):
440-
"""Backlash nonlinearity foruse indescribing function analysis
440+
"""Backlash nonlinearity for describing function analysis.
441441
442442
This class creates a nonlinear function representing a friction-dominated
443443
backlash nonlinearity ,including the describing function for the

‎control/flatsys/basis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class BasisFamily:
4747
4848
:math:`z_i^{(q)}(t)` = basis.eval_deriv(self, i, j, t)
4949
50+
Parameters
51+
----------
52+
N : int
53+
Order of the basis set.
54+
5055
"""
5156
def__init__(self,N):
5257
"""Create a basis family of order N."""

‎control/flatsys/bezier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from .basisimportBasisFamily
4444

4545
classBezierFamily(BasisFamily):
46-
r"""Polynomial basis functions.
46+
r"""Bezier curve basis functions.
4747
4848
This class represents the family of polynomials of the form
4949

‎control/flatsys/flatsys.py

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,59 @@ class FlatSystem(NonlinearIOSystem):
5454
"""Base class for representing a differentially flat system.
5555
5656
The FlatSystem class is used as a base class to describe differentially
57-
flat systems for trajectory generation. The class must implement two
58-
functions:
57+
flat systems for trajectory generation. The output of the system does not
58+
need to be the differentially flat output.
59+
60+
Parameters
61+
----------
62+
forward : callable
63+
A function to compute the flat flag given the states and input.
64+
reverse : callable
65+
A function to compute the states and input given the flat flag.
66+
updfcn : callable, optional
67+
Function returning the state update function
68+
69+
`updfcn(t, x, u[, param]) -> array`
70+
71+
where `x` is a 1-D array with shape (nstates,), `u` is a 1-D array
72+
with shape (ninputs,), `t` is a float representing the currrent
73+
time, and `param` is an optional dict containing the values of
74+
parameters used by the function. If not specified, the state
75+
space update will be computed using the flat system coordinates.
76+
outfcn : callable
77+
Function returning the output at the given state
78+
79+
`outfcn(t, x, u[, param]) -> array`
80+
81+
where the arguments are the same as for `upfcn`. If not
82+
specified, the output will be the flat outputs.
83+
inputs : int, list of str, or None
84+
Description of the system inputs. This can be given as an integer
85+
count or as a list of strings that name the individual signals.
86+
If an integer count is specified, the names of the signal will be
87+
of the form `s[i]` (where `s` is one of `u`, `y`, or `x`). If
88+
this parameter is not given or given as `None`, the relevant
89+
quantity will be determined when possible based on other
90+
information provided to functions using the system.
91+
outputs : int, list of str, or None
92+
Description of the system outputs. Same format as `inputs`.
93+
states : int, list of str, or None
94+
Description of the system states. Same format as `inputs`.
95+
dt : None, True or float, optional
96+
System timebase. None (default) indicates continuous
97+
time, True indicates discrete time with undefined sampling
98+
time, positive number is discrete time with specified
99+
sampling time.
100+
params : dict, optional
101+
Parameter values for the systems. Passed to the evaluation
102+
functions for the system as default values, overriding internal
103+
defaults.
104+
name : string, optional
105+
System name (used for specifying signals)
106+
107+
Notes
108+
-----
109+
The class must implement two functions:
59110
60111
zflag = flatsys.foward(x, u)
61112
This function computes the flag (derivatives) of the flat output.
@@ -83,65 +134,13 @@ def __init__(self,
83134
updfcn=None,outfcn=None,# I/O system
84135
inputs=None,outputs=None,
85136
states=None,params={},dt=None,name=None):
86-
"""Create a differentially flatinput/output system.
137+
"""Create a differentially flatI/O system.
87138
88139
The FlatIOSystem constructor is used to create an input/output system
89-
object that also represents a differentially flat system. The output
90-
of the system does not need to be the differentially flat output.
91-
92-
Parameters
93-
----------
94-
forward : callable
95-
A function to compute the flat flag given the states and input.
96-
reverse : callable
97-
A function to compute the states and input given the flat flag.
98-
updfcn : callable, optional
99-
Function returning the state update function
100-
101-
`updfcn(t, x, u[, param]) -> array`
102-
103-
where `x` is a 1-D array with shape (nstates,), `u` is a 1-D array
104-
with shape (ninputs,), `t` is a float representing the currrent
105-
time, and `param` is an optional dict containing the values of
106-
parameters used by the function. If not specified, the state
107-
space update will be computed using the flat system coordinates.
108-
outfcn : callable
109-
Function returning the output at the given state
110-
111-
`outfcn(t, x, u[, param]) -> array`
112-
113-
where the arguments are the same as for `upfcn`. If not
114-
specified, the output will be the flat outputs.
115-
inputs : int, list of str, or None
116-
Description of the system inputs. This can be given as an integer
117-
count or as a list of strings that name the individual signals.
118-
If an integer count is specified, the names of the signal will be
119-
of the form `s[i]` (where `s` is one of `u`, `y`, or `x`). If
120-
this parameter is not given or given as `None`, the relevant
121-
quantity will be determined when possible based on other
122-
information provided to functions using the system.
123-
outputs : int, list of str, or None
124-
Description of the system outputs. Same format as `inputs`.
125-
states : int, list of str, or None
126-
Description of the system states. Same format as `inputs`.
127-
dt : None, True or float, optional
128-
System timebase. None (default) indicates continuous
129-
time, True indicates discrete time with undefined sampling
130-
time, positive number is discrete time with specified
131-
sampling time.
132-
params : dict, optional
133-
Parameter values for the systems. Passed to the evaluation
134-
functions for the system as default values, overriding internal
135-
defaults.
136-
name : string, optional
137-
System name (used for specifying signals)
138-
139-
Returns
140-
-------
141-
InputOutputSystem
142-
Input/output system object
140+
object that also represents a differentially flat system.
143141
144142
"""
143+
145144
# TODO: specify default update and output functions
146145
ifupdfcnisNone:updfcn=self._flat_updfcn
147146
ifoutfcnisNone:outfcn=self._flat_outfcn
@@ -158,6 +157,7 @@ def __init__(self,
158157
# Save the length of the flat flag
159158

160159
defforward(self,x,u,params={}):
160+
161161
"""Compute the flat flag given the states and input.
162162
163163
Given the states and inputs for a system, compute the flat

‎control/flatsys/linflat.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,46 +42,48 @@
4242

4343

4444
classLinearFlatSystem(FlatSystem,LinearIOSystem):
45+
"""Base class for a linear, differentially flat system.
46+
47+
This class is used to create a differentially flat system representation
48+
from a linear system.
49+
50+
Parameters
51+
----------
52+
linsys : StateSpace
53+
LTI StateSpace system to be converted
54+
inputs : int, list of str or None, optional
55+
Description of the system inputs. This can be given as an integer
56+
count or as a list of strings that name the individual signals.
57+
If an integer count is specified, the names of the signal will be
58+
of the form `s[i]` (where `s` is one of `u`, `y`, or `x`). If
59+
this parameter is not given or given as `None`, the relevant
60+
quantity will be determined when possible based on other
61+
information provided to functions using the system.
62+
outputs : int, list of str or None, optional
63+
Description of the system outputs. Same format as `inputs`.
64+
states : int, list of str, or None, optional
65+
Description of the system states. Same format as `inputs`.
66+
dt : None, True or float, optional
67+
System timebase. None (default) indicates continuous
68+
time, True indicates discrete time with undefined sampling
69+
time, positive number is discrete time with specified
70+
sampling time.
71+
params : dict, optional
72+
Parameter values for the systems. Passed to the evaluation
73+
functions for the system as default values, overriding internal
74+
defaults.
75+
name : string, optional
76+
System name (used for specifying signals)
77+
78+
"""
79+
4580
def__init__(self,linsys,inputs=None,outputs=None,states=None,
4681
name=None):
4782
"""Define a flat system from a SISO LTI system.
4883
4984
Given a reachable, single-input/single-output, linear time-invariant
5085
system, create a differentially flat system representation.
5186
52-
Parameters
53-
----------
54-
linsys : StateSpace
55-
LTI StateSpace system to be converted
56-
inputs : int, list of str or None, optional
57-
Description of the system inputs. This can be given as an integer
58-
count or as a list of strings that name the individual signals.
59-
If an integer count is specified, the names of the signal will be
60-
of the form `s[i]` (where `s` is one of `u`, `y`, or `x`). If
61-
this parameter is not given or given as `None`, the relevant
62-
quantity will be determined when possible based on other
63-
information provided to functions using the system.
64-
outputs : int, list of str or None, optional
65-
Description of the system outputs. Same format as `inputs`.
66-
states : int, list of str, or None, optional
67-
Description of the system states. Same format as `inputs`.
68-
dt : None, True or float, optional
69-
System timebase. None (default) indicates continuous
70-
time, True indicates discrete time with undefined sampling
71-
time, positive number is discrete time with specified
72-
sampling time.
73-
params : dict, optional
74-
Parameter values for the systems. Passed to the evaluation
75-
functions for the system as default values, overriding internal
76-
defaults.
77-
name : string, optional
78-
System name (used for specifying signals)
79-
80-
Returns
81-
-------
82-
iosys : LinearFlatSystem
83-
Linear system represented as an flat input/output system
84-
8587
"""
8688
# Make sure we can handle the system
8789
if (notcontrol.isctime(linsys)):

‎control/flatsys/systraj.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,29 @@
4141
classSystemTrajectory:
4242
"""Class representing a system trajectory.
4343
44-
The `SystemTrajectory` class is used to represent the trajectory of
45-
a (differentially flat) system. Used by the
46-
:func:`~control.trajsys.point_to_point` function to return a
47-
trajectory.
44+
The `SystemTrajectory` class is used to represent the
45+
trajectory of a (differentially flat) system. Used by the
46+
:func:`~control.trajsys.point_to_point` function to return a trajectory.
4847
49-
"""
50-
def__init__(self,sys,basis,coeffs=[],flaglen=[]):
51-
"""Initilize a system trajectory object.
48+
Parameters
49+
----------
50+
sys : FlatSystem
51+
Flat system object associated with this trajectory.
52+
basis : BasisFamily
53+
Family of basis vectors to use to represent the trajectory.
54+
coeffs : list of 1D arrays, optional
55+
For each flat output, define the coefficients of the basis
56+
functions used to represent the trajectory. Defaults to an empty
57+
list.
58+
flaglen : list of ints, optional
59+
For each flat output, the number of derivatives of the flat
60+
output used to define the trajectory. Defaults to an empty
61+
list.
5262
53-
Parameters
54-
----------
55-
sys : FlatSystem
56-
Flat system object associated with this trajectory.
57-
basis : BasisFamily
58-
Family of basis vectors to use to represent the trajectory.
59-
coeffs : list of 1D arrays, optional
60-
For each flat output, define the coefficients of the basis
61-
functions used to represent the trajectory. Defaults to an empty
62-
list.
63-
flaglen : list of ints, optional
64-
For each flat output, the number of derivatives of the flat output
65-
used to define the trajectory. Defaults to an empty list.
63+
"""
6664

67-
"""
65+
def__init__(self,sys,basis,coeffs=[],flaglen=[]):
66+
"""Initilize a system trajectory object."""
6867
self.nstates=sys.nstates
6968
self.ninputs=sys.ninputs
7069
self.system=sys

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp