A system that represents the complete manipulation station, including exactly one robotic arm (a Kuka IIWA LWR), one gripper (a Schunk WSG 50), and anything a user might want to load into the model.
SetupDefaultStation() provides the setup that is used in the MIT Intelligent Robot Manipulation class, which includes the supporting structure for IIWA and several RGBD cameras. Alternative Setup___() methods are provided, as well.
| ManipulationStation |
|
Each pixel in the output image from depth_image
is a 16bit unsigned short in millimeters.
Note that outputs in orange are available in the simulation, but not on the real robot. The distinction between q_measured and v_estimated is because the Kuka FRI reports positions directly, but we have estimated v in our code that wraps the FRI.
Consider the robot dynamics M(q)vdot + C(q,v)v = τ_g(q) + τ_commanded + τ_joint_friction + τ_external, where q == position, v == velocity, and τ == torque.
This model of the IIWA internal controller in the FRI software's JointImpedanceControlMode
is:
τ_commanded = Mₑ(qₑ)vdot_desired + Cₑ(qₑ, vₑ)vₑ - τₑ_g(q) - τₑ_joint_friction + τ_feedforward vdot_desired = PID(q_commanded, qₑ, v_commanded, vₑ)
where Mₑ, Cₑ, τₑ_g, and τₑ_friction terms are now (Kuka's) estimates of the true model, qₑ and vₑ are measured/estimation, and v_commanded must be obtained from an online (causal) derivative of q_commanded. The result is
M(q)vdot ≈ Mₑ(q)vdot_desired + τ_feedforward + τ_external,
where the "approximately equal" comes from the differences due to the estimated model/state.
The model implemented in this System assumes that M, C, and τ_friction terms are perfect (except that they contain only a lumped mass approximation of the gripper), and that the measured signals are noise/bias free (e.g. q_measured = q, v_estimated = v, τ_measured = τ_commanded). What remains for τ_external is the generalized forces due to contact (note that they could also include the missing contributions from the gripper fingers, which the controller assumes are welded).
To add objects into the environment for the robot to manipulate, use, e.g.:
Note that you must call Finalize() before you can use this class as a System.
T | The scalar type, which must be double . |
#include <drake/examples/manipulation_station/manipulation_station.h>
Public Member Functions | |
ManipulationStation (double time_step=0.002) | |
Construct the EMPTY station model. More... | |
void | SetupClutterClearingStation (const std::optional< const math::RigidTransformd > &X_WCameraBody={}, IiwaCollisionModel collision_model=IiwaCollisionModel::kNoCollision, SchunkCollisionModel schunk_model=SchunkCollisionModel::kBox) |
Adds a default iiwa, wsg, two bins, and a camera, then calls RegisterIiwaControllerModel() and RegisterWsgControllerModel() with the appropriate arguments. More... | |
void | SetupManipulationClassStation (IiwaCollisionModel collision_model=IiwaCollisionModel::kNoCollision, SchunkCollisionModel schunk_model=SchunkCollisionModel::kBox) |
Adds a default iiwa, wsg, cupboard, and 80/20 frame for the MIT Intelligent Robot Manipulation class, then calls RegisterIiwaControllerModel() and RegisterWsgControllerModel() with the appropriate arguments. More... | |
void | SetupPlanarIiwaStation (SchunkCollisionModel schunk_model=SchunkCollisionModel::kBox) |
Adds a version of the iiwa with joints that would result in out-of-plane rotations welded in a fixed orientation, reducing the total degrees of freedom of the arm to 3. More... | |
void | SetDefaultState (const systems::Context< T > &station_context, systems::State< T > *state) const override |
Sets the default State for the chosen setup. More... | |
void | SetRandomState (const systems::Context< T > &station_context, systems::State< T > *state, RandomGenerator *generator) const override |
Sets a random State for the chosen setup. More... | |
void | RegisterIiwaControllerModel (const std::string &model_path, const multibody::ModelInstanceIndex iiwa_instance, const multibody::Frame< T > &parent_frame, const multibody::Frame< T > &child_frame, const math::RigidTransform< double > &X_PC) |
Notifies the ManipulationStation that the IIWA robot model instance can be identified by iiwa_instance as well as necessary information to reload model for the internal controller's use. More... | |
void | RegisterWsgControllerModel (const std::string &model_path, const multibody::ModelInstanceIndex wsg_instance, const multibody::Frame< T > &parent_frame, const multibody::Frame< T > &child_frame, const math::RigidTransform< double > &X_PC) |
Notifies the ManipulationStation that the WSG gripper model instance can be identified by wsg_instance , as well as necessary information to reload model for the internal controller's use. More... | |
void | RegisterRgbdSensor (const std::string &name, const multibody::Frame< T > &parent_frame, const math::RigidTransform< double > &X_PCameraBody, const geometry::render::DepthRenderCamera &depth_camera) |
Registers an RGBD sensor. More... | |
void | RegisterRgbdSensor (const std::string &name, const multibody::Frame< T > &parent_frame, const math::RigidTransform< double > &X_PCameraBody, const geometry::render::ColorRenderCamera &color_camera, const geometry::render::DepthRenderCamera &depth_camera) |
Registers an RGBD sensor with uniquely characterized color/label and depth cameras. More... | |
void | AddManipulandFromFile (const std::string &model_file, const math::RigidTransform< double > &X_WObject) |
Adds a single object for the robot to manipulate. More... | |
void | Finalize () |
Users must call Finalize() after making any additions to the multibody plant and before using this class in the Systems framework. More... | |
void | Finalize (std::map< std::string, std::unique_ptr< geometry::render::RenderEngine >> render_engines) |
Finalizes the station with the option of specifying the renderers the manipulation station uses. More... | |
const multibody::MultibodyPlant< T > & | get_multibody_plant () const |
Returns a reference to the main plant responsible for the dynamics of the robot and the environment. More... | |
multibody::MultibodyPlant< T > & | get_mutable_multibody_plant () |
Returns a mutable reference to the main plant responsible for the dynamics of the robot and the environment. More... | |
const geometry::SceneGraph< T > & | get_scene_graph () const |
Returns a reference to the SceneGraph responsible for all of the geometry for the robot and the environment. More... | |
geometry::SceneGraph< T > & | get_mutable_scene_graph () |
Returns a mutable reference to the SceneGraph responsible for all of the geometry for the robot and the environment. More... | |
const multibody::MultibodyPlant< T > & | get_controller_plant () const |
Return a reference to the plant used by the inverse dynamics controller (which contains only a model of the iiwa + equivalent mass of the gripper). More... | |
int | num_iiwa_joints () const |
Gets the number of joints in the IIWA (only – does not include the gripper). More... | |
VectorX< T > | GetIiwaPosition (const systems::Context< T > &station_context) const |
Convenience method for getting all of the joint angles of the Kuka IIWA. More... | |
void | SetIiwaPosition (const systems::Context< T > &station_context, systems::State< T > *state, const Eigen::Ref< const VectorX< T >> &q) const |
Convenience method for setting all of the joint angles of the Kuka IIWA. More... | |
void | SetIiwaPosition (systems::Context< T > *station_context, const Eigen::Ref< const VectorX< T >> &q) const |
Convenience method for setting all of the joint angles of the Kuka IIWA. More... | |
VectorX< T > | GetIiwaVelocity (const systems::Context< T > &station_context) const |
Convenience method for getting all of the joint velocities of the Kuka. More... | |
void | SetIiwaVelocity (const systems::Context< T > &station_context, systems::State< T > *state, const Eigen::Ref< const VectorX< T >> &v) const |
Convenience method for setting all of the joint velocities of the Kuka IIWA. More... | |
void | SetIiwaVelocity (systems::Context< T > *station_context, const Eigen::Ref< const VectorX< T >> &v) const |
Convenience method for setting all of the joint velocities of the Kuka IIWA. More... | |
T | GetWsgPosition (const systems::Context< T > &station_context) const |
Convenience method for getting the position of the Schunk WSG. More... | |
T | GetWsgVelocity (const systems::Context< T > &station_context) const |
Convenience method for getting the velocity of the Schunk WSG. More... | |
void | SetWsgPosition (const systems::Context< T > &station_context, systems::State< T > *state, const T &q) const |
Convenience method for setting the position of the Schunk WSG. More... | |
void | SetWsgPosition (systems::Context< T > *station_context, const T &q) const |
Convenience method for setting the position of the Schunk WSG. More... | |
void | SetWsgVelocity (const systems::Context< T > &station_context, systems::State< T > *state, const T &v) const |
Convenience method for setting the velocity of the Schunk WSG. More... | |
void | SetWsgVelocity (systems::Context< T > *station_context, const T &v) const |
Convenience method for setting the velocity of the Schunk WSG. More... | |
std::map< std::string, math::RigidTransform< double > > | GetStaticCameraPosesInWorld () const |
Returns a map from camera name to X_WCameraBody for all the static (rigidly attached to the world body) cameras that have been registered. More... | |
std::vector< std::string > | get_camera_names () const |
Get the camera names / unique ids. More... | |
void | SetWsgGains (double kp, double kd) |
Set the gains for the WSG controller. More... | |
void | SetIiwaPositionGains (const VectorX< double > &kp) |
Set the position gains for the IIWA controller. More... | |
void | SetIiwaVelocityGains (const VectorX< double > &kd) |
Set the velocity gains for the IIWA controller. More... | |
void | SetIiwaIntegralGains (const VectorX< double > &ki) |
Set the integral gains for the IIWA controller. More... | |
Does not allow copy, move, or assignment | |
ManipulationStation (const ManipulationStation &)=delete | |
ManipulationStation & | operator= (const ManipulationStation &)=delete |
ManipulationStation (ManipulationStation &&)=delete | |
ManipulationStation & | operator= (ManipulationStation &&)=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... | |
void | Accept (SystemVisitor< T > *v) const final |
Implements a visitor pattern. More... | |
const std::map< InputPortLocator, OutputPortLocator > & | connection_map () const |
Returns a reference to the map of connections between Systems. More... | |
std::vector< InputPortLocator > | GetInputPortLocators (InputPortIndex port_index) const |
Returns the collection of "locators" for the subsystem input ports that were exported or connected to the port_index input port for the Diagram. More... | |
const OutputPortLocator & | get_output_port_locator (OutputPortIndex port_index) const |
Returns the "locator" for the subsystem output port that was exported as the port_index output port for the Diagram. More... | |
std::multimap< int, int > | GetDirectFeedthroughs () const final |
Reports all direct feedthroughs from input ports to output ports. More... | |
void | SetDefaultParameters (const Context< T > &context, Parameters< T > *params) const override |
Assigns default values to all parameters. More... | |
void | SetDefaultState (const Context< T > &context, State< T > *state) const override |
Assigns default values to all elements of the state. 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 final |
Returns a ContinuousState of the same size as the continuous_state allocated in CreateDefaultContext. More... | |
std::unique_ptr< DiscreteValues< T > > | AllocateDiscreteVariables () const final |
Returns a DiscreteValues of the same dimensions as the discrete_state allocated in CreateDefaultContext. More... | |
bool | HasSubsystemNamed (std::string_view name) const |
Returns true iff this contains a subsystem with the given name. More... | |
const System< T > & | GetSubsystemByName (std::string_view name) const |
Retrieves a const reference to the subsystem with name name returned by get_name(). More... | |
template<template< typename > class MySystem> | |
const MySystem< T > & | GetDowncastSubsystemByName (std::string_view name) const |
Retrieves a const reference to the subsystem with name name returned by get_name(), downcast to the type provided as a template argument. More... | |
template<class MyUntemplatizedSystem > | |
const MyUntemplatizedSystem & | GetDowncastSubsystemByName (std::string_view name) const |
Alternate signature for a subsystem that has the Diagram's scalar type T but is not explicitly templatized on T. More... | |
const ContinuousState< T > & | GetSubsystemDerivatives (const System< T > &subsystem, const ContinuousState< T > &derivatives) const |
Retrieves the state derivatives for a particular subsystem from the derivatives for the entire diagram. More... | |
const DiscreteValues< T > & | GetSubsystemDiscreteValues (const System< T > &subsystem, const DiscreteValues< T > &discrete_values) const |
Retrieves the discrete state values for a particular subsystem from the discrete values for the entire diagram. 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... | |
bool | AreConnected (const OutputPort< T > &output, const InputPort< T > &input) const |
Reports if the indicated output is connected to the input port. More... | |
Diagram (const Diagram &)=delete | |
Diagram & | operator= (const Diagram &)=delete |
Diagram (Diagram &&)=delete | |
Diagram & | operator= (Diagram &&)=delete |
Public Member Functions inherited from System< T > | |
~System () override | |
void | GetWitnessFunctions (const Context< T > &context, std::vector< const WitnessFunction< T > * > *w) const |
Gets the witness functions active for the given state. More... | |
T | CalcWitnessValue (const Context< T > &context, const WitnessFunction< T > &witness_func) const |
Evaluates a witness function at the given context. More... | |
DependencyTicket | discrete_state_ticket (DiscreteStateIndex index) const |
Returns a ticket indicating dependence on a particular discrete state variable xdᵢ (may be a vector). More... | |
DependencyTicket | abstract_state_ticket (AbstractStateIndex index) const |
Returns a ticket indicating dependence on a particular abstract state variable xaᵢ. More... | |
DependencyTicket | numeric_parameter_ticket (NumericParameterIndex index) const |
Returns a ticket indicating dependence on a particular numeric parameter pnᵢ (may be a vector). More... | |
DependencyTicket | abstract_parameter_ticket (AbstractParameterIndex index) const |
Returns a ticket indicating dependence on a particular abstract parameter paᵢ. More... | |
DependencyTicket | input_port_ticket (InputPortIndex index) const |
Returns a ticket indicating dependence on input port uᵢ indicated by index . More... | |
DependencyTicket | cache_entry_ticket (CacheIndex index) const |
Returns a ticket indicating dependence on the cache entry indicated by index . More... | |
System (const System &)=delete | |
System & | operator= (const System &)=delete |
System (System &&)=delete | |
System & | operator= (System &&)=delete |
std::unique_ptr< Context< T > > | AllocateContext () const |
Returns a Context<T> suitable for use with this System<T>. More... | |
std::unique_ptr< CompositeEventCollection< T > > | AllocateCompositeEventCollection () const |
Allocates a CompositeEventCollection for this system. 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< AbstractValue > | AllocateInputAbstract (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... | |
VectorX< T > | AllocateImplicitTimeDerivativesResidual () const |
Returns an Eigen VectorX suitable for use as the output argument to the CalcImplicitTimeDerivativesResidual() method. 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 |
Sets Context fields to their default values. More... | |
void | SetRandomContext (Context< T > *context, RandomGenerator *generator) const |
Sets Context fields to random values. More... | |
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... | |
virtual std::multimap< int, int > | GetDirectFeedthroughs () const=0 |
Reports all direct feedthroughs from input ports to output ports. More... | |
EventStatus | 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 | ForcedPublish (const Context< T > &context) const |
(Advanced) Manually triggers any PublishEvent that has trigger type kForced. More... | |
const ContinuousState< T > & | EvalTimeDerivatives (const Context< T > &context) const |
Returns a reference to the cached value of the continuous state variable time derivatives, evaluating first if necessary using CalcTimeDerivatives(). More... | |
const CacheEntry & | get_time_derivatives_cache_entry () const |
(Advanced) Returns the CacheEntry used to cache time derivatives for EvalTimeDerivatives(). More... | |
const T & | EvalPotentialEnergy (const Context< T > &context) const |
Returns a reference to the cached value of the potential energy (PE), evaluating first if necessary using CalcPotentialEnergy(). More... | |
const T & | EvalKineticEnergy (const Context< T > &context) const |
Returns a reference to the cached value of the kinetic energy (KE), evaluating first if necessary using CalcKineticEnergy(). More... | |
const T & | EvalConservativePower (const Context< T > &context) const |
Returns a reference to the cached value of the conservative power (Pc), evaluating first if necessary using CalcConservativePower(). More... | |
const T & | EvalNonConservativePower (const Context< T > &context) const |
Returns a reference to the cached value of the non-conservative power (Pnc), evaluating first if necessary using CalcNonConservativePower(). 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... | |
SystemConstraintIndex | AddExternalConstraint (ExternalSystemConstraint constraint) |
Adds an "external" constraint to this System. More... | |
void | CalcTimeDerivatives (const Context< T > &context, ContinuousState< T > *derivatives) const |
Calculates the time derivatives ẋ꜀ of the continuous state x꜀ into a given output argument. More... | |
void | CalcImplicitTimeDerivativesResidual (const Context< T > &context, const ContinuousState< T > &proposed_derivatives, EigenPtr< VectorX< T >> residual) const |
Evaluates the implicit form of the System equations and returns the residual. More... | |
EventStatus | CalcDiscreteVariableUpdate (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 | ApplyDiscreteVariableUpdate (const EventCollection< DiscreteUpdateEvent< T >> &events, DiscreteValues< T > *discrete_state, Context< T > *context) const |
Given the discrete_state results of a previous call to CalcDiscreteVariableUpdate() that dispatched the given collection of events, modifies the context to reflect the updated discrete_state . More... | |
void | CalcForcedDiscreteVariableUpdate (const Context< T > &context, DiscreteValues< T > *discrete_state) const |
(Advanced) Manually triggers any DiscreteUpdateEvent that has trigger type kForced. More... | |
EventStatus | 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 | ApplyUnrestrictedUpdate (const EventCollection< UnrestrictedUpdateEvent< T >> &events, State< T > *state, Context< T > *context) const |
Given the state results of a previous call to CalcUnrestrictedUpdate() that dispatched the given collection of events, modifies the context to reflect the updated state . More... | |
void | CalcForcedUnrestrictedUpdate (const Context< T > &context, State< T > *state) const |
(Advanced) Manually triggers any UnrestrictedUpdateEvent that has trigger type kForced. More... | |
T | 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 | GetPeriodicEvents (const Context< T > &context, CompositeEventCollection< T > *events) const |
Returns all periodic events in this System. 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 AdvanceTo() 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... | |
void | ExecuteInitializationEvents (Context< T > *context) const |
This method triggers all of the initialization events returned by GetInitializationEvents(). More... | |
void | ExecuteForcedEvents (Context< T > *context, bool publish=true) const |
This method triggers all of the forced events registered with this System (which might be a Diagram). More... | |
std::optional< PeriodicEventData > | GetUniquePeriodicDiscreteUpdateAttribute () const |
Determines whether there exists a unique periodic timing (offset and period) that triggers one or more discrete update events (and, if so, returns that unique periodic timing). More... | |
const DiscreteValues< T > & | EvalUniquePeriodicDiscreteUpdate (const Context< T > &context) const |
If this System contains a unique periodic timing for discrete update events, this function executes the handlers for those periodic events to determine what their effect would be. More... | |
bool | IsDifferenceEquationSystem (double *time_period=nullptr) const |
Returns true iff the state dynamics of this system are governed exclusively by a difference equation on a single discrete state group and with a unique periodic update (having zero offset). More... | |
bool | IsDifferentialEquationSystem () const |
Returns true iff the state dynamics of this system are governed exclusively by a differential equation. More... | |
std::map< PeriodicEventData, std::vector< const Event< T > * >, PeriodicEventDataComparator > | MapPeriodicEventsByTiming (const Context< T > *context=nullptr) const |
Maps all periodic triggered events for a System, organized by timing. 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... | |
T | CalcPotentialEnergy (const Context< T > &context) const |
Calculates and returns the potential energy represented by the current configuration provided in context . More... | |
T | CalcKineticEnergy (const Context< T > &context) const |
Calculates and returns the kinetic energy represented by the current configuration and velocity provided in context . More... | |
T | CalcConservativePower (const Context< T > &context) const |
Calculates and returns the conservative power represented by the current contents of the given context . More... | |
T | CalcNonConservativePower (const Context< T > &context) const |
Calculates and returns the non-conservative power represented by the current contents of 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... | |
const Context< T > & | GetSubsystemContext (const System< T > &subsystem, const Context< T > &context) const |
Returns a const reference to the subcontext that corresponds to the contained System subsystem . More... | |
Context< T > & | GetMutableSubsystemContext (const System< T > &subsystem, Context< T > *context) const |
Returns a mutable reference to the subcontext that corresponds to the contained System subsystem . More... | |
const Context< T > & | GetMyContextFromRoot (const Context< T > &root_context) const |
Returns the const Context for this subsystem, given a root context. More... | |
Context< T > & | GetMyMutableContextFromRoot (Context< T > *root_context) const |
Returns the mutable subsystem context for this system, given a root context. More... | |
const InputPort< T > & | get_input_port (int port_index, bool warn_deprecated=true) const |
Returns the typed input port at index port_index . More... | |
const InputPort< T > & | get_input_port () const |
Convenience method for the case of exactly one input port. More... | |
const InputPort< T > * | get_input_port_selection (std::variant< InputPortSelection, InputPortIndex > port_index) const |
Returns the typed input port specified by the InputPortSelection or by the InputPortIndex. More... | |
const InputPort< T > & | GetInputPort (const std::string &port_name) const |
Returns the typed input port with the unique name port_name . More... | |
bool | HasInputPort (const std::string &port_name) const |
Returns true iff the system has an InputPort of the given port_name . More... | |
const OutputPort< T > & | get_output_port (int port_index, bool warn_deprecated=true) const |
Returns the typed output port at index port_index . More... | |
const OutputPort< T > & | get_output_port () const |
Convenience method for the case of exactly one output port. More... | |
const OutputPort< T > * | get_output_port_selection (std::variant< OutputPortSelection, OutputPortIndex > port_index) const |
Returns the typed output port specified by the OutputPortSelection or by the OutputPortIndex. More... | |
const OutputPort< T > & | GetOutputPort (const std::string &port_name) const |
Returns the typed output port with the unique name port_name . More... | |
bool | HasOutputPort (const std::string &port_name) const |
Returns true iff the system has an OutputPort of the given port_name . More... | |
int | 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... | |
boolean< T > | CheckSystemConstraintsSatisfied (const Context< T > &context, double tol) const |
Returns true if context satisfies all of the registered SystemConstraints with tolerance tol . More... | |
VectorX< T > | CopyContinuousStateVector (const Context< T > &context) const |
Returns a copy of the continuous state vector x꜀ into an Eigen vector. More... | |
std::string | GetMemoryObjectName () const |
Returns a name for this System based on a stringification of its type name and memory address. More... | |
int | num_input_ports () const |
Returns the number of input ports currently allocated in this System. More... | |
int | num_output_ports () const |
Returns the number of output ports currently allocated in this System. 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 SystemScalarConverter & | get_system_scalar_converter () const |
(Advanced) Returns the SystemScalarConverter for this object. More... | |
std::string | GetGraphvizString (std::optional< int > max_depth={}, const std::map< std::string, std::string > &options={}) const |
Returns a Graphviz string describing this System. More... | |
std::unique_ptr< System< T > > | Clone () const |
Creates a deep copy of this system. 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... | |
template<typename U > | |
std::unique_ptr< System< U > > | ToScalarType () const |
Creates a deep copy of this System, transmogrified to use the scalar type selected by a template parameter. More... | |
template<typename U > | |
std::unique_ptr< System< U > > | ToScalarTypeMaybe () const |
Creates a deep copy of this system exactly like ToScalarType(), but returns nullptr if this System does not support the destination type, 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... | |
std::string | GetMemoryObjectName () const |
Returns a name for this System based on a stringification of its type name and memory address. 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... | |
std::unique_ptr< ContextBase > | AllocateContext () const |
Returns a Context suitable for use with this System. More... | |
int | num_input_ports () const |
Returns the number of input ports currently allocated in this System. More... | |
int | num_output_ports () const |
Returns the number of output ports currently allocated in this System. More... | |
const InputPortBase & | get_input_port_base (InputPortIndex port_index) const |
Returns a reference to an InputPort given its port_index . More... | |
const OutputPortBase & | get_output_port_base (OutputPortIndex port_index) const |
Returns a reference to an OutputPort given its port_index . More... | |
int | num_total_inputs () const |
Returns the total dimension of all of the vector-valued input ports (as if they were muxed). More... | |
int | 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 CacheEntry & | get_cache_entry (CacheIndex index) const |
Returns a reference to a CacheEntry given its index . More... | |
CacheEntry & | get_mutable_cache_entry (CacheIndex index) |
(Advanced) Returns a mutable reference to a CacheEntry given its index . More... | |
int | num_continuous_states () const |
Returns the number of declared continuous state variables. 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_parameter_groups () 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... | |
int | implicit_time_derivatives_residual_size () const |
Returns the size of the implicit time derivatives residual vector. More... | |
void | ValidateContext (const ContextBase &context) const final |
Checks whether the given context was created for this system. More... | |
void | ValidateContext (const ContextBase *context) const |
Checks whether the given context was created for this system. More... | |
template<class Clazz > | |
void | ValidateCreatedForThisSystem (const Clazz &object) const |
Checks whether the given object was created for this system. More... | |
SystemBase (const SystemBase &)=delete | |
SystemBase & | operator= (const SystemBase &)=delete |
SystemBase (SystemBase &&)=delete | |
SystemBase & | operator= (SystemBase &&)=delete |
std::string | GetGraphvizString (std::optional< int > max_depth={}, const std::map< std::string, std::string > &options={}) const |
Returns a Graphviz string describing this System. More... | |
GraphvizFragment | GetGraphvizFragment (std::optional< int > max_depth={}, const std::map< std::string, std::string > &options={}) const |
(Advanced) Like GetGraphvizString() but does not wrap the string in a digraph { … } . More... | |
const AbstractValue * | EvalAbstractInput (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... | |
DependencyTicket | discrete_state_ticket (DiscreteStateIndex index) const |
Returns a ticket indicating dependence on a particular discrete state variable xdᵢ (may be a vector). More... | |
DependencyTicket | abstract_state_ticket (AbstractStateIndex index) const |
Returns a ticket indicating dependence on a particular abstract state variable xaᵢ. More... | |
DependencyTicket | numeric_parameter_ticket (NumericParameterIndex index) const |
Returns a ticket indicating dependence on a particular numeric parameter pnᵢ (may be a vector). More... | |
DependencyTicket | abstract_parameter_ticket (AbstractParameterIndex index) const |
Returns a ticket indicating dependence on a particular abstract parameter paᵢ. More... | |
DependencyTicket | input_port_ticket (InputPortIndex index) const |
Returns a ticket indicating dependence on input port uᵢ indicated by index . More... | |
DependencyTicket | cache_entry_ticket (CacheIndex index) const |
Returns a ticket indicating dependence on the cache entry indicated by index . More... | |
DependencyTicket | output_port_ticket (OutputPortIndex index) const |
(Internal use only) Returns a ticket indicating dependence on the output port indicated by index . More... | |
Static Public Member Functions | |
static std::string | default_renderer_name () |
Returns the name of the station's default renderer. More... | |
Static Public Member Functions inherited from System< T > | |
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 any or 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 | pn_ticket () |
Returns a ticket indicating dependence on all of the numerical parameters in the current Context. More... | |
static DependencyTicket | pa_ticket () |
Returns a ticket indicating dependence on all of the abstract parameters pa in the current Context. 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... | |
static DependencyTicket | all_sources_ticket () |
Returns a ticket indicating dependence on every possible independent source value, including time, accuracy, state, input ports, and parameters (but not cache entries). More... | |
static DependencyTicket | configuration_ticket () |
Returns a ticket indicating dependence on all source values that may affect configuration-dependent computations. More... | |
static DependencyTicket | kinematics_ticket () |
Returns a ticket indicating dependence on all source values that may affect configuration- or velocity-dependent computations. More... | |
static DependencyTicket | xcdot_ticket () |
Returns a ticket for the cache entry that holds time derivatives of the continuous variables. More... | |
static DependencyTicket | pe_ticket () |
Returns a ticket for the cache entry that holds the potential energy calculation. More... | |
static DependencyTicket | ke_ticket () |
Returns a ticket for the cache entry that holds the kinetic energy calculation. More... | |
static DependencyTicket | pc_ticket () |
Returns a ticket for the cache entry that holds the conservative power calculation. More... | |
static DependencyTicket | pnc_ticket () |
Returns a ticket for the cache entry that holds the non-conservative power calculation. More... | |
template<template< typename > class S = ::drake::systems::System> | |
static std::unique_ptr< S< T > > | Clone (const S< T > &from) |
Creates a deep copy of this system. More... | |
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... | |
template<typename U , template< typename > class S = ::drake::systems::System> | |
static std::unique_ptr< S< U > > | ToScalarType (const S< T > &from) |
Creates a deep copy of from , transmogrified to use the scalar type selected by a template parameter. More... | |
Static Public Member Functions inherited from SystemBase | |
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 any or 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 | pn_ticket () |
Returns a ticket indicating dependence on all of the numerical parameters in the current Context. More... | |
static DependencyTicket | pa_ticket () |
Returns a ticket indicating dependence on all of the abstract parameters pa in the current Context. 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... | |
static DependencyTicket | all_sources_except_input_ports_ticket () |
Returns a ticket indicating dependence on every possible independent source value except input ports. More... | |
static DependencyTicket | all_sources_ticket () |
Returns a ticket indicating dependence on every possible independent source value, including time, accuracy, state, input ports, and parameters (but not cache entries). More... | |
static DependencyTicket | configuration_ticket () |
Returns a ticket indicating dependence on all source values that may affect configuration-dependent computations. More... | |
static DependencyTicket | kinematics_ticket () |
Returns a ticket indicating dependence on all source values that may affect configuration- or velocity-dependent computations. More... | |
static DependencyTicket | xcdot_ticket () |
Returns a ticket for the cache entry that holds time derivatives of the continuous variables. More... | |
static DependencyTicket | pe_ticket () |
Returns a ticket for the cache entry that holds the potential energy calculation. More... | |
static DependencyTicket | ke_ticket () |
Returns a ticket for the cache entry that holds the kinetic energy calculation. More... | |
static DependencyTicket | pc_ticket () |
Returns a ticket for the cache entry that holds the conservative power calculation. More... | |
static DependencyTicket | pnc_ticket () |
Returns a ticket for the cache entry that holds the non-conservative power calculation. More... | |
static DependencyTicket | xd_unique_periodic_update_ticket () |
(Internal use only) Returns a ticket for the cache entry that holds the unique periodic discrete update computation. More... | |
Additional Inherited Members | |
Public Types inherited from Diagram< T > | |
using | InputPortLocator = std::pair< const System< T > *, InputPortIndex > |
A designator for a "system + input port" pair, to uniquely refer to some input port on one of this diagram's subsystems. More... | |
using | OutputPortLocator = std::pair< const System< T > *, OutputPortIndex > |
A designator for a "system + output port" pair, to uniquely refer to some output port on one of this diagram's subsystems. More... | |
Public Types inherited from System< T > | |
using | Scalar = T |
The scalar type with which this System was instantiated. More... | |
Protected Member Functions inherited from Diagram< T > | |
Diagram () | |
Constructs an uninitialized Diagram. More... | |
Diagram (SystemScalarConverter converter) | |
(Advanced) Constructs an uninitialized Diagram. More... | |
template<typename U > | |
Diagram (SystemScalarConverter converter, const Diagram< U > &other) | |
(Advanced) Scalar-converting constructor, for used by derived classes that are performing a conversion and also need to supply a converter that preserves subtypes for additional conversions. More... | |
T | 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' Evaluate 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... | |
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... | |
std::string | GetUnsupportedScalarConversionMessage (const std::type_info &source_type, const std::type_info &destination_type) const final |
(Internal use only) Returns the message to use for a std::exception in the case of unsupported scalar type conversions. More... | |
GraphvizFragment | DoGetGraphvizFragment (const GraphvizFragmentParams ¶ms) const override |
The NVI implementation of SystemBase::GetGraphvizFragment() for subclasses to override if desired. 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... | |
bool | forced_publish_events_exist () const |
bool | forced_discrete_update_events_exist () const |
bool | forced_unrestricted_update_events_exist () const |
EventCollection< PublishEvent< T > > & | get_mutable_forced_publish_events () |
EventCollection< DiscreteUpdateEvent< T > > & | get_mutable_forced_discrete_update_events () |
EventCollection< UnrestrictedUpdateEvent< T > > & | get_mutable_forced_unrestricted_update_events () |
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) |
SystemScalarConverter & | get_mutable_system_scalar_converter () |
Returns the SystemScalarConverter for this system. More... | |
CacheEntry & | DeclareCacheEntry (std::string description, ValueProducer value_producer, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()}) |
Declares a new CacheEntry in this System using the most generic form of the calculation function. More... | |
template<class MySystem , class MyContext , typename ValueType > | |
CacheEntry & | DeclareCacheEntry (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 > | |
CacheEntry & | DeclareCacheEntry (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... | |
System (SystemScalarConverter converter) | |
Constructs an empty System base class object and allocates base class resources, possibly supporting scalar-type conversion support (AutoDiff, etc.) using converter . More... | |
InputPort< T > & | DeclareInputPort (std::variant< std::string, UseDefaultName > name, PortDataType type, int size, std::optional< RandomDistribution > random_type=std::nullopt) |
Adds a port with the specified type and size to the input topology. More... | |
virtual T | DoCalcPotentialEnergy (const Context< T > &context) const |
Override this method for physical systems to calculate the potential energy PE 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 KE 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 Pc 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 Pnc at which work W is done on the system by non-conservative forces. 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). 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... | |
std::string | NextInputPortName (std::variant< std::string, UseDefaultName > given_name) const |
(Internal use only) Returns a name for the next input port, using the given name if it isn't kUseDefaultName, otherwise making up a name like "u3" from the next available input port index. More... | |
std::string | NextOutputPortName (std::variant< std::string, UseDefaultName > given_name) const |
(Internal use only) Returns a name for the next output port, using the given name if it isn't kUseDefaultName, otherwise making up a name like "y3" from the next available output port index. 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... | |
CacheEntry & | DeclareCacheEntryWithKnownTicket (DependencyTicket known_ticket, std::string description, ValueProducer value_producer, 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... | |
bool | IsObviouslyNotInputDependent (DependencyTicket dependency_ticket) const |
(Internal use only) Checks if a ticket depends on (any) input port. More... | |
const AbstractValue * | EvalAbstractInputImpl (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::exception 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::exception 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::exception 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::exception 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::exception 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::exception because someone called API method func , that requires this input port to be evaluatable, but the port was neither fixed nor connected. More... | |
const InputPortBase & | GetInputPortBaseOrThrow (const char *func, int port_index, bool warn_deprecated) const |
(Internal use only) Returns the InputPortBase at index port_index , throwing std::exception we don't like the port index. More... | |
const OutputPortBase & | GetOutputPortBaseOrThrow (const char *func, int port_index, bool warn_deprecated) const |
(Internal use only) Returns the OutputPortBase at index port_index , throwing std::exception if we don't like the port index. More... | |
void | ThrowValidateContextMismatch (const ContextBase &) const |
(Internal use only) Throws std::exception with a message that the sanity check(s) given by ValidateContext have failed. 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... | |
const ContextSizes & | get_context_sizes () const |
Obtains access to the declared Context partition sizes as accumulated during LeafSystem or Diagram construction . More... | |
ContextSizes & | get_mutable_context_sizes () |
Obtains mutable access to the Context sizes struct. More... | |
void | set_implicit_time_derivatives_residual_size (int n) |
Allows a LeafSystem to override the default size for the implicit time derivatives residual and a Diagram to sum up the total size. More... | |
internal::SystemId | get_system_id () const |
(Internal) Gets the id used to tag context data as being created by this system. More... | |
CacheEntry & | DeclareCacheEntry (std::string description, ValueProducer value_producer, std::set< DependencyTicket > prerequisites_of_calc={ all_sources_ticket()}) |
Declares a new CacheEntry in this System using the most generic form of the calculation function. More... | |
template<class MySystem , class MyContext , typename ValueType > | |
CacheEntry & | DeclareCacheEntry (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 > | |
CacheEntry & | DeclareCacheEntry (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... | |
Static Protected Member Functions inherited from System< T > | |
static void | FindUniquePeriodicDiscreteUpdatesOrThrow (const char *api_name, const System< T > &system, const Context< T > &context, std::optional< PeriodicEventData > *timing, EventCollection< DiscreteUpdateEvent< T >> *events) |
(Internal use only) Static interface to DoFindUniquePeriodicDiscreteUpdatesOrThrow() to allow a Diagram to invoke that private method on its subsystems. 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... | |
static void | ThrowInputPortHasWrongType (const char *func, const std::string &system_pathname, InputPortIndex, const std::string &port_name, const std::string &expected_type, const std::string &actual_type) |
Throws std::exception because someone called API method func claiming the input port had some value type that was wrong. More... | |
static const ContextSizes & | get_context_sizes (const SystemBase &system) |
Allows Diagram to access protected get_context_sizes() recursively on its subsystems. More... | |
|
delete |
|
delete |
|
explicit |
Construct the EMPTY station model.
time_step | The time step used by MultibodyPlant<T>, and by the discrete derivative used to approximate velocity from the position command inputs. |
void AddManipulandFromFile | ( | const std::string & | model_file, |
const math::RigidTransform< double > & | X_WObject | ||
) |
Adds a single object for the robot to manipulate.
model_file | The path to the .sdf model file of the object. |
X_WObject | The pose of the object in world frame. |
|
static |
Returns the name of the station's default renderer.
void Finalize | ( | ) |
Users must call Finalize() after making any additions to the multibody plant and before using this class in the Systems framework.
This should be called exactly once. This assumes an IIWA and WSG have been added to the MultibodyPlant, and RegisterIiwaControllerModel() and RegisterWsgControllerModel() have been called.
void Finalize | ( | std::map< std::string, std::unique_ptr< geometry::render::RenderEngine >> | render_engines | ) |
Finalizes the station with the option of specifying the renderers the manipulation station uses.
Calling this method with an empty map is equivalent to calling Finalize(). See Finalize() for more details.
std::vector<std::string> get_camera_names | ( | ) | const |
Get the camera names / unique ids.
const multibody::MultibodyPlant<T>& get_controller_plant | ( | ) | const |
Return a reference to the plant used by the inverse dynamics controller (which contains only a model of the iiwa + equivalent mass of the gripper).
const multibody::MultibodyPlant<T>& get_multibody_plant | ( | ) | const |
Returns a reference to the main plant responsible for the dynamics of the robot and the environment.
This can be used to, e.g., add additional elements into the world before calling Finalize().
multibody::MultibodyPlant<T>& get_mutable_multibody_plant | ( | ) |
Returns a mutable reference to the main plant responsible for the dynamics of the robot and the environment.
This can be used to, e.g., add additional elements into the world before calling Finalize().
geometry::SceneGraph<T>& get_mutable_scene_graph | ( | ) |
Returns a mutable reference to the SceneGraph responsible for all of the geometry for the robot and the environment.
This can be used to, e.g., add additional elements into the world before calling Finalize().
const geometry::SceneGraph<T>& get_scene_graph | ( | ) | const |
Returns a reference to the SceneGraph responsible for all of the geometry for the robot and the environment.
This can be used to, e.g., add additional elements into the world before calling Finalize().
VectorX<T> GetIiwaPosition | ( | const systems::Context< T > & | station_context | ) | const |
Convenience method for getting all of the joint angles of the Kuka IIWA.
This does not include the gripper.
VectorX<T> GetIiwaVelocity | ( | const systems::Context< T > & | station_context | ) | const |
Convenience method for getting all of the joint velocities of the Kuka.
std::map<std::string, math::RigidTransform<double> > GetStaticCameraPosesInWorld | ( | ) | const |
Returns a map from camera name to X_WCameraBody for all the static (rigidly attached to the world body) cameras that have been registered.
T GetWsgPosition | ( | const systems::Context< T > & | station_context | ) | const |
Convenience method for getting the position of the Schunk WSG.
Note that the WSG position is the signed distance between the two fingers (not the state of the fingers individually).
T GetWsgVelocity | ( | const systems::Context< T > & | station_context | ) | const |
Convenience method for getting the velocity of the Schunk WSG.
int num_iiwa_joints | ( | ) | const |
Gets the number of joints in the IIWA (only – does not include the gripper).
|
delete |
|
delete |
void RegisterIiwaControllerModel | ( | const std::string & | model_path, |
const multibody::ModelInstanceIndex | iiwa_instance, | ||
const multibody::Frame< T > & | parent_frame, | ||
const multibody::Frame< T > & | child_frame, | ||
const math::RigidTransform< double > & | X_PC | ||
) |
Notifies the ManipulationStation that the IIWA robot model instance can be identified by iiwa_instance
as well as necessary information to reload model for the internal controller's use.
Assumes iiwa_instance
has already been added to the MultibodyPlant. Note, the current implementation only allows parent_frame
to be the world frame. The IIWA frame needs to directly contain child_frame
. Only call this with custom IIWA models (i.e. not calling SetupDefaultStation()). Must be called before Finalize().
model_path | Full path to the model file. |
iiwa_instance | Identifies the IIWA model. |
parent_frame | Identifies frame P (the parent frame) in the MultibodyPlant that the IIWA model has been attached to. |
child_frame_name | Identifies frame C (the child frame) in the IIWA model that is welded to frame P. |
X_PC | Transformation between frame P and C. |
If | parent_frame is not the world frame. |
void RegisterRgbdSensor | ( | const std::string & | name, |
const multibody::Frame< T > & | parent_frame, | ||
const math::RigidTransform< double > & | X_PCameraBody, | ||
const geometry::render::DepthRenderCamera & | depth_camera | ||
) |
Registers an RGBD sensor.
Must be called before Finalize().
name | Name for the camera. |
parent_frame | The parent frame (frame P). The body that parent_frame is attached to must have a corresponding geometry::FrameId. Otherwise, an exception will be thrown in Finalize(). |
X_PCameraBody | Transformation between frame P and the camera body. see systems::sensors:::RgbdSensor for descriptions about how the camera body, RGB, and depth image frames are related. |
depth_camera | Specification for the RGBD camera. The color render camera is inferred from the depth_camera. The color camera will share the RenderCameraCore and be configured to not show its window. |
void RegisterRgbdSensor | ( | const std::string & | name, |
const multibody::Frame< T > & | parent_frame, | ||
const math::RigidTransform< double > & | X_PCameraBody, | ||
const geometry::render::ColorRenderCamera & | color_camera, | ||
const geometry::render::DepthRenderCamera & | depth_camera | ||
) |
Registers an RGBD sensor with uniquely characterized color/label and depth cameras.
void RegisterWsgControllerModel | ( | const std::string & | model_path, |
const multibody::ModelInstanceIndex | wsg_instance, | ||
const multibody::Frame< T > & | parent_frame, | ||
const multibody::Frame< T > & | child_frame, | ||
const math::RigidTransform< double > & | X_PC | ||
) |
Notifies the ManipulationStation that the WSG gripper model instance can be identified by wsg_instance
, as well as necessary information to reload model for the internal controller's use.
Assumes wsg_instance
has already been added to the MultibodyPlant. The IIWA model needs to directly contain parent_frame
, and the WSG model needs to directly contain child_frame
. Only call this with custom WSG models (i.e. not calling SetupDefaultStation()). Must be called before Finalize().
model_path | Full path to the model file. |
wsg_instance | Identifies the WSG model. |
parent_frame | Identifies frame P (the parent frame) in the MultibodyPlant that the WSG model has been attached to. Has to be part of the IIWA model. |
child_frame | Identifies frame C (the child frame) in the WSG model that is used welded to frame P. |
X_PC | Transformation between frame P and C. |
|
override |
Sets the default State for the chosen setup.
context | A const reference to the ManipulationStation context. |
state | A pointer to the State of the ManipulationStation system. |
state
must be the systems::State<T> object contained in station_context
. Set the integral gains for the IIWA controller.
std::exception | if Finalize() has been called. |
void SetIiwaPosition | ( | const systems::Context< T > & | station_context, |
systems::State< T > * | state, | ||
const Eigen::Ref< const VectorX< T >> & | q | ||
) | const |
Convenience method for setting all of the joint angles of the Kuka IIWA.
Also sets the position history in the velocity command generator. q
must have size num_iiwa_joints().
state
must be the systems::State<T> object contained in station_context
. void SetIiwaPosition | ( | systems::Context< T > * | station_context, |
const Eigen::Ref< const VectorX< T >> & | q | ||
) | const |
Convenience method for setting all of the joint angles of the Kuka IIWA.
Also sets the position history in the velocity command generator. q
must have size num_iiwa_joints().
Set the position gains for the IIWA controller.
std::exception | if Finalize() has been called. |
void SetIiwaVelocity | ( | const systems::Context< T > & | station_context, |
systems::State< T > * | state, | ||
const Eigen::Ref< const VectorX< T >> & | v | ||
) | const |
Convenience method for setting all of the joint velocities of the Kuka IIWA.
@v must have size num_iiwa_joints().
state
must be the systems::State<T> object contained in station_context
. void SetIiwaVelocity | ( | systems::Context< T > * | station_context, |
const Eigen::Ref< const VectorX< T >> & | v | ||
) | const |
Convenience method for setting all of the joint velocities of the Kuka IIWA.
@v must have size num_iiwa_joints().
Set the velocity gains for the IIWA controller.
std::exception | if Finalize() has been called. |
|
override |
Sets a random State for the chosen setup.
context | A const reference to the ManipulationStation context. |
state | A pointer to the State of the ManipulationStation system. |
generator | is the random number generator. |
state
must be the systems::State<T> object contained in station_context
. void SetupClutterClearingStation | ( | const std::optional< const math::RigidTransformd > & | X_WCameraBody = {} , |
IiwaCollisionModel | collision_model = IiwaCollisionModel::kNoCollision , |
||
SchunkCollisionModel | schunk_model = SchunkCollisionModel::kBox |
||
) |
Adds a default iiwa, wsg, two bins, and a camera, then calls RegisterIiwaControllerModel() and RegisterWsgControllerModel() with the appropriate arguments.
Setup___()
methods should be called. X_WCameraBody | Transformation between the world and the camera body. |
collision_model | Determines which sdf is loaded for the IIWA. |
schunk_model | Determines which sdf is loaded for the Schunk. |
void SetupManipulationClassStation | ( | IiwaCollisionModel | collision_model = IiwaCollisionModel::kNoCollision , |
SchunkCollisionModel | schunk_model = SchunkCollisionModel::kBox |
||
) |
Adds a default iiwa, wsg, cupboard, and 80/20 frame for the MIT Intelligent Robot Manipulation class, then calls RegisterIiwaControllerModel() and RegisterWsgControllerModel() with the appropriate arguments.
Setup___()
methods should be called. collision_model | Determines which sdf is loaded for the IIWA. |
schunk_model | Determines which sdf is loaded for the Schunk. |
void SetupPlanarIiwaStation | ( | SchunkCollisionModel | schunk_model = SchunkCollisionModel::kBox | ) |
Adds a version of the iiwa with joints that would result in out-of-plane rotations welded in a fixed orientation, reducing the total degrees of freedom of the arm to 3.
This arm lives in the X-Z plane. Also adds the WSG planar gripper and two tables to form the workspace. Note that additional floating base objects (aka manipulands) will still potentially move in 3D.
Setup___()
methods should be called. schunk_model | Determines which sdf is loaded for the Schunk. |
Set the gains for the WSG controller.
std::exception | if Finalize() has been called. |
void SetWsgPosition | ( | const systems::Context< T > & | station_context, |
systems::State< T > * | state, | ||
const T & | q | ||
) | const |
Convenience method for setting the position of the Schunk WSG.
Also sets the position history in the velocity interpolator. Note that the WSG position is the signed distance between the two fingers (not the state of the fingers individually).
state
must be the systems::State<T> object contained in station_context
. void SetWsgPosition | ( | systems::Context< T > * | station_context, |
const T & | q | ||
) | const |
Convenience method for setting the position of the Schunk WSG.
Also sets the position history in the velocity interpolator. Note that the WSG position is the signed distance between the two fingers (not the state of the fingers individually).
void SetWsgVelocity | ( | const systems::Context< T > & | station_context, |
systems::State< T > * | state, | ||
const T & | v | ||
) | const |
Convenience method for setting the velocity of the Schunk WSG.
state
must be the systems::State<T> object contained in station_context
. void SetWsgVelocity | ( | systems::Context< T > * | station_context, |
const T & | v | ||
) | const |
Convenience method for setting the velocity of the Schunk WSG.