Drake
PidControlledSystem< T > Class Template Reference

A system that encapsulates a PidController and a controlled System (a.k.a the "plant"). More...

#include <drake/systems/controllers/pid_controlled_system.h>

Inheritance diagram for PidControlledSystem< T >:
[legend]
Collaboration diagram for PidControlledSystem< T >:
[legend]

Classes

struct  ConnectResult
 The return type of ConnectController. More...
 

Public Member Functions

 PidControlledSystem (std::unique_ptr< System< T >> plant, double Kp, double Ki, double Kd)
 plant full state is used for feedback control, and all the dimensions have homogeneous gains specified by Kp, Kd and Ki. More...
 
 PidControlledSystem (std::unique_ptr< System< T >> plant, const Eigen::VectorXd &Kp, const Eigen::VectorXd &Ki, const Eigen::VectorXd &Kd)
 plant full state is used for feedback control, and the vectorized gains are specified by Kp, Kd and Ki. More...
 
 PidControlledSystem (std::unique_ptr< System< T >> plant, const MatrixX< double > &feedback_selector, double Kp, double Ki, double Kd)
 A constructor where the gains are scalar values and some of the plant's output is part of the feedback signal as specified by feedback_selector. More...
 
 PidControlledSystem (std::unique_ptr< System< T >> plant, const MatrixX< double > &feedback_selector, const Eigen::VectorXd &Kp, const Eigen::VectorXd &Ki, const Eigen::VectorXd &Kd)
 A constructor where the gains are vector values and some of the plant's output is part of the feedback signal as specified by feedback_selector. More...
 
 ~PidControlledSystem () override
 
System< T > * plant ()
 
const InputPort< T > & get_control_input_port () const
 
const InputPort< T > & get_state_input_port () const
 
const OutputPort< T > & get_state_output_port () const
 
Does not allow copy, move, or assignment
 PidControlledSystem (const PidControlledSystem &)=delete
 
PidControlledSystemoperator= (const PidControlledSystem &)=delete
 
 PidControlledSystem (PidControlledSystem &&)=delete
 
PidControlledSystemoperator= (PidControlledSystem &&)=delete
 
- Public Member Functions inherited from Diagram< T >
template<typename U >
 Diagram (const Diagram< U > &other)
 Scalar-converting copy constructor. See System Scalar Conversion. More...
 
 ~Diagram () override
 
std::vector< const systems::System< T > * > GetSystems () const
 Returns the list of contained Systems. More...
 
std::multimap< int, intGetDirectFeedthroughs () const final
 Reports all direct feedthroughs from input ports to output ports. More...
 
std::unique_ptr< CompositeEventCollection< T > > AllocateCompositeEventCollection () const final
 Allocates a DiagramEventCollection for this Diagram. More...
 
void SetDefaultState (const Context< T > &context, State< T > *state) const override
 Assigns default values to all elements of the state. More...
 
void SetDefaultParameters (const Context< T > &context, Parameters< T > *params) const override
 Assigns default values to all parameters. More...
 
void SetRandomState (const Context< T > &context, State< T > *state, RandomGenerator *generator) const override
 Assigns random values to all elements of the state. More...
 
void SetRandomParameters (const Context< T > &context, Parameters< T > *params, RandomGenerator *generator) const override
 Assigns random values to all parameters. More...
 
std::unique_ptr< ContinuousState< T > > AllocateTimeDerivatives () const override
 Aggregates the time derivatives from each subsystem into a DiagramContinuousState. More...
 
std::unique_ptr< DiscreteValues< T > > AllocateDiscreteVariables () const override
 Aggregates the discrete update variables from each subsystem into a DiagramDiscreteVariables. More...
 
void DoCalcTimeDerivatives (const Context< T > &context, ContinuousState< T > *derivatives) const override
 Override this if you have any continuous state variables xc in your concrete System to calculate their time derivatives. More...
 
const ContinuousState< T > & GetSubsystemDerivatives (const ContinuousState< T > &derivatives, const System< T > *subsystem) const
 Retrieves the state derivatives for a particular subsystem from the derivatives for the entire diagram. More...
 
const Context< T > & GetSubsystemContext (const System< T > &subsystem, const Context< T > &context) const
 Returns a constant reference to the subcontext that corresponds to the system subsystem. More...
 
Context< T > & GetMutableSubsystemContext (const System< T > &subsystem, Context< T > *context) const
 Returns the subcontext that corresponds to the system subsystem. More...
 
const CompositeEventCollection< T > & GetSubsystemCompositeEventCollection (const System< T > &subsystem, const CompositeEventCollection< T > &events) const
 Returns the const subsystem composite event collection from events that corresponds to subsystem. More...
 
CompositeEventCollection< T > & GetMutableSubsystemCompositeEventCollection (const System< T > &subsystem, CompositeEventCollection< T > *events) const
 Returns the mutable subsystem composite event collection that corresponds to subsystem. More...
 
State< T > & GetMutableSubsystemState (const System< T > &subsystem, Context< T > *context) const
 Retrieves the state for a particular subsystem from the context for the entire diagram. More...
 
State< T > & GetMutableSubsystemState (const System< T > &subsystem, State< T > *state) const
 Retrieves the state for a particular subsystem from the state for the entire diagram. More...
 
const State< T > & GetSubsystemState (const System< T > &subsystem, const State< T > &state) const
 Retrieves the state for a particular subsystem from the state for the entire diagram. More...
 
SubsystemIndex GetSystemIndexOrAbort (const System< T > *sys) const
 Returns the index of the given sys in this diagram, or aborts if sys is not a member of the diagram. More...
 
 Diagram (const Diagram &)=delete
 
