Drake
 All Classes Files Functions Variables
PolynomialSystem Class Reference

A dynamical system described by rational polynomial dynamics, and polynomial outputs. More...

Inheritance diagram for PolynomialSystem:
Collaboration diagram for PolynomialSystem:

Public Member Functions

function PolynomialSystem (num_xc, num_xd, num_u, num_y, direct_feedthrough_flag, time_invariant_flag, rational_flag)
 initialize PolynomialSystem More...
 
function dynamics (obj, t, x, u)
 
function dynamicsLHS (obj, t, x, u)
 
function dynamicsRHS (obj, t, x, u)
 
function setRationalFlag (obj, tf)
 
function isRational (obj)
 
function getPolyDynamics (obj, t)
 
function getPolyUpdate (obj, t)
 
function getPolyOutput (obj, t)
 
function getPolyStateConstraints (obj)
 
function setNumZeroCrossings (obj, num_zcs)
 
function timeReverse (obj)
 
function setInputFrame (obj, frame)
 
function setStateFrame (obj, frame)
 
function inStateFrame (sys, frame)
 
function feedback (sys1, sys2)
 try to keep feedback between polynomial systems polynomial. More...
 
function cascade (sys1, sys2)
 try to keep cascade between polynomial systems polynomial. More...
 
function extractAffineSystem (obj)
 
function plotVdot (sys, Vtraj, ts, options)
 
function regionOfAttraction (sys, varargin)
 Estimates the region of attraction. More...
 
function sampledFiniteTimeReachability (poly, ts, xtraj, gTmss, R, options)
 Implements Henrion and Korda's SOS relaxation for computing finite time funnels. More...
 
function sampledFiniteTimeReachabilityFunnel (sys, polyOrig, Vtraj0, G, R0, tv, ts, xtraj0, utraj, options, Phi, rho)
 % Implements time-varying reachability computation. More...
 
function sampledFiniteTimeVerification (sys, ts, G, varargin)
 Attempts to find the largest funnel, defined by the time-varying one-level set of V, which verifies (using SOS over state at finite sample points in time) initial conditions to end inside the one-level set of the goal region G at time ts(end). More...
 
function sampledTransverseVerification (sys, G, Vtraj0, ts, xtraj, utraj, transSurf, options)
 Attempts to find the largest funnel around xtraj using transverse surfaces. More...
 
- Public Member Functions inherited from DrakeSystem
function DrakeSystem (num_xc, num_xd, num_u, num_y, direct_feedthrough_flag, time_invariant_flag)
 Construct a DrakeSystem. More...
 
function getInitialState (obj)
 Return a (potentially random) state double (column) vector of initial conditions. More...
 
function update (obj, t, x, u)
 Placeholder for the update method. More...
 
function output (obj, t, x, u)
 Placeholder for the output method. Systems must overload this method. More...
 
function zeroCrossings (obj, t, x, u)
 Placeholder for the zeroCrossings method: a method phi = zeroCrossings(t,x,u) which triggers a zero crossing event when phi transitions from positive to negative. More...
 
function getNumContStates (obj)
 Returns the number of continuous states. More...
 
function getNumDiscStates (obj)
 Returns the number of discrete states. More...
 
function getNumInputs (obj)
 Returns the number of inputs to the system. More...
 
function getNumOutputs (obj)
 Returns the number of outputs from the system. More...
 
function getInitialStateWInput (obj, t, x, u)
 Hook in case a system needs to initial state based on current time and/or input. More...
 
function getSampleTime (obj)
 As described at http://www.mathworks.com/help/toolbox/simulink/sfg/f6-58760.html to set multiple sample times, specify one column for each sample time/offset pair. More...
 
function getInputSampleTimes (obj)
 Returns getSampleTime - a DrakeSystem can only have a single same time associated with it. More...
 
function getOutputSampleTimes (obj)
 Returns getSampleTime - a DrakeSystem can only have a single same time associated with it. More...
 
function setSampleTime (obj, ts)
 robust method for setting default sample time More...
 
