A SystemConstraint is a generic base-class for constraints on Systems.
A SystemConstraint is a means to inform our algorithms about the implemented system behavior – declaring the constraint does not cause the system behavior to change. It is meant to improve analysis by telling our algorithms that "all valid solutions of this dynamical system will satisfy the following (in)equalities". Examples could include conserved quantities or joint limits on a mechanism.
This class is intentionally similar to, but (so far) independent from solvers::Constraint. This is primarily because there is no notion of decision variables in the system classes (yet); rather each individual algorithm (e.g. trajectory optimization, or system identification) constructs decision variables for the particular mathematical program that is being formulated, and must bind the system constraint to those variables (e.g. by populating the Context with the decision variables and calling Calc).
We can convert a SystemConstraint to a solvers::Constraint by using SystemConstraintWrapper or SystemConstraintAdapter.
T | The scalar type, which must be one of the default scalars. |
#include <drake/systems/framework/system_constraint.h>
Public Member Functions | |
SystemConstraint (const System< T > *system, std::string description) | |
(Advanced) Constructs a default (zero-sized) SystemConstraint. More... | |
SystemConstraint (const System< T > *system, ContextConstraintCalc< T > calc_function, SystemConstraintBounds bounds, std::string description) | |
(Advanced) Constructs a SystemConstraint. More... | |
SystemConstraint (const System< T > *system, SystemConstraintCalc< T > calc_function, SystemConstraintBounds bounds, std::string description) | |
(Advanced) Constructs a SystemConstraint. More... | |
void | Calc (const Context< T > &context, VectorX< T > *value) const |
Evaluates the function pointer passed in through the constructor, writing the output to value . More... | |
boolean< T > | CheckSatisfied (const Context< T > &context, double tol) const |
Evaluates the function pointer, and check if all of the outputs are within the desired bounds. More... | |
const System< T > & | get_system () const |
Returns a reference to the System that owns this constraint. More... | |
const SystemConstraintBounds & | bounds () const |
int | size () const |
SystemConstraintType | type () const |
bool | is_equality_constraint () const |
const Eigen::VectorXd & | lower_bound () const |
const Eigen::VectorXd & | upper_bound () const |
const std::string & | description () const |
Does not allow copy, move, or assignment | |
SystemConstraint (const SystemConstraint &)=delete | |
SystemConstraint & | operator= (const SystemConstraint &)=delete |
SystemConstraint (SystemConstraint &&)=delete | |
SystemConstraint & | operator= (SystemConstraint &&)=delete |
System compatibility | |
See System Compatibility. | |
const std::optional< internal::SystemId > & | get_system_id () const |
(Internal use only) Gets the id of the subsystem associated with this object, if one has been set. More... | |
void | set_system_id (internal::SystemId id) |
(Internal use only) Records the id of the subsystem associated with this object. More... | |
|
delete |
|
delete |
SystemConstraint | ( | const System< T > * | system, |
std::string | description | ||
) |
(Advanced) Constructs a default (zero-sized) SystemConstraint.
Most users should call a LeafSystem method like DeclareEqualityConstraint to create (and add) constraints, not call this constructor directly.
description | a human-readable description useful for debugging. |
SystemConstraint | ( | const System< T > * | system, |
ContextConstraintCalc< T > | calc_function, | ||
SystemConstraintBounds | bounds, | ||
std::string | description | ||
) |
(Advanced) Constructs a SystemConstraint.
Depending on the bounds
it could be an equality constraint f(x) = 0, or an inequality constraint lower_bound <= f(x) <= upper_bound.
Most users should call a LeafSystem method like DeclareEqualityConstraint to create (and add) constraints, not call this constructor directly.
description | a human-readable description useful for debugging. |
SystemConstraint | ( | const System< T > * | system, |
SystemConstraintCalc< T > | calc_function, | ||
SystemConstraintBounds | bounds, | ||
std::string | description | ||
) |
(Advanced) Constructs a SystemConstraint.
Depending on the bounds
it could be an equality constraint f(x) = 0, or an inequality constraint lower_bound <= f(x) <= upper_bound.
Most users should call a LeafSystem method like DeclareEqualityConstraint to create (and add) constraints, not call this constructor directly.
description | a human-readable description useful for debugging. |
const SystemConstraintBounds& bounds | ( | ) | const |
Evaluates the function pointer passed in through the constructor, writing the output to value
.
value
will be (non-conservatively) resized to match the constraint function output.
Evaluates the function pointer, and check if all of the outputs are within the desired bounds.
const std::string& description | ( | ) | const |
const System<T>& get_system | ( | ) | const |
Returns a reference to the System that owns this constraint.
Note that for a constraint on a diagram this will be the diagram itself, never a leaf system whose constraint was re-expressed.
const std::optional<internal::SystemId>& get_system_id | ( | ) | const |
(Internal use only) Gets the id of the subsystem associated with this object, if one has been set.
bool is_equality_constraint | ( | ) | const |
const Eigen::VectorXd& lower_bound | ( | ) | const |
|
delete |
|
delete |
void set_system_id | ( | internal::SystemId | id | ) |
(Internal use only) Records the id of the subsystem associated with this object.
int size | ( | ) | const |
SystemConstraintType type | ( | ) | const |
const Eigen::VectorXd& upper_bound | ( | ) | const |