42
42
# External packages and modules
43
43
import numpy as np
44
44
import scipy as sp
45
+ import warnings
45
46
46
47
from . import statesp
47
48
from .mateqn import care , dare , _check_shape
@@ -597,10 +598,10 @@ def dlqr(*args, **kwargs):
597
598
598
599
# Function to create an I/O sytems representing a state feedback controller
599
600
def create_statefbk_iosystem (
600
- sys , gain , integral_action = None , estimator = None , type = None ,
601
+ sys , gain , integral_action = None , estimator = None , controller_type = None ,
601
602
xd_labels = 'xd[{i}]' , ud_labels = 'ud[{i}]' , gainsched_indices = None ,
602
603
gainsched_method = 'linear' , name = None , inputs = None , outputs = None ,
603
- states = None ):
604
+ states = None , ** kwargs ):
604
605
"""Create an I/O system using a (full) state feedback controller
605
606
606
607
This function creates an input/output system that implements a
@@ -684,7 +685,7 @@ def create_statefbk_iosystem(
684
685
hull of the scheduling points, the gain at the nearest point is
685
686
used.
686
687
687
- type : 'linear' or 'nonlinear', optional
688
+ controller_type : 'linear' or 'nonlinear', optional
688
689
Set the type of controller to create. The default for a linear gain
689
690
is a linear controller implementing the LQR regulator. If the type
690
691
is 'nonlinear', a :class:NonlinearIOSystem is created instead, with
@@ -728,6 +729,18 @@ def create_statefbk_iosystem(
728
729
if not isinstance (sys , InputOutputSystem ):
729
730
raise ControlArgument ("Input system must be I/O system" )
730
731
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
+
731
744
# See whether we were give an estimator
732
745
if estimator is not None :
733
746
# Check to make sure the estimator is the right size
@@ -781,13 +794,14 @@ def create_statefbk_iosystem(
781
794
raise ControlArgument ("gain must be an array or a tuple" )
782
795
783
796
# Decide on the type of system to create
784
- if gainsched and type == 'linear' :
797
+ if gainsched and controller_type == 'linear' :
785
798
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 } '" )
791
805
792
806
# Figure out the labels to use
793
807
if isinstance (xd_labels , str ):
@@ -845,7 +859,7 @@ def _compute_gain(mu):
845
859
return K
846
860
847
861
# Define the controller system
848
- if type == 'nonlinear' :
862
+ if controller_type == 'nonlinear' :
849
863
# Create an I/O system for the state feedback gains
850
864
def _control_update (t , states , inputs , params ):
851
865
# Split input into desired state, nominal input, and current state
@@ -879,7 +893,7 @@ def _control_output(t, states, inputs, params):
879
893
_control_update , _control_output , name = name , inputs = inputs ,
880
894
outputs = outputs , states = states , params = params )
881
895
882
- elif type == 'linear' or type is None :
896
+ elif controller_type == 'linear' or controller_type is None :
883
897
# Create the matrices implementing the controller
884
898
if isctime (sys ):
885
899
# Continuous time: integrator
@@ -898,7 +912,7 @@ def _control_output(t, states, inputs, params):
898
912
inputs = inputs , outputs = outputs , states = states )
899
913
900
914
else :
901
- raise ControlArgument (f"unknown type '{ type } '" )
915
+ raise ControlArgument (f"unknown controller_type '{ controller_type } '" )
902
916
903
917
# Define the closed loop system
904
918
closed = interconnect (
0 commit comments