control.flatsys.FlatSystem

class control.flatsys.FlatSystem(forward, reverse, updfcn=None, outfcn=None, inputs=None, outputs=None, states=None, params={}, dt=None, name=None)

Base class for representing a differentially flat system.

The FlatSystem class is used as a base class to describe differentially flat systems for trajectory generation. The class must implement two functions:

zflag = flatsys.foward(x, u)

This function computes the flag (derivatives) of the flat output. The inputs to this function are the state ‘x’ and inputs ‘u’ (both 1D arrays). The output should be a 2D array with the first dimension equal to the number of system inputs and the second dimension of the length required to represent the full system dynamics (typically the number of states)

x, u = flatsys.reverse(zflag)

This function system state and inputs give the the flag (derivatives) of the flat output. The input to this function is an 2D array whose first dimension is equal to the number of system inputs and whose second dimension is of length required to represent the full system dynamics (typically the number of states). The output is the state x and inputs u (both 1D arrays).

A flat system is also an input/output system supporting simulation, composition, and linearization. If the update and output methods are given, they are used in place of the flat coordinates.

__init__(forward, reverse, updfcn=None, outfcn=None, inputs=None, outputs=None, states=None, params={}, dt=None, name=None)

Create a differentially flat input/output system.

The FlatIOSystem constructor is used to create an input/output system object that also represents a differentially flat system. The output of the system does not need to be the differentially flat output.

Parameters
  • forward (callable) – A function to compute the flat flag given the states and input.

  • reverse (callable) – A function to compute the states and input given the flat flag.

  • updfcn (callable, optional) –

    Function returning the state update function

    updfcn(t, x, u[, param]) -> array

    where x is a 1-D array with shape (nstates,), u is a 1-D array with shape (ninputs,), t is a float representing the currrent time, and param is an optional dict containing the values of parameters used by the function. If not specified, the state space update will be computed using the flat system coordinates.

  • outfcn (callable) –

    Function returning the output at the given state

    outfcn(t, x, u[, param]) -> array

    where the arguments are the same as for upfcn. If not specified, the output will be the flat outputs.

  • inputs (int, list of str, or None) – Description of the system inputs. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form s[i] (where s is one of u, y, or x). If this parameter is not given or given as None, the relevant quantity will be determined when possible based on other information provided to functions using the system.

  • outputs (int, list of str, or None) – Description of the system outputs. Same format as inputs.

  • states (int, list of str, or None) – Description of the system states. Same format as inputs.

  • dt (None, True or float, optional) – System timebase. None (default) indicates continuous time, True indicates discrete time with undefined sampling time, positive number is discrete time with specified sampling time.

  • params (dict, optional) – Parameter values for the systems. Passed to the evaluation functions for the system as default values, overriding internal defaults.

  • name (string, optional) – System name (used for specifying signals)

Returns

Input/output system object

Return type

InputOutputSystem

Methods

__init__(forward, reverse[, updfcn, outfcn, …])

Create a differentially flat input/output system.

copy([newname])

Make a copy of an input/output system.

feedback([other, sign, params])

Feedback interconnection between two input/output systems

find_input(name)

Find the index for an input given its name (None if not found)

find_output(name)

Find the index for an output given its name (None if not found)

find_state(name)

Find the index for a state given its name (None if not found)

forward(x, u[, params])

Compute the flat flag given the states and input.

linearize(x0, u0[, t, params, eps])

Linearize an input/output system at a given state and input.

name_or_default([name])

reverse(zflag[, params])

Compute the states and input given the flat flag.

set_inputs(inputs[, prefix])

Set the number/names of the system inputs.

set_outputs(outputs[, prefix])

Set the number/names of the system outputs.

set_states(states[, prefix])

Set the number/names of the system states.

Attributes

idCounter

copy(newname=None)

Make a copy of an input/output system.

feedback(other=1, sign=- 1, params={})

Feedback interconnection between two input/output systems

Parameters
  • sys1 (InputOutputSystem) – The primary process.

  • sys2 (InputOutputSystem) – The feedback process (often a feedback controller).

  • sign (scalar, optional) – The sign of feedback. sign = -1 indicates negative feedback, and sign = 1 indicates positive feedback. sign is an optional argument; it assumes a value of -1 if not specified.

Returns

out

Return type

InputOutputSystem

Raises

ValueError – if the inputs, outputs, or timebases of the systems are incompatible.

find_input(name)

Find the index for an input given its name (None if not found)

find_output(name)

Find the index for an output given its name (None if not found)

find_state(name)

Find the index for a state given its name (None if not found)

forward(x, u, params={})

Compute the flat flag given the states and input.

Given the states and inputs for a system, compute the flat outputs and their derivatives (the flat “flag”) for the system.

Parameters
  • x (list or array) – The state of the system.

  • u (list or array) – The input to the system.

  • params (dict, optional) – Parameter values for the system. Passed to the evaluation functions for the system as default values, overriding internal defaults.

Returns

zflag – For each flat output z_i, zflag[i] should be an ndarray of length q_i that contains the flat output and its first q_i derivatives.

Return type

list of 1D arrays

linearize(x0, u0, t=0, params={}, eps=1e-06)

Linearize an input/output system at a given state and input.

Return the linearization of an input/output system at a given state and input value as a StateSpace system. See linearize() for complete documentation.

reverse(zflag, params={})

Compute the states and input given the flat flag.

Parameters
  • zflag (list of arrays) – For each flat output z_i, zflag[i] should be an ndarray of length q_i that contains the flat output and its first q_i derivatives.

  • params (dict, optional) – Parameter values for the system. Passed to the evaluation functions for the system as default values, overriding internal defaults.

Returns

  • x (1D array) – The state of the system corresponding to the flat flag.

  • u (1D array) – The input to the system corresponding to the flat flag.

set_inputs(inputs, prefix='u')

Set the number/names of the system inputs.

Parameters
  • inputs (int, list of str, or None) – Description of the system inputs. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form u[i] (where the prefix u can be changed using the optional prefix parameter).

  • prefix (string, optional) – If inputs is an integer, create the names of the states using the given prefix (default = ‘u’). The names of the input will be of the form prefix[i].

set_outputs(outputs, prefix='y')

Set the number/names of the system outputs.

Parameters
  • outputs (int, list of str, or None) – Description of the system outputs. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form u[i] (where the prefix u can be changed using the optional prefix parameter).

  • prefix (string, optional) – If outputs is an integer, create the names of the states using the given prefix (default = ‘y’). The names of the input will be of the form prefix[i].

set_states(states, prefix='x')

Set the number/names of the system states.

Parameters
  • states (int, list of str, or None) – Description of the system states. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form u[i] (where the prefix u can be changed using the optional prefix parameter).

  • prefix (string, optional) – If states is an integer, create the names of the states using the given prefix (default = ‘x’). The names of the input will be of the form prefix[i].