4242# External packages and modules
4343import numpy as np
4444import scipy as sp
45+ import warnings
4546
4647from . import statesp
4748from .mateqn import care , dare , _check_shape
@@ -597,10 +598,10 @@ def dlqr(*args, **kwargs):
597598
598599# Function to create an I/O sytems representing a state feedback controller
599600def create_statefbk_iosystem (
600- sys , gain , integral_action = None , estimator = None , type = None ,
601+ sys , gain , integral_action = None , estimator = None , controller_type = None ,
601602 xd_labels = 'xd[{i}]' , ud_labels = 'ud[{i}]' , gainsched_indices = None ,
602603 gainsched_method = 'linear' , name = None , inputs = None , outputs = None ,
603- states = None ):
604+ states = None , ** kwargs ):
604605 """Create an I/O system using a (full) state feedback controller
605606
606607 This function creates an input/output system that implements a
@@ -684,7 +685,7 @@ def create_statefbk_iosystem(
684685 hull of the scheduling points, the gain at the nearest point is
685686 used.
686687
687- type : 'linear' or 'nonlinear', optional
688+ controller_type : 'linear' or 'nonlinear', optional
688689 Set the type of controller to create. The default for a linear gain
689690 is a linear controller implementing the LQR regulator. If the type
690691 is 'nonlinear', a :class:NonlinearIOSystem is created instead, with
@@ -728,6 +729,18 @@ def create_statefbk_iosystem(
728729 if not isinstance (sys , InputOutputSystem ):
729730 raise ControlArgument ("Input system must be I/O system" )
730731
732+ # Process (legacy) keywords
733+ if kwargs .get ('type' ) is not None :
734+ warnings .warn (
735+ "keyword 'type' is deprecated; use 'controller_type'" ,
736+ DeprecationWarning )
737+ if controller_type is not None :
738+ raise ControlArgument (
739+ "duplicate keywords 'type` and 'controller_type'" )
740+ controller_type = kwargs .pop ('type' )
741+ if kwargs :
742+ raise TypeError ("unrecognized keywords: " , str (kwargs ))
743+
731744 # See whether we were give an estimator
732745 if estimator is not None :
733746 # Check to make sure the estimator is the right size
@@ -781,13 +794,14 @@ def create_statefbk_iosystem(
781794 raise ControlArgument ("gain must be an array or a tuple" )
782795
783796 # Decide on the type of system to create
784- if gainsched and type == 'linear' :
797+ if gainsched and controller_type == 'linear' :
785798 raise ControlArgument (
786- "type 'linear' not allowed for gain scheduled controller" )
787- elif type is None :
788- type = 'nonlinear' if gainsched else 'linear'
789- elif type not in {'linear' , 'nonlinear' }:
790- raise ControlArgument (f"unknown type '{ type } '" )
799+ "controller_type 'linear' not allowed for"
800+ " gain scheduled controller" )
801+ elif controller_type is None :
802+ controller_type = 'nonlinear' if gainsched else 'linear'
803+ elif controller_type not in {'linear' , 'nonlinear' }:
804+ raise ControlArgument (f"unknown controller_type '{ controller_type } '" )
791805
792806 # Figure out the labels to use
793807 if isinstance (xd_labels , str ):
@@ -845,7 +859,7 @@ def _compute_gain(mu):
845859 return K
846860
847861 # Define the controller system
848- if type == 'nonlinear' :
862+ if controller_type == 'nonlinear' :
849863 # Create an I/O system for the state feedback gains
850864 def _control_update (t , states , inputs , params ):
851865 # Split input into desired state, nominal input, and current state
@@ -879,7 +893,7 @@ def _control_output(t, states, inputs, params):
879893 _control_update , _control_output , name = name , inputs = inputs ,
880894 outputs = outputs , states = states , params = params )
881895
882- elif type == 'linear' or type is None :
896+ elif controller_type == 'linear' or controller_type is None :
883897 # Create the matrices implementing the controller
884898 if isctime (sys ):
885899 # Continuous time: integrator
@@ -898,7 +912,7 @@ def _control_output(t, states, inputs, params):
898912 inputs = inputs , outputs = outputs , states = states )
899913
900914 else :
901- raise ControlArgument (f"unknown type '{ type } '" )
915+ raise ControlArgument (f"unknown controller_type '{ controller_type } '" )
902916
903917 # Define the closed loop system
904918 closed = interconnect (
0 commit comments