function isDirectFeedthrough (obj)
 Check if the system is direct feedthrough (e.g., if the output depends on the immediate input) More...
 
function setDirectFeedthrough (obj, tf)
 Set the direct feedthrough flag. More...
 
function getModel (obj)
 Constructs a simulink system block for this system to be used by the simulink engine. More...
 
function findFixedPoint (obj, x0, u0)
 attempts to find a fixed point (xstar,ustar) which also satisfies the constraints, using (x0,u0) as the initial guess. More...
 
function getDefaultInput (obj)
 Define the default initial input so that behavior is well-defined if no controller is specified or if no control messages have been received yet. More...
 
function setNumContStates (obj, num_xc)
 Guards the num_states variable. More...
 
function setNumDiscStates (obj, num_xd)
 Guards the num_states variable. More...
 
function setNumInputs (obj, num_u)
 Guards the num_u variable. More...
 
function setInputLimits (obj, umin, umax)
 Guards the input limits to make sure it stay consistent. More...
 
function setNumOutputs (obj, num_y)
 Guards the number of outputs to make sure it's consistent. More...
 
function getNumZeroCrossings (obj)
 Returns the number of zero crossings. More...
 
function setNumZeroCrossings (obj, num_zcs)
 Guards the number of zero crossings to make sure it's valid. More...
 
function getNumStateConstraints (obj)
 
function getNumUnilateralConstraints (obj)
 
function addStateConstraint (obj, con, xind)
 
function updateStateConstraint (obj, id, con, xind)
 
function displayStateConstraints (obj)
 
function removeAllStateConstraints (obj)
 
function addStateConstraintsToProgram (obj, prog, indices)
 adds state constraints and unilateral constraints to the program on the specified indices. More...
 
function addInputConstraintsToProgram (obj, prog, indices)
 add bounding box constraint todo: consider whether it makes sense to a list of constraints objects instead of just input limits. More...
 
function stateConstraints (obj, x)
 Provides the old interface of a single constraint function which evaluates all of the equality constraints on the state (which should be == 0) More...
 
function linearize (obj, t0, x0, u0)
 Uses the geval engine to linearize the model around the nominal point, at least for the simple case. More...
 
function simulate (obj, varargin)
 
function simulateODE (obj, tspan, x0, options)
 Simulates the system using the ODE45 suite of solvers instead of the simulink solvers. More...
 
function feedback (sys1, sys2)
 Constructs a feedback combination of sys1 and sys2. More...
 
function cascade (sys1, sys2)
 Constructs a cascade combination of sys1 and sys2. More...
 
function extractPolynomialSystem (obj)
 Attempts to symbolically extract the extra structure of a polynomial system from the Drake system Will throw an error if the system is not truly polynomial. More...
 
function extractAffineSystem (obj)
 Attempts to symbolically extract the extra structure of an affine system from the Drake system Will throw an error if the system is not truly affine. More...
 
function extractLinearSystem (obj)
 Attempts to symbolically extract the extra structure of a linear system from the Drake system Will throw an error if the system is not truly linear. More...
 
function makeTrigPolySystem (obj, options)
 deprecated method (due to refactoring): please use extractTrigPolySystem instead More...
 
function systemGradTest (obj, t, x, u, options)
 Compare numerical and analytical derivatives of dynamics,update,and output. More...
 
function extractAffineSystem (obj)
 
function extractTrigPolySystem (sys, options)
 tries to convert the current system into a trig-poly system More...
 
function taylorApprox (sys, varargin)
 performs a taylorApproximation around a point or trajectory usage: taylorApprox(sys,t0,x0,u0,order[,ignores]) or taylorApprox(sys,x0traj,u0traj,order[,ignores]) it returns a polynomial system (or polynomial trajectory system) More...
 
function transverseLQR (obj, xtraj, utraj, Q, R, Qf, transSurf)
 Compute LQR control for transversal system. More...
 
function transverseLQRClosedLoop (obj, xtraj, utraj, Q, R, Vf, transSurf)
 