Diagramoperator= (const Diagram &)=delete
 
 Diagram (Diagram &&)=delete
 
Diagramoperator= (Diagram &&)=delete
 
void GetGraphvizFragment (std::stringstream *dot) const override
 Returns a Graphviz fragment describing this Diagram. More...
 
void GetGraphvizInputPortToken (const InputPort< T > &port, std::stringstream *dot) const override
 Appends a fragment to the dot stream identifying the graphviz node representing port. More...
 
void GetGraphvizOutputPortToken (const OutputPort< T > &port, std::stringstream *dot) const override
 Appends a fragment to the dot stream identifying the graphviz node representing port. More...
 
- Public Member Functions inherited from System< T >
 ~System () override=default
 
void GetWitnessFunctions (const Context< T > &context, std::vector< const WitnessFunction< T > * > *w) const
 Gets the witness functions active for the given state. More...
 
CalcWitnessValue (const Context< T > &context, const WitnessFunction< T > &witness_func) const
 Evaluates a witness function at the given context. More...
 
 System (const System &)=delete
 
Systemoperator= (const System &)=delete
 
 System (System &&)=delete
 
Systemoperator= (System &&)=delete
 
std::unique_ptr< Context< T > > AllocateContext () const
 Returns a Context<T> suitable for use with this System<T>. More...
 
std::unique_ptr< BasicVector< T > > AllocateInputVector (const InputPort< T > &input_port) const
 Given an input port, allocates the vector storage. More...
 
std::unique_ptr< AbstractValueAllocateInputAbstract (const InputPort< T > &input_port) const
 Given an input port, allocates the abstract storage. More...
 
std::unique_ptr< SystemOutput< T > > AllocateOutput () const
 Returns a container that can hold the values of all of this System's output ports. More...
 
std::unique_ptr< Context< T > > CreateDefaultContext () const
 This convenience method allocates a context using AllocateContext() and sets its default values using SetDefaultContext(). More...
 
void SetDefaultContext (Context< T > *context) const
 
void SetRandomContext (Context< T > *context, RandomGenerator *generator) const
 
void AllocateFixedInputs (Context< T > *context) const
 For each input port, allocates a fixed input of the concrete type that this System requires, and binds it to the port, disconnecting any prior input. More...
 
bool HasAnyDirectFeedthrough () const
 Returns true if any of the inputs to the system might be directly fed through to any of its outputs and false otherwise. More...
 
bool HasDirectFeedthrough (int output_port) const
 Returns true if there might be direct-feedthrough from any input port to the given output_port, and false otherwise. More...
 
bool HasDirectFeedthrough (int input_port, int output_port) const
 Returns true if there might be direct-feedthrough from the given input_port to the given output_port, and false otherwise. More...
 
void Publish (const Context< T > &context, const EventCollection< PublishEvent< T >> &events) const
 This method is the public entry point for dispatching all publish event handlers. More...
 
void Publish (const Context< T > &context) const
 Forces a publish on the system, given a context. More...
 
const T & EvalConservativePower (const Context< T > &context) const
 Returns a reference to the cached value of the conservative power. More...
 
const T & EvalNonConservativePower (const Context< T > &context) const
 Returns a reference to the cached value of the non-conservative power. More...
 
template<template< typename > class Vec = BasicVector>
const Vec< T > * EvalVectorInput (const Context< T > &context, int port_index) const
 Returns the value of the vector-valued input port with the given port_index as a BasicVector or a specific subclass Vec derived from BasicVector. More...
 
Eigen::VectorBlock< const VectorX< T > > EvalEigenVectorInput (const Context< T > &context, int port_index) const
 Returns the value of the vector-valued input port with the given port_index as an Eigen vector. More...
 
int get_num_constraint_equations (const Context< T > &context) const
 Gets the number of constraint equations for this system using the given context (useful in case the number of constraints is dependent upon the current state (as might be the case with a system modeled using piecewise differential algebraic equations). More...
 
Eigen::VectorXd EvalConstraintEquations (const Context< T > &context) const
 Evaluates the constraint equations for the system at the generalized coordinates and generalized velocity specified by the context. More...
 
Eigen::VectorXd EvalConstraintEquationsDot (const Context< T > &context) const
 Computes the time derivative of each constraint equation, evaluated at the generalized coordinates and generalized velocity specified by the context. More...
 
Eigen::VectorXd CalcVelocityChangeFromConstraintImpulses (const Context< T > &context, const Eigen::MatrixXd &J, const Eigen::VectorXd &lambda) const
 Computes the change in velocity from applying the given constraint forces to the system at the given context. More...
 
double CalcConstraintErrorNorm (const Context< T > &context, const Eigen::VectorXd &error) const
 Computes the norm on constraint error (used as a metric for comparing errors between the outputs of algebraic equations applied to two different state variable instances). More...
 
void CalcTimeDerivatives (const Context< T > &context, ContinuousState< T > *derivatives) const
 Calculates the time derivatives xcdot of the continuous state xc. More...
 
void CalcDiscreteVariableUpdates (const Context< T > &context, const EventCollection< DiscreteUpdateEvent< T >> &events, DiscreteValues< T > *discrete_state) const
 This method is the public entry point for dispatching all discrete variable update event handlers. More...
 
void CalcDiscreteVariableUpdates (const Context< T > &context, DiscreteValues< T > *discrete_state) const
 This method forces a discrete update on the system given a context, and the updated discrete state is stored in discrete_state. More...
 
void CalcUnrestrictedUpdate (const Context< T > &context, const EventCollection< UnrestrictedUpdateEvent< T >> &events, State< T > *state) const
 This method is the public entry point for dispatching all unrestricted update event handlers. More...
 
void CalcUnrestrictedUpdate (const Context< T > &context, State< T > *state) const
 This method forces an unrestricted update on the system given a context, and the updated state is stored in state. More...
 
CalcNextUpdateTime (const Context< T > &context, CompositeEventCollection< T > *events) const
 This method is called by a Simulator during its calculation of the size of the next continuous step to attempt. More...
 
void GetPerStepEvents (const Context< T > &context, CompositeEventCollection< T > *events) const
 This method is called by Simulator::Initialize() to gather all update and publish events that are to be handled in StepTo() at the point before Simulator integrates continuous state. More...
 
void GetInitializationEvents (const Context< T > &context, CompositeEventCollection< T > *events) const
 This method is called by Simulator::Initialize() to gather all update and publish events that need to be handled at initialization before the simulator starts integration. More...
 
optional< PeriodicEventDataGetUniquePeriodicDiscreteUpdateAttribute () const
 Gets whether there exists a unique periodic attribute that triggers one or more discrete update events (and, if so, returns that unique periodic attribute). More...
 
std::map< PeriodicEventData, std::vector< const Event< T > * >, PeriodicEventDataComparatorGetPeriodicEvents () const
 Gets all periodic triggered events for a system. More...
 
void CalcOutput (const Context< T > &context, SystemOutput< T > *outputs) const
 Utility method that computes for every output port i the value y(i) that should result from the current contents of the given Context. More...
 
CalcPotentialEnergy (const Context< T > &context) const
 Calculates and returns the potential energy current stored in the configuration provided in context. More...
 
CalcKineticEnergy (const Context< T > &context) const
 Calculates and returns the kinetic energy currently present in the motion provided in the given Context. More...
 
CalcConservativePower (const Context< T > &context) const
 Calculates and returns the rate at which mechanical energy is being converted from potential energy to kinetic energy by this system in the given Context. More...
 
CalcNonConservativePower (const Context< T > &context) const
 Calculates and returns the rate at which mechanical energy is being generated (positive) or dissipated (negative) other than by conversion between potential and kinetic energy (in the given Context). More...
 
void MapVelocityToQDot (const Context< T > &context, const VectorBase< T > &generalized_velocity, VectorBase< T > *qdot) const
 Transforms a given generalized velocity v to the time derivative qdot of the generalized configuration q taken from the supplied Context. More...
 
void MapVelocityToQDot (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &generalized_velocity, VectorBase< T > *qdot) const
 Transforms the given generalized velocity to the time derivative of generalized configuration. More...
 
void MapQDotToVelocity (const Context< T > &context, const VectorBase< T > &qdot, VectorBase< T > *generalized_velocity) const
 Transforms the time derivative qdot of the generalized configuration q to generalized velocities v. More...
 
void MapQDotToVelocity (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &qdot, VectorBase< T > *generalized_velocity) const
 Transforms the given time derivative qdot of generalized configuration q to generalized velocity v. More...
 
std::string GetMemoryObjectName () const
 Returns a name for this System based on a stringification of its type name and memory address. More...
 
const InputPort< T > & get_input_port (int port_index) const
 Returns the typed input port at index port_index. More...
 
const OutputPort< T > & get_output_port (int port_index) const
 Returns the typed output port at index port_index. More...
 
int get_num_constraints () const
 Returns the number of constraints specified for the system. More...
 
const SystemConstraint< T > & get_constraint (SystemConstraintIndex constraint_index) const
 Returns the constraint at index constraint_index. More...
 
bool CheckSystemConstraintsSatisfied (const Context< T > &context, double tol) const
 Returns true if context satisfies all of the registered SystemConstraints with tolerance tol. More...
 
void CheckValidOutput (const SystemOutput< T > *output) const
 Checks that output is consistent with the number and size of output ports declared by the system. More...
 
template<typename T1 = T>
void CheckValidContextT (const Context< T1 > &context) const
 Checks that context is consistent for this System template. More...
 
VectorX< T > CopyContinuousStateVector (const Context< T > &context) const
 Returns a copy of the continuous state vector xc into an Eigen vector. More...
 
std::string GetGraphvizString () const
 Returns a Graphviz string describing this System. More...
 
int64_t GetGraphvizId () const
 Returns an opaque integer that uniquely identifies this system in the Graphviz output. More...
 
void FixInputPortsFrom (const System< double > &other_system, const Context< double > &other_context, Context< T > *target_context) const
 Fixes all of the input ports in target_context to their current values in other_context, as evaluated by other_system. More...
 
const SystemScalarConverterget_system_scalar_converter () const
 (Advanced) Returns the SystemScalarConverter for this object. More...
 
std::unique_ptr< System< AutoDiffXd > > ToAutoDiffXd () const
 Creates a deep copy of this System, transmogrified to use the autodiff scalar type, with a dynamic-sized vector of partial derivatives. More...
 
std::unique_ptr< System< AutoDiffXd > > ToAutoDiffXdMaybe () const
 Creates a deep copy of this system exactly like ToAutoDiffXd(), but returns nullptr if this System does not support autodiff, instead of throwing an exception. More...
 
std::unique_ptr< System< symbolic::Expression > > ToSymbolic () const
 Creates a deep copy of this System, transmogrified to use the symbolic scalar type. More...
 
std::unique_ptr< System< symbolic::Expression > > ToSymbolicMaybe () const
 Creates a deep copy of this system exactly like ToSymbolic(), but returns nullptr if this System does not support symbolic, instead of throwing an exception. More...
 
- Public Member Functions inherited from SystemBase
 ~SystemBase () override
 
void set_name (const std::string &name)
 Sets the name of the system. More...
 
const std::string & get_name () const
 Returns the name last supplied to set_name(), if any. More...
 
const std::string & GetSystemName () const final
 Returns a human-readable name for this system, for use in messages and logging. More...
 
std::string GetSystemPathname () const final
 Generates and returns a human-readable full path name of this subsystem, for use in messages and logging. More...
 
std::string GetSystemType () const final
 Returns the most-derived type of this concrete System object as a human-readable string suitable for use in error messages. More...
 
void ThrowIfContextNotCompatible (const ContextBase &context) const final
 Throws an exception with an appropriate message if the given context is not compatible with this System. More...
 
std::unique_ptr< ContextBaseAllocateContext () const
 Returns a Context suitable for use with this System. More...
 
int get_num_input_ports () const
 Returns the number of input ports currently allocated in this System. More...
 
int get_num_output_ports () const
 Returns the number of output ports currently allocated in this System. More...
 
const InputPortBaseget_input_port_base (InputPortIndex port_index) const
 Returns a reference to an InputPort given its port_index. More...
 
const OutputPortBaseget_output_port_base (OutputPortIndex port_index) const
 Returns a reference to an OutputPort given its port_index. More...
 
int get_num_total_inputs () const
 Returns the total dimension of all of the vector-valued input ports (as if they were muxed). More...
 
int get_num_total_outputs () const
 Returns the total dimension of all of the vector-valued output ports (as if they were muxed). More...
 
int num_cache_entries () const
 Returns the number nc of cache entries currently allocated in this System. More...
 
const CacheEntryget_cache_entry (CacheIndex index) const
 Return a reference to a CacheEntry given its index. More...
 
void CheckValidContext (const ContextBase &context) const
 Checks whether the given context is valid for this System and throws an exception with a helpful message if not. More...
 
 SystemBase (const SystemBase &)=delete
 
SystemBaseoperator= (const SystemBase &)=delete
 
 SystemBase (SystemBase &&)=delete
 
SystemBaseoperator= (SystemBase &&)=delete
 
const AbstractValueEvalAbstractInput (const ContextBase &context, int port_index) const
 Returns the value of the input port with the given port_index as an AbstractValue, which is permitted for ports of any type. More...
 
template<typename V >
const V * EvalInputValue (const ContextBase &context, int port_index) const
 Returns the value of an abstract-valued input port with the given port_index as a value of known type V. More...
 
const CacheEntryDeclareCacheEntry (std::string description, CacheEntry::AllocCallback alloc_function, CacheEntry::CalcCallback calc_function, std::set< DependencyTicket > prerequisites_of_calc={all_sources_ticket()})
 Declares a new CacheEntry in this System using the least-restrictive definitions for the associated functions. More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, ValueType(MySystem::*make)() const, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={all_sources_ticket()})
 Declares a cache entry by specifying member functions to use both for the allocator and calculator. More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, const ValueType &model_value, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={all_sources_ticket()})
 Declares a cache entry by specifying a model value of concrete type ValueType and a calculator function that is a class member function (method) with signature: More...
 
template<class MySystem , class MyContext , typename ValueType >
const CacheEntryDeclareCacheEntry (std::string description, void(MySystem::*calc)(const MyContext &, ValueType *) const, std::set< DependencyTicket > prerequisites_of_calc={all_sources_ticket()})
 Declares a cache entry by specifying only a calculator function that is a class member function (method) with signature: More...
 
DependencyTicket input_port_ticket (InputPortIndex index)
 Returns a ticket indicating dependence on the input port indicated by index. More...
 
DependencyTicket output_port_ticket (OutputPortIndex index)
 Returns a ticket indicating dependence on the output port indicated by index. More...
 
DependencyTicket cache_entry_ticket (CacheIndex index)
 Returns a ticket indicating dependence on the cache entry indicated by index. More...
 
int num_discrete_state_groups () const
 Returns the number of declared discrete state groups (each group is a vector-valued discrete state variable). More...
 
int num_abstract_states () const
 Returns the number of declared abstract state variables. More...
 
int num_numeric_parameters () const
 Returns the number of declared numeric parameters (each of these is a vector-valued parameter). More...
 
int num_abstract_parameters () const
 Returns the number of declared abstract parameters. More...
 
DependencyTicket discrete_state_ticket (DiscreteStateIndex index) const
 Returns a ticket indicating dependence on a particular discrete state variable (may be a vector). More...
 
DependencyTicket abstract_state_ticket (AbstractStateIndex index) const
 Returns a ticket indicating dependence on a particular abstract state variable. More...
 
DependencyTicket numeric_parameter_ticket (NumericParameterIndex index) const
 Returns a ticket indicating dependence on a particular numeric parameter (may be a vector). More...
 
DependencyTicket abstract_parameter_ticket (AbstractParameterIndex index) const
 Returns a ticket indicating dependence on a particular abstract parameter. More...
 

Static Public Member Functions

static ConnectResult ConnectController (const InputPort< T > &plant_input, const OutputPort< T > &plant_output, const MatrixX< double > &feedback_selector, const Eigen::VectorXd &Kp, const Eigen::VectorXd &Ki, const Eigen::VectorXd &Kd, DiagramBuilder< T > *builder)
 Creates a PidController and uses builder to connect plant_input and plant_output from an existing plant. More...
 
static ConnectResult ConnectController (const InputPort< T > &plant_input, const OutputPort< T > &plant_output, const Eigen::VectorXd &Kp, const Eigen::VectorXd &Ki, const Eigen::VectorXd &Kd, DiagramBuilder< T > *builder)
 Creates a PidController and uses builder to connect plant_input and plant_output from an existing plant. More...
 
static ConnectResult ConnectControllerWithInputSaturation (const InputPort< T > &plant_input, const OutputPort< T > &plant_output, const MatrixX< double > &feedback_selector, const Eigen::VectorXd &Kp, const Eigen::VectorXd &Ki, const Eigen::VectorXd &Kd, const VectorX< T > &min_plant_input, const VectorX< T > &max_plant_input, DiagramBuilder< T > *builder)
 Creates a PidController with input saturation and uses builder to connect plant_input and plant_output from an existing plant. More...
 
static ConnectResult ConnectControllerWithInputSaturation (const InputPort< T > &plant_input, const OutputPort< T > &plant_output, const Eigen::VectorXd &Kp, const Eigen::VectorXd &Ki, const Eigen::VectorXd &Kd, const VectorX< T > &min_plant_input, const VectorX< T > &max_plant_input, DiagramBuilder< T > *builder)
 Creates a PidController with input saturation and uses builder to connect plant_input and plant_output from an existing plant. More...
 
- Static Public Member Functions inherited from System< T >
template<template< typename > class S = ::drake::systems::System>
static std::unique_ptr< S< AutoDiffXd > > ToAutoDiffXd (const S< T > &from)
 Creates a deep copy of from, transmogrified to use the autodiff scalar type, with a dynamic-sized vector of partial derivatives. More...
 
template<template< typename > class S = ::drake::systems::System>
static std::unique_ptr< S< symbolic::Expression > > ToSymbolic (const S< T > &from)
 Creates a deep copy of from, transmogrified to use the symbolic scalar type. More...
 
- Static Public Member Functions inherited from SystemBase
static DependencyTicket all_sources_ticket ()
 Returns a ticket indicating dependence on every possible independent source value, including time, state, input ports, parameters, and the accuracy setting (but not cache entries). More...
 
static DependencyTicket nothing_ticket ()
 Returns a ticket indicating that a computation does not depend on any source value; that is, it is a constant. More...
 
static DependencyTicket time_ticket ()
 Returns a ticket indicating dependence on time. More...
 
static DependencyTicket accuracy_ticket ()
 Returns a ticket indicating dependence on the accuracy setting in the Context. More...
 
static DependencyTicket q_ticket ()
 Returns a ticket indicating that a computation depends on configuration state variables q. More...
 
static DependencyTicket v_ticket ()
 Returns a ticket indicating dependence on velocity state variables v. More...
 
static DependencyTicket z_ticket ()
 Returns a ticket indicating dependence on all of the miscellaneous continuous state variables z. More...
 
static DependencyTicket xc_ticket ()
 Returns a ticket indicating dependence on all of the continuous state variables q, v, or z. More...
 
static DependencyTicket xd_ticket ()
 Returns a ticket indicating dependence on all of the numerical discrete state variables, in any discrete variable group. More...
 
static DependencyTicket xa_ticket ()
 Returns a ticket indicating dependence on all of the abstract state variables in the current Context. More...
 
static DependencyTicket all_state_ticket ()
 Returns a ticket indicating dependence on all state variables x in this system, including continuous variables xc, discrete (numeric) variables xd, and abstract state variables xa. More...
 
static DependencyTicket xcdot_ticket ()
 Returns a ticket for the cache entry that holds time derivatives of the continuous variables. More...
 
static DependencyTicket xdhat_ticket ()
 Returns a ticket for the cache entry that holds the discrete state update for the numerical discrete variables in the state. More...
 
static DependencyTicket configuration_ticket ()
 Returns a ticket indicating dependence on all the configuration variables for this System. More...
 
static DependencyTicket velocity_ticket ()
 (Advanced) Returns a ticket indicating dependence on all of the velocity variables, but not the configuration variables for this System. More...
 
static DependencyTicket kinematics_ticket ()
 Returns a ticket indicating dependence on all of the configuration and velocity state variables of this System. More...
 
static DependencyTicket all_parameters_ticket ()
 Returns a ticket indicating dependence on all parameters p in this system, including numeric parameters pn, and abstract parameters pa. More...
 
static DependencyTicket all_input_ports_ticket ()
 Returns a ticket indicating dependence on all input ports u of this system. More...
 

Additional Inherited Members

- Public Types inherited from Diagram< T >
using InputPortLocator = std::pair< const System< T > *, InputPortIndex >
 
using OutputPortLocator = std::pair< const System< T > *, OutputPortIndex >
 
- Protected Member Functions inherited from Diagram< T >
 Diagram ()
 Constructs an uninitialized Diagram. More...
 
 Diagram (SystemScalarConverter converter)
 (Advanced) Constructs an uninitialized Diagram. More...
 
DoCalcWitnessValue (const Context< T > &context, const WitnessFunction< T > &witness_func) const final
 For the subsystem associated with witness_func, gets its subcontext from context, passes the subcontext to witness_func' Evaulate method and returns the result. More...
 
void AddTriggeredWitnessFunctionToCompositeEventCollection (Event< T > *event, CompositeEventCollection< T > *events) const final
 For the subsystem associated with witness_func, gets its mutable sub composite event collection from events, and passes it to witness_func's AddEventToCollection method. More...
 
void DoGetWitnessFunctions (const Context< T > &context, std::vector< const WitnessFunction< T > * > *witnesses) const final
 Provides witness functions of subsystems that are active at the beginning of a continuous time interval. More...
 
Context< T > * DoGetMutableTargetSystemContext (const System< T > &target_system, Context< T > *context) const final
 Returns a pointer to mutable context if target_system is a sub system of this, nullptr is returned otherwise. More...
 
const Context< T > * DoGetTargetSystemContext (const System< T > &target_system, const Context< T > *context) const final
 Returns a pointer to const context if target_system is a subsystem of this, nullptr is returned otherwise. More...
 
State< T > * DoGetMutableTargetSystemState (const System< T > &target_system, State< T > *state) const final
 Returns a pointer to mutable state if target_system is a subsystem of this, nullptr is returned otherwise. More...
 
const ContinuousState< T > * DoGetTargetSystemContinuousState (const System< T > &target_system, const ContinuousState< T > *xc) const final
 Returns a pointer to const state if target_system is a subsystem of this, nullptr is returned otherwise. More...
 
const State< T > * DoGetTargetSystemState (const System< T > &target_system, const State< T > *state) const final
 Returns a pointer to const state if target_system is a subsystem of this, nullptr is returned otherwise. More...
 
CompositeEventCollection< T > * DoGetMutableTargetSystemCompositeEventCollection (const System< T > &target_system, CompositeEventCollection< T > *events) const final
 Returns a pointer to mutable composite event collection if target_system is a subsystem of this, nullptr is returned otherwise. More...
 
const CompositeEventCollection< T > * DoGetTargetSystemCompositeEventCollection (const System< T > &target_system, const CompositeEventCollection< T > *events) const final
 Returns a pointer to const composite event collection if target_system is a subsystem of this, nullptr is returned otherwise. More...
 
void DoMapVelocityToQDot (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &generalized_velocity, VectorBase< T > *qdot) const override
 The generalized_velocity vector must have the same size and ordering as the generalized velocity in the ContinuousState that this Diagram reserves in its context. More...
 
void DoMapQDotToVelocity (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &qdot, VectorBase< T > *generalized_velocity) const override
 The generalized_velocity vector must have the same size and ordering as the generalized velocity in the ContinuousState that this Diagram reserves in its context. More...
 
void DoCalcNextUpdateTime (const Context< T > &context, CompositeEventCollection< T > *event_info, T *time) const override
 Computes the next update time based on the configured actions, for scalar types that are arithmetic, or aborts for scalar types that are not arithmetic. More...
 
BasicVector< T > * DoAllocateInputVector (const InputPort< T > &input_port) const override
 Allocates an input vector of the leaf type that the System requires on the port specified by input_port. More...
 
AbstractValueDoAllocateInputAbstract (const InputPort< T > &input_port) const override
 Allocates an abstract input of the leaf type that the System requires on the port specified by input_port. More...
 
- Protected Member Functions inherited from System< T >
SystemConstraintIndex AddConstraint (std::unique_ptr< SystemConstraint< T >> constraint)
 Adds an already-created constraint to the list of constraints for this System. More...
 
const EventCollection< PublishEvent< T > > & get_forced_publish_events () const
 
const EventCollection< DiscreteUpdateEvent< T > > & get_forced_discrete_update_events () const
 
const EventCollection< UnrestrictedUpdateEvent< T > > & get_forced_unrestricted_update_events () const
 
void set_forced_publish_events (std::unique_ptr< EventCollection< PublishEvent< T >>> forced)
 
void set_forced_discrete_update_events (std::unique_ptr< EventCollection< DiscreteUpdateEvent< T >>> forced)
 
void set_forced_unrestricted_update_events (std::unique_ptr< EventCollection< UnrestrictedUpdateEvent< T >>> forced)
 
 System (SystemScalarConverter converter)
 Constructs an empty System base class object, possibly supporting scalar-type conversion support (AutoDiff, etc.) using converter. More...
 
const InputPort< T > & DeclareInputPort (PortDataType type, int size, optional< RandomDistribution > random_type=nullopt)
 Adds a port with the specified type and size to the input topology. More...
 
const InputPort< T > & DeclareAbstractInputPort ()
 Adds an abstract-valued port to the input topology. More...
 
virtual T DoCalcPotentialEnergy (const Context< T > &context) const
 Override this method for physical systems to calculate the potential energy currently stored in the configuration provided in the given Context. More...
 
virtual T DoCalcKineticEnergy (const Context< T > &context) const
 Override this method for physical systems to calculate the kinetic energy currently present in the motion provided in the given Context. More...
 
virtual T DoCalcConservativePower (const Context< T > &context) const
 Override this method to return the rate at which mechanical energy is being converted from potential energy to kinetic energy by this system in the given Context. More...
 
virtual T DoCalcNonConservativePower (const Context< T > &context) const
 Override this method to return the rate at which mechanical energy is being generated (positive) or dissipated (negative) other than by conversion between potential and kinetic energy (in the given Context). More...
 
virtual int do_get_num_constraint_equations (const Context< T > &context) const
 Gets the number of constraint equations for this system from the given context. More...
 
virtual Eigen::VectorXd DoEvalConstraintEquations (const Context< T > &context) const
 Evaluates the constraint equations for the system at the generalized coordinates and generalized velocity specified by the context. More...
 
virtual Eigen::VectorXd DoEvalConstraintEquationsDot (const Context< T > &context) const
 Computes the time derivative of each constraint equation, evaluated at the generalized coordinates and generalized velocity specified by the context. More...
 
virtual Eigen::VectorXd DoCalcVelocityChangeFromConstraintImpulses (const Context< T > &context, const Eigen::MatrixXd &J, const Eigen::VectorXd &lambda) const
 Computes the change in velocity from applying the given constraint forces to the system at the given context. More...
 
virtual double DoCalcConstraintErrorNorm (const Context< T > &context, const Eigen::VectorXd &error) const
 Computes the norm of the constraint error. More...
 
Eigen::VectorBlock< VectorX< T > > GetMutableOutputVector (SystemOutput< T > *output, int port_index) const
 Returns a mutable Eigen expression for a vector valued output port with index port_index in this system. More...
 
- Protected Member Functions inherited from SystemBase
 SystemBase ()=default
 (Internal use only) Default constructor. More...
 
void AddInputPort (std::unique_ptr< InputPortBase > port)
 (Internal use only) Adds an already-constructed input port to this System. More...
 
void AddOutputPort (std::unique_ptr< OutputPortBase > port)
 (Internal use only) Adds an already-constructed output port to this System. More...
 
void AddDiscreteStateGroup (DiscreteStateIndex index)
 (Internal use only) Assigns a ticket to a new discrete variable group with the given index. More...
 
void AddAbstractState (AbstractStateIndex index)
 (Internal use only) Assigns a ticket to a new abstract state variable with the given index. More...
 
void AddNumericParameter (NumericParameterIndex index)
 (Internal use only) Assigns a ticket to a new numeric parameter with the given index. More...
 
void AddAbstractParameter (AbstractParameterIndex index)
 (Internal use only) Assigns a ticket to a new abstract parameter with the given index. More...
 
const CacheEntryDeclareCacheEntryWithKnownTicket (DependencyTicket known_ticket, std::string description, CacheEntry::AllocCallback alloc_function, CacheEntry::CalcCallback calc_function, std::set< DependencyTicket > prerequisites_of_calc={all_sources_ticket()})
 (Internal use only) This is for cache entries associated with pre-defined tickets, for example the cache entry for time derivatives. More...
 
const internal::SystemParentServiceInterface * get_parent_service () const
 Returns a pointer to the service interface of the immediately enclosing Diagram if one has been set, otherwise nullptr. More...
 
DependencyTicket assign_next_dependency_ticket ()
 (Internal use only) Assigns the next unused dependency ticket number, unique only within a particular system. More...
 
const AbstractValueEvalAbstractInputImpl (const char *func, const ContextBase &context, InputPortIndex port_index) const
 (Internal use only) Shared code for updating an input port and returning a pointer to its abstract value, or nullptr if the port is not connected. More...
 
void ThrowNegativePortIndex (const char *func, int port_index) const
 Throws std::out_of_range to report a negative port_index that was passed to API method func. More...
 
void ThrowInputPortIndexOutOfRange (const char *func, InputPortIndex port_index) const
 Throws std::out_of_range to report bad input port_index that was passed to API method func. More...
 
void ThrowOutputPortIndexOutOfRange (const char *func, OutputPortIndex port_index) const
 Throws std::out_of_range to report bad output port_index that was passed to API method func. More...
 
void ThrowNotAVectorInputPort (const char *func, InputPortIndex port_index) const
 Throws std::logic_error because someone misused API method func, that is only allowed for declared-vector input ports, on an abstract port whose index is given here. More...
 
void ThrowInputPortHasWrongType (const char *func, InputPortIndex port_index, const std::string &expected_type, const std::string &actual_type) const
 Throws std::logic_error because someone called API method func claiming the input port had some value type that was wrong. More...
 
void ThrowCantEvaluateInputPort (const char *func, InputPortIndex port_index) const
 Throws std::logic_error because someone called API method func, that requires this input port to be evaluatable, but the port was neither fixed nor connected. More...
 
const InputPortBaseGetInputPortBaseOrThrow (const char *func, int port_index) const
 (Internal use only) Returns the InputPortBase at index port_index, throwing std::out_of_range we don't like the port index. More...
 
const OutputPortBaseGetOutputPortBaseOrThrow (const char *func, int port_index) const
 (Internal use only) Returns the OutputPortBase at index port_index, throwing std::out_of_range we don't like the port index. More...
 
void InitializeContextBase (ContextBase *context) const
 This method must be invoked from within derived class DoAllocateContext() implementations right after the concrete Context object has been allocated. More...
 
- Static Protected Member Functions inherited from SystemBase
static void set_parent_service (SystemBase *child, const internal::SystemParentServiceInterface *parent_service)
 (Internal use only) Declares that parent_service is the service interface of the Diagram that owns this subsystem. More...
 

Detailed Description

template<typename T>
class drake::systems::controllers::PidControlledSystem< T >

A system that encapsulates a PidController and a controlled System (a.k.a the "plant").

The passed in plant must meet the following properties:

  • Input port zero must be all of the control inputs (size U). When the plant is a dynamics model, this is typically the generalized effort (e.g., force or torque) command.
  • Output port zero must be of size 2 * Q, where the first Q elements are the position states of the plant, and the second Q elements are the velocity states of the plant. Q >= U.

The resulting PidControlledSystem has two input ports and one output port with the following properties:

  • Input port zero is the feed forward control (size U), which will be added onto the output of the PID controller. The sum is sent to the plant's input.
  • Input port one is the desired controlled states (2 * U) of the plant, where the first half are the controlled positions, and the second half are the controlled velocities.
  • The output port is the current state of the plant (it is the direct pass-through of the plant's output port).

Some of the constructors include a parameter called feedback_selector. It is used to select the controlled states from the plant's state output port. Let S be the gain matrix in parameter feedback_selector. S must have dimensions of (2 * U, 2 * Q). Typically, S contains one 1 in each row, and zeros everywhere else. S does not affect the desired state input. Let 'x' be the full state of the plant (size 2 * Q), and 'x_d' be the desired state (size 2 * U), S is used to compute the state error as x_err = S * x - x_d.

Template Parameters
TThe vector element type, which must be a valid Eigen scalar.

Instantiated templates for the following kinds of T's are provided:

  • double
  • AutoDiffXd

Constructor & Destructor Documentation

PidControlledSystem ( const PidControlledSystem< T > &  )
delete
PidControlledSystem ( std::unique_ptr< System< T >>  plant,
double  Kp,
double  Ki,
double  Kd 
)

plant full state is used for feedback control, and all the dimensions have homogeneous gains specified by Kp, Kd and Ki.

Parameters
[in]plantThe system to be controlled. This must not be nullptr.
[in]Kpthe proportional constant.
[in]Kithe integral constant.
[in]Kdthe derivative constant.
PidControlledSystem ( std::unique_ptr< System< T >>  plant,
const Eigen::VectorXd &  Kp,
const Eigen::VectorXd &  Ki,
const Eigen::VectorXd &  Kd 
)

plant full state is used for feedback control, and the vectorized gains are specified by Kp, Kd and Ki.

Parameters
[in]plantThe system to be controlled. This must not be nullptr.
[in]Kpthe proportional vector constant.
[in]Kithe integral vector constant.
[in]Kdthe derivative vector constant.
PidControlledSystem ( std::unique_ptr< System< T >>  plant,
const MatrixX< double > &  feedback_selector,
double  Kp,
double  Ki,
double  Kd 
)

A constructor where the gains are scalar values and some of the plant's output is part of the feedback signal as specified by feedback_selector.

Parameters
[in]plantThe system to be controlled. This must not be nullptr.
[in]feedback_selectorThe matrix that selects which part of the plant's full state is fed back to the PID controller. For semantic details of this parameter, see this class's description.
[in]Kpthe proportional constant.
[in]Kithe integral constant.
[in]Kdthe derivative constant.

Here is the call graph for this function:

PidControlledSystem ( std::unique_ptr< System< T >>  plant,
const MatrixX< double > &  feedback_selector,
const Eigen::VectorXd &  Kp,
const Eigen::VectorXd &  Ki,
const Eigen::VectorXd &  Kd 
)

A constructor where the gains are vector values and some of the plant's output is part of the feedback signal as specified by feedback_selector.

Parameters
[in]plantThe system to be controlled. This must not be nullptr.
[in]feedback_selectorThe matrix that selects which part of the plant's full state is fed back to the PID controller. For semantic details of this parameter, see this class's description.
[in]Kpthe proportional vector constant.
[in]Kithe integral vector constant.
[in]Kdthe derivative vector constant.

Here is the call graph for this function:

~PidControlledSystem ( )
override

Member Function Documentation

PidControlledSystem< T >::ConnectResult ConnectController ( const InputPort< T > &  plant_input,
const OutputPort< T > &  plant_output,
const MatrixX< double > &  feedback_selector,
const Eigen::VectorXd &  Kp,
const Eigen::VectorXd &  Ki,
const Eigen::VectorXd &  Kd,
DiagramBuilder< T > *  builder 
)
static

Creates a PidController and uses builder to connect plant_input and plant_output from an existing plant.

The controlled states are selected by feedback_selector.

Here is the call graph for this function:

Here is the caller graph for this function:

PidControlledSystem< T >::ConnectResult ConnectController ( const InputPort< T > &  plant_input,
const OutputPort< T > &  plant_output,
const Eigen::VectorXd &  Kp,
const Eigen::VectorXd &  Ki,
const Eigen::VectorXd &  Kd,
DiagramBuilder< T > *  builder 
)
static

Creates a PidController and uses builder to connect plant_input and plant_output from an existing plant.

The plant's full state is used for feedback.

Here is the call graph for this function:

PidControlledSystem< T >::ConnectResult ConnectControllerWithInputSaturation ( const InputPort< T > &  plant_input,
const OutputPort< T > &  plant_output,
const MatrixX< double > &  feedback_selector,
const Eigen::VectorXd &  Kp,
const Eigen::VectorXd &  Ki,
const Eigen::VectorXd &  Kd,
const VectorX< T > &  min_plant_input,
const VectorX< T > &  max_plant_input,
DiagramBuilder< T > *  builder 
)
static

Creates a PidController with input saturation and uses builder to connect plant_input and plant_output from an existing plant.

The controlled states are selected by feedback_selector. The output of the PidController is clipped to be within the specified bounds. Note that using input limits along with integral gain constant may cause the integrator to windup.

Here is the call graph for this function:

Here is the caller graph for this function:

PidControlledSystem< T >::ConnectResult ConnectControllerWithInputSaturation ( const InputPort< T > &  plant_input,
const OutputPort< T > &  plant_output,
const Eigen::VectorXd &  Kp,
const Eigen::VectorXd &  Ki,
const Eigen::VectorXd &  Kd,
const VectorX< T > &  min_plant_input,
const VectorX< T > &  max_plant_input,
DiagramBuilder< T > *  builder 
)
static

Creates a PidController with input saturation and uses builder to connect plant_input and plant_output from an existing plant.

The plant's full state is used for feedback. The output of the PidController is clipped to be within the specified bounds. Note that using input limits along with integral gain constant may cause the integrator to windup.

Here is the call graph for this function:

const InputPort<T>& get_control_input_port ( ) const
inline
Returns
the input port for the feed forward control input.

Here is the call graph for this function:

const InputPort<T>& get_state_input_port ( ) const
inline
Returns
the input port for the desired position/velocity state.

Here is the call graph for this function:

const OutputPort<T>& get_state_output_port ( ) const
inline

Here is the call graph for this function:

PidControlledSystem& operator= ( PidControlledSystem< T > &&  )
delete
PidControlledSystem& operator= ( const PidControlledSystem< T > &  )
delete
System<T>* plant ( )
inline

Here is the caller graph for this function:


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