function tvlqr (obj, xtraj, utraj, Q, R, Qf, options)
 implements the time-varying linear (or affine) quadratic regulator More...
 
- Public Member Functions inherited from DynamicalSystem
function DynamicalSystem ()
 
function inInputFrame (sys, frame)
 Ensures that sys has the specified input frame, by searching for and cascading a coordinate transformation to the existing input if necessary. More...
 
function inStateFrame (sys, frame)
 Ensures that sys has the specified state frame. More...
 
function inOutputFrame (sys, frame)
 Ensures that sys has the specified output frame, by searching for and cascading a coordinate transformation to the existing output if necessary. More...
 
function cascade (sys1, sys2)
 Creates a new system with the output of system 1 connected to the input of system 2. More...
 
function feedback (sys1, sys2)
 Creates a new systems with sys1 and sys2 in a feedback interconnect (with sys1 on the forward path, and sys2 on the return path). More...
 
function parallel (sys1, sys2)
 Creates a new system that takes the inputs to both sys1 and sys2 as a single input (which is "demux"ed and passed independently to the two systems), and outputs the "mux"ed output of the two systems. More...
 
function sampledData (sys, tsin, tsout)
 Creates a new system which is a sampled data (e.g. More...
 
function resolveConstraints (obj, x0, v, constraints)
 attempts to find a x which satisfies the constraints, using x0 as the initial guess. More...
 
function addStateConstraintsToProgram (obj, prog, indices)
 adds state constraints and unilateral constriants to the program on the specified indices. More...
 
function getNumStates (obj)
 Returns the total number of states (discrete + continuous) in the system. More...
 
function getInputSampleTimes (obj)
 Returns the sample time of the input See getSampleTime for more details about sample times. More...
 
function getOutputSampleTimes (obj)
 Returns the sample time of the output See getSampleTime for more details about sample times. More...
 
function isDT (obj)
 Returns true if the system has no states, or has states and only one sample time [a b], with a>0. More...
 
function isCT (obj)
 Returns true if the system has only one sample time [a b], with a==0. More...
 
function isInheritedTime (obj)
 Returns true if the system has only one sample time [a b], with b==-1. More...
 
function isTI (obj)
 Returns true if the system is time-invariant. More...
 
function setTIFlag (obj, bval)
 Sets the time invariant flag. More...
 
function getInputFrame (obj)
 Access the CoordinateFrame object that defines the input to this system. More...
 
function setInputFrame (obj, fr)
 Set the CoordinateFrame object that defines the input of this system. More...
 
function getStateFrame (obj)
 Access the CoordinateFrame object that defines the state of this system. More...
 
function setStateFrame (obj, fr)
 Set the CoordinateFrame object that defines the state of this system. More...
 
function getOutputFrame (obj)
 Access the CoordinateFrame object that defines the output to this system. More...
 
function setOutputFrame (obj, fr)
 Set the CoordinateFrame object that defines the output of this system. More...
 
function getNumStateConstraints (obj)
 Returns the scalar number of state constraints (of the form phi(x)=0) More...
 
function stateConstraints (obj, x)
 defines state equality constraints in the form phi(x)=0 More...
 
function unilateralConstraints (obj, x)
 defines state unilateral constraints in the form phi(x)>=0 More...
 
function getNumUnilateralConstraints (obj)
 Returns the scalar number of state constraints (of the form phi(x)>=0) More...
 
function setSimulinkParam (obj, varargin)
 Sets parameters of the simulink model Syntax setSimulinkParam(obj,param_name,param_value[,param_name,param_value,]) % Se. More...
 
function linearize (obj, t0, x0, u0)
 Linearize the system about an operating point (continuous time) More...
 
function dlinearize (obj, ts, t0, x0, u0)
 Linearize the system about an operating point (discrete time) More...
 
function setParams (obj, p)
 This default setParams method attempts to set class properties of the system according to the coordinate names in the parameter frame. More...
 
function getParams (obj)
 This default getParams method attempts to get class properties of the system according to the coordinate names in the parameter frame. More...
 
function getNumParams (obj)
 
function setParamFrame (obj, fr)
 Set the CoordinateFrame object which describes any system parameters. More...
 
function getParamFrame (obj)
 Returns the CoordinateFrame object which describes any system parameters. More...
 
function setParamLimits (obj, pmin, pmax)
 Set lower and upper bounds on the system parameters. More...
 
function getParamLimits (obj)
 Returns the current lower and upper bounds on the system parameters. More...
 
function parameterEstimation (obj, data, options)
 Estimate parameter values from input-output data. More...
 
function runLCM (obj, x0, options)
 Runs the system as an lcm node. More...
 
function simulate (obj, tspan, x0, options)
 Simulates the dynamical system (using the simulink solvers) More...
 
function tiHinf (obj, x0, u0, Q, R, Bw, gamma)
 Suboptimal state-feedback H-infinity controller for LTI system with bound gamma. More...
 
function tilqr (obj, x0, u0, Q, R, options)
 Computes an LQR controller to stabilize the system around (x0,u0) More...
 
function tilyap (obj, x0, Q)
 Linearizes the system about the state x0 and returns a candidate LyapunovFunction generated by solving the quadratic Lyapunov equation. More...
 
function tvlyap (obj, xtraj, Q, Qf)
 Linearizes the system about the state trajectory xtraj and returns a candidate LyapunovFunction generated by integrating backwards the quadratic differential Lyapunov equation. More...
 

Additional Inherited Members

- Public Attributes inherited from DynamicalSystem
Property warning_manager
 
- Protected Member Functions inherited from DynamicalSystem
function stateIndicesForCombination (sys1, sys2)
 Helper method to figure out the indices of the discrete and continuous states after sys1 and sys2 have been combined into a single system. More...
 
function stateVectorToStructure (obj, xv, mdl)
 Converts the vector state xv to the structure xs for simulink state. More...
 
function stateStructureToVector (obj, xs)
 Converts the simulink state structure representation back to the vector state. More...
 

Detailed Description

A dynamical system described by rational polynomial dynamics, and polynomial outputs.

If the system is time-varying, then it need not be polynomial in time (but for every time, it is polynomial in x and u).

Constructor & Destructor Documentation

function PolynomialSystem ( num_xc  ,
num_xd  ,
num_u  ,
num_y  ,
direct_feedthrough_flag  ,
time_invariant_flag  ,
rational_flag   
)

initialize PolynomialSystem

Return values
obj

Member Function Documentation

function cascade ( sys1  ,
sys2   
)

try to keep cascade between polynomial systems polynomial.

else, kick out to DrakeSystem

Return values
sys
function dynamics ( obj  ,
,
,
 
)
virtual
Return values
xcdot
dxcdot

Reimplemented from DrakeSystem.

Reimplemented in StochasticPolynomialSystem.

function dynamicsLHS ( obj  ,
,
,
 
)
Return values
e
de
function dynamicsRHS ( obj  ,
,
,
 
)
Return values
f
df
function extractAffineSystem ( obj  )
Return values
sys
function feedback ( sys1  ,
sys2   
)

try to keep feedback between polynomial systems polynomial.

else, kick out to DrakeSystem

Return values
sys
function getPolyDynamics ( obj  ,
 
)
Return values
p_dynamics_rhs
p_dynamics_lhs
function getPolyOutput ( obj  ,
 
)
Return values
p_output
function getPolyStateConstraints ( obj  )
Return values
p_state_constraints
function getPolyUpdate ( obj  ,
 
)
Return values
p_update
function inStateFrame ( sys  ,
frame   
)
Return values
sys
function isRational ( obj  )
Return values
tf
function plotVdot ( sys  ,
Vtraj  ,
ts  ,
options   
)
function regionOfAttraction ( sys  ,
varargin   
)

Estimates the region of attraction.

V = regionOfAttraction(sys,V0,options) uses the LyapunovFunction V0 as the initial guess V = regionOfAttraction(sys,x0,options) attempts to construct a LyapunovFunction around the fixed point x0

The resulting region of attraction is defined by the sub-level set V<=1 containing the origin in the LyapunovFunction reference frame.

Parameters
V0A LyapunovFunction object used as the initial candidate.
x0A fixed point of the system (if the system has inputs, they are set to zero)
Default: origin of the system's state frame
Return values
VThe verified Lyapunov candidate (with V<=1 verified)
Options:
method  The method to use. Must be one of 'bilinear','levelset','levelset_yalmip', 'binary', or 'sampling'. You may also pass in a cell array of methods to run them one after another (e.g. use options.method={'levelset','bilinear'} to use the levelset method to optimize the initial V0 before starting bilinear alternations).
degV  The degree of the Lyapunov function to search over.
Default: 2
degL  The degree of the Lagrange multiplier used in the S-procedure. It's implementation is method specific. Set degL to a vector if there are multiple Langrange multiplier degrees to set.
Default: the degree required to kill terms in the main polynomial.
max_iterations  The maximum number of iterations in the iterative methods (e.g. biinear)
converged_tol  The convergence tolerance in the iterative methods (e.g. bilinear). The algorithm terminates if the estimated volume changes by less than this percentage.
optimize  Set to false to simply check whether V0 is an ROA.
Default: true
numSamples  Number of samples to use (on every iteration)q if method is set to 'sampling'.
Default: 10^(dim(x)+2)
function sampledFiniteTimeReachability ( poly  ,
ts  ,
xtraj  ,
gTmss  ,
,
options   
)

Implements Henrion and Korda's SOS relaxation for computing finite time funnels.

Given an initial set B(0) and a description of the dynamics, this function gives a set B(t) corresponding to each time sample such that any state starting in B(0) is "guaranteed" to be in B(t) at time t. The dynamics are not explicitly modeled as a function of time since this requires having a large total degree (in t and x) of the approximating polynomial. Rather, the dynamics are sampled at finitely many points in time and the verification is performed at each sample point (just like the sampledFiniteTimeVerification.m function). This only affects the constraint that checks the "Vdot" condition. The two big advantages of this formulation are (1) a single convex program is solved to get B(t) for a given time and (2) the computations for different B(t)s are separate and thus can be parallelized.

Parameters
polyPolynomialTrajectorySystem that you want to verify
tsTime samples to verify conditions on
xtrajNominal trajectory about which funnel is computed
gTmssDescription of set of initial conditions B(0). gT must be a
RRadius of ball describing X (the big space in which everyting happens). Right now, I only allow this to be a ball, but we can easily extend this to ellipsoids too. In principle, you can do any semialgebraic set, but the number of multipliers required increases with the number of polynomials needed to describe the set. Also, Lebesgue moments have to be calculated on this set - this can be nontrivial.
Options:
clean_tol  Tolerance for cleaning stuff in yalmip spot polynomial (of arbitrary degree) which is > 0 on B(0).
degV  Degree of "Lyapunov function"
degW  Degree of "approximating function"
degq1  q1 multiplier degree (if you don't set this, I'll set it automatically by degree matching (based on degV and degW)
degq01  q01 multiplier degree (if you don't set this, I'll set it automatically by degree matching (based on degV and degW)
degqT  qT multiplier degree (if you don't set this, I'll set it automatically by degree matching (based on degV and degW)
degs0  s0 multiplier degree (if you don't set this, I'll set it automatically by degree matching (based on degV and degW)
backoff_percent  Percentage to back off on objective when resolving sos program (backing off helps with numerics)
Return values
Wopt
xs
function sampledFiniteTimeReachabilityFunnel ( sys  ,
polyOrig  ,
Vtraj0  ,
,
R0  ,
tv  ,
ts  ,
xtraj0  ,
utraj  ,
options  ,
Phi  ,
rho   
)

% Implements time-varying reachability computation.

The approach searches for a Lyapunov function and attempts to minimize the size of the funnel.

Parameters
sysTaylor expanded closed loop system (with tvlqr)
polyOrigTaylor expanded original system (not closed loop)
Vtraj0Initial guess for Lyapunov function
GTarget set description
tvTvlqr controller
tsTime samples
xtraj0Nominal trajectory
utrajNominal control input
optionsOptions structure
Options:
controller_deg  Degree of controller to search for
max_iterations  Maximum number of iterations (3 steps per iteration)
converged_tol  Tolerance for convergence
saturations  True if input saturations exist, False if not
rho0  Initial guess for rho
clean_tol  Tolerance for cleaning small terms
backoff_percent  Percentage to back off on objective (helps with numerics)
degL1  Multiplier degree
Lu  Multiplier degree
Lu1  Multiplier degree
Lu2  Multiplier degree
Lup  Multiplier degree
Lum  Multiplier degree
Return values
V
rho
Phi
function sampledFiniteTimeVerification ( sys  ,
ts  ,
,
varargin   
)

Attempts to find the largest funnel, defined by the time-varying one-level set of V, which verifies (using SOS over state at finite sample points in time) initial conditions to end inside the one-level set of the goal region G at time ts(end).

V = sampledFinitTimeVerification(sys,ts,G,V0,options) uses the LyapunovFunction V0 as the initial guess V = sampledFinitTimeVerification(sys,ts,G,x0,options) attempts to construct a LyapunovFunction around the trajectory x0

Parameters
sysPolynomialSystem that you want to verify.
tssample times
Gthe goal region. can be a PolynomialLyapunovFunction or a nX by nX matrix which defines a quadratic form centered at the goal.
V0a PolynomialLyapunovFunction which is the initial guess
x0a Trajectory in the state frame of sys around which an initial Lyapunov candidate is defined.
Options:
rho0_tau  initial rho (set large to make the initial guess drop rho quickly)
max_iterations  limit on number of alternations in bilinear search
converged_tol  tolerance (in units of cost-to-go) for bilinear alternations
stability  set to true to additionally verify that trajectories converge (exponentially) to x0 (or the origin in the V0 frame)
plot_rho  set to true for visual progress/debugging output
degL1  polynomial degree of the first lagrange multiplier
degL2  polynomial degree of the second lagrange multiplier
lyap_parameterization  specifies whether you search over the rescaling of the Lyapunov function (rho) or the entire Lyapunov Function (rhoS).
Return values
Va time-varying PolynomialLyapunovFunction who's one-level set defines the verified invariant region.

Implements the algorithm described in http://arxiv.org/pdf/1010.3013v1

function sampledTransverseVerification ( sys  ,
,
Vtraj0  ,
ts  ,
xtraj  ,
utraj  ,
transSurf  ,
options   
)

Attempts to find the largest funnel around xtraj using transverse surfaces.

Implements the algorithm described in "Transverse Dynamics and Regions of Stability for Nonlinear Hybrid Limit Cycles" by Ian R. Manchester http://arxiv.org/abs/1010.2241

Parameters
sysplant
Ggoal region (in one less dimension then the dynamics
Vtraj0initial guess at the lyapunov function
tstime span to verify over
xtrajtrajectory to verify over
utrajcontrol trajectory
transSurfTransversalSurface to use, usally created with TransversalSurface.design()
optionsstructure
Options:
rho0_tau  initial guess at scaling
Default: 2
max_iterations  maximum number of times to do bilinear optimization
Default: 10
convered_tol  convergence tolerance
Default: 0.01
stability  unimplemented (leave as false)
plot_rho  plot rho during optimization
Default: true degL1
Return values
VtrajXP
VtrajX
function setInputFrame ( obj  ,
frame   
)
Return values
obj
function setNumZeroCrossings ( obj  ,
num_zcs   
)
Return values
obj
function setRationalFlag ( obj  ,
tf   
)
Return values
obj
function setStateFrame ( obj  ,
frame   
)
Return values
obj
function timeReverse ( obj  )
Return values
polysys

The documentation for this class was generated from the following file: