Drake
Rod2D< T > Class Template Reference

Dynamical system representation of a rod contacting a half-space in two dimensions. More...

#include <drake/examples/rod2d/rod2d.h>

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

## Public Types

enum  SimulationType { kPiecewiseDAE, kTimeStepping, kCompliant }
Simulation model and approach for the system. More...

enum  Mode {
kInvalid, kBallisticMotion, kSlidingSingleContact, kStickingSingleContact,
kSlidingTwoContacts, kStickingTwoContacts
}
Possible dynamic modes for the 2D rod. More...

## Public Member Functions

~Rod2D () override

Rod2D (SimulationType simulation_type, double dt)
Constructor for the 2D rod system using the piecewise DAE (differential algebraic equation) based approach, the time stepping approach, or the compliant ordinary differential equation based approach. More...

double get_cfm () const
Gets the constraint force mixing parameter (CFM, used for time stepping systems only). More...

void set_cfm (double cfm)
Sets the constraint force mixing parameter (CFM, used for time stepping systems only). More...

double get_erp () const
Gets the error reduction parameter (ERP, used for time stepping systems only). More...

void set_erp (double erp)
Sets the error reduction parameter (ERP, used for time stepping systems only). More...

Vector3< T > GetRodConfig (const systems::Context< T > &context) const
Gets the generalized position of the rod, given a Context. More...

Vector3< T > GetRodVelocity (const systems::Context< T > &context) const
Gets the generalized velocity of the rod, given a Context. More...

void HandleImpact (const systems::Context< T > &context, systems::State< T > *new_state) const
Models impact using an inelastic impact model with friction. More...

double get_gravitational_acceleration () const
Gets the acceleration (with respect to the positive y-axis) due to gravity (i.e., this number should generally be negative). More...

void set_gravitational_acceleration (double g)
Sets the acceleration (with respect to the positive y-axis) due to gravity (i.e., this number should generally be negative). More...

double get_mu_coulomb () const
Gets the coefficient of dynamic (sliding) Coulomb friction. More...

void set_mu_coulomb (double mu)
Sets the coefficient of dynamic (sliding) Coulomb friction. More...

double get_rod_mass () const
Gets the mass of the rod. More...

void set_rod_mass (double mass)
Sets the mass of the rod. More...

double get_rod_half_length () const
Gets the half-length h of the rod. More...

void set_rod_half_length (double half_length)
Sets the half-length h of the rod. More...

double get_rod_moment_of_inertia () const
Gets the rod moment of inertia. More...

void set_rod_moment_of_inertia (double J)
Sets the rod moment of inertia. More...

double get_stiffness () const
Get compliant contact normal stiffness in N/m. More...

void set_stiffness (double stiffness)
Set compliant contact normal stiffness in N/m (>= 0). More...

double get_dissipation () const
Get compliant contact normal dissipation in 1/velocity (s/m). More...

void set_dissipation (double dissipation)
Set compliant contact normal dissipation in 1/velocity (s/m, >= 0). More...

double get_mu_static () const
Get compliant contact static friction (stiction) coefficient μ_s. More...

void set_mu_static (double mu_static)
Set contact stiction coefficient (>= mu_coulomb). More...

double get_stiction_speed_tolerance () const
Get the stiction speed tolerance (m/s). More...

void set_stiction_speed_tolerance (double v_stick_tol)
Set the stiction speed tolerance (m/s). More...

Matrix2< T > GetSlidingContactFrameToWorldTransform (const T &xaxis_velocity) const
Gets the rotation matrix that transforms velocities from a sliding contact frame to the global frame. More...

Matrix2< T > GetNonSlidingContactFrameToWorldTransform () const
Gets the rotation matrix that transforms velocities from a non-sliding contact frame to the global frame. More...

bool IsImpacting (const systems::Context< T > &context) const
Checks whether the system is in an impacting state, meaning that the relative velocity along the contact normal between the rod and the halfspace is such that the rod will begin interpenetrating the halfspace at any time Δt in the future (i.e., Δt > 0). More...

double get_integration_step_size () const
Gets the integration step size for the time stepping system. More...

SimulationType get_simulation_type () const
Gets the model and simulation type for this system. More...

Vector3< T > CalcCompliantContactForces (const systems::Context< T > &context) const
Return net contact forces as a spatial force F_Ro_W=(fx,fy,τ) where translational force f_Ro_W=(fx,fy) is applied at the rod origin Ro, and torque t_R=τ is the moment due to the contact forces actually being applied elsewhere. More...

CalcSignedDistance (const systems::Context< T > &context) const
The witness function for signed distance between the rod and the half-space. More...

CalcEndpointDistance (const systems::Context< T > &context) const
The witness function for the signed distance between one endpoint of the rod (not already touching the half-space) and the half-space for the case when the rod is contacting the ground with a single point of contact. More...

CalcNormalAccelWithoutContactForces (const systems::Context< T > &context) const
The witness function that determines whether the rod should separate from the halfspace. More...

CalcSlidingDot (const systems::Context< T > &context) const
Evaluates the witness function for sliding direction changes. More...

CalcStickingFrictionForceSlack (const systems::Context< T > &context) const
Evaluates the witness function for determining whether the rod in sticking frictional contact should transition to sliding contact. More...

int DetermineNumWitnessFunctions (const systems::Context< T > &context) const
Gets the number of witness functions for the system active in the system for a given state (using context). More...

const systems::OutputPort< T > & pose_output () const
Returns the 3D pose of this rod. More...

void GetContactPoints (const systems::Context< T > &context, std::vector< Vector2< T >> *points) const
Gets the point(s) of contact for the 2D rod. More...

void GetContactPointsTangentVelocities (const systems::Context< T > &context, const std::vector< Vector2< T >> &points, std::vector< T > *vels) const
Gets the tangent velocities for all contact points. More...

void CalcConstraintProblemData (const systems::Context< T > &context, const std::vector< Vector2< T >> &points, const std::vector< T > &tangent_vels, multibody::constraint::ConstraintAccelProblemData< T > *data) const
Initializes the contact data for the rod, given a set of contact points. More...

void CalcImpactProblemData (const systems::Context< T > &context, const std::vector< Vector2< T >> &points, multibody::constraint::ConstraintVelProblemData< T > *data) const
Initializes the impacting contact data for the rod, given a set of contact points. More...

Public Member Functions inherited from LeafSystem< T >
~LeafSystem () override

std::unique_ptr< CompositeEventCollection< T > > AllocateCompositeEventCollection () const final
Allocates a CompositeEventCollection object for this system. More...

std::unique_ptr< Context< T > > AllocateContext () const override
Allocates a context, initialized with the correct numbers of concrete input ports and state variables for this System. More...

void SetDefaultState (const Context< T > &context, State< T > *state) const override
Default implementation: sets all continuous and discrete state variables to zero. More...

virtual void SetDefaultParameters (const LeafContext< T > &context, Parameters< T > *parameters) const
Default implementation: sets all numeric parameters to the model vector given to DeclareNumericParameter, or else if no model was provided sets the numeric parameter to one. More...

void SetDefaults (Context< T > *context) const final

std::unique_ptr< SystemOutput< T > > AllocateOutput (const Context< T > &context) const final
Returns a container that can hold the values of all of this System's output ports. More...

std::unique_ptr< ContinuousState< T > > AllocateTimeDerivatives () const override
Returns the AllocateContinuousState value, which must not be nullptr. More...

std::unique_ptr< DiscreteValues< T > > AllocateDiscreteVariables () const override
Returns the AllocateDiscreteState value, which must not be nullptr. More...

std::multimap< int, intGetDirectFeedthroughs () const final
Reports all direct feedthroughs from input ports to output ports. More...

LeafSystem (const LeafSystem &)=delete

LeafSystemoperator= (const LeafSystem &)=delete

LeafSystem (LeafSystem &&)=delete

LeafSystemoperator= (LeafSystem &&)=delete

Public Member Functions inherited from System< T >
virtual ~System ()

void GetWitnessFunctions (const Context< T > &context, std::vector< const WitnessFunction< T > * > *w) const
Gets the witness functions active at the beginning of a continuous time interval. More...

EvaluateWitness (const Context< T > &context, const WitnessFunction< T > &witness_func) const
Evaluates a witness function at the given context. More...

std::string GetSystemIdString () const
Returns a string suitable for identifying this particular System in error messages, when it is a subsystem of a larger Diagram. More...

System (const System &)=delete

Systemoperator= (const System &)=delete

System (System &&)=delete

Systemoperator= (System &&)=delete

std::unique_ptr< BasicVector< T > > AllocateInputVector (const InputPortDescriptor< T > &descriptor) const
Given a port descriptor, allocates the vector storage. More...

std::unique_ptr< AbstractValueAllocateInputAbstract (const InputPortDescriptor< T > &descriptor) const
Given a port descriptor, allocates the abstract storage. More...

std::unique_ptr< Context< T > > CreateDefaultContext () const
This convenience method allocates a context using AllocateContext() and sets its default values using SetDefaults(). More...

void AllocateFreestandingInputs (Context< T > *context) const
For each input port, allocates a freestanding 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
Causes the vector-valued input port with the given port_index to become up-to-date, delegating to our parent Diagram if necessary. More...

Eigen::VectorBlock< const VectorX< T > > EvalEigenVectorInput (const Context< T > &context, int port_index) const
Causes the vector-valued input port with the given port_index to become up-to-date, delegating to our parent Diagram if necessary. More...

const AbstractValueEvalAbstractInput (const Context< T > &context, int port_index) const
Causes the abstract-valued input port with the given port_index to become up-to-date, delegating to our parent Diagram if necessary. More...

template<typename V >
const V * EvalInputValue (const Context< T > &context, int port_index) const
Causes the abstract-valued input port with the given port_index to become up-to-date, delegating to our parent Diagram if necessary. 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 discrete_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 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...

void set_name (const std::string &name)
Sets the name of the system. More...

std::string get_name () const
Returns the name last supplied to set_name(), or empty if set_name() was never called. More...

std::string GetMemoryObjectName () const
Returns a name for this System based on a stringification of its type name and memory address. More...

void GetPath (std::stringstream *output) const
Writes the full path of this System in the tree of Systems to output. More...

std::string GetPath () const

int get_num_input_ports () const
Returns the number of input ports of the system. More...

int get_num_output_ports () const
Returns the number of output ports of the system. More...

const InputPortDescriptor< T > & get_input_port (int port_index) const
Returns the descriptor of the input port at index port_index. More...

const OutputPort< T > & get_output_port (int port_index) const
Returns the 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...

int get_num_total_inputs () const
Returns the total dimension of all of the input ports (as if they were muxed). More...

int get_num_total_outputs () const
Returns the total dimension of all of the output ports (as if they were muxed). 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 CheckValidContext (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...

void set_parent (const detail::InputPortEvaluatorInterface< T > *parent)
Declares that parent is the immediately enclosing Diagram. 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...

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...

## Static Public Member Functions

static Vector2< T > CalcRodEndpoint (const T &x, const T &y, int k, const T &ctheta, const T &stheta, double half_rod_len)
Utility method for determining the World frame location of one of three points on the rod whose origin is Ro. More...

static Vector2< T > CalcCoincidentRodPointVelocity (const Vector2< T > &p_WRo, const Vector2< T > &v_WRo, const T &w_WR, const Vector2< T > &p_WC)
Given a location p_WC of a point C in the World frame, define the point Rc on the rod that is coincident with C, and report Rc's World frame velocity v_WRc. 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...

## Friends

class Rod2DDAETest

class Rod2DDAETest_RigidContactProblemDataBallistic_Test

Protected Member Functions inherited from LeafSystem< T >
LeafSystem ()
Default constructor that declares no inputs, outputs, state, parameters, events, nor scalar-type conversion support (AutoDiff, etc.). More...

LeafSystem (SystemScalarConverter converter)
Constructor that declares no inputs, outputs, state, parameters, or events, but allows subclasses to declare scalar-type conversion support (AutoDiff, etc.). More...

System< AutoDiffXd > * DoToAutoDiffXd () const override
NVI implementation of ToAutoDiffXdMaybe. More...

System< symbolic::Expression > * DoToSymbolic () const override
NVI implementation of ToSymbolicMaybe. More...

virtual std::unique_ptr< LeafContext< T > > DoMakeContext () const
Provides a new instance of the leaf context for this system. More...

DoEvaluateWitness (const Context< T > &context, const WitnessFunction< T > &witness_func) const final
Derived classes will implement this method to evaluate a witness function at the given context. More...

void AddTriggeredWitnessFunctionToCompositeEventCollection (const WitnessFunction< T > &witness_func, CompositeEventCollection< T > *events) const final
Add witness_func to events. More...

void DoCalcNextUpdateTime (const Context< T > &context, CompositeEventCollection< T > *events, T *time) const override
Computes the next update time based on the configured periodic events, for scalar types that are arithmetic, or aborts for scalar types that are not arithmetic. More...

BasicVector< T > * DoAllocateInputVector (const InputPortDescriptor< T > &descriptor) const override
Allocates a vector that is suitable as an input value for descriptor. More...

AbstractValueDoAllocateInputAbstract (const InputPortDescriptor< T > &descriptor) const override
Allocates an AbstractValue suitable as an input value for descriptor. More...

void GetGraphvizFragment (std::stringstream *dot) const override
Emits a graphviz fragment for this System. More...

void GetGraphvizInputPortToken (const InputPortDescriptor< T > &port, std::stringstream *dot) const final
Appends a fragment to the dot stream identifying the graphviz node representing port. More...

void GetGraphvizOutputPortToken (const OutputPort< T > &port, std::stringstream *dot) const final
Appends a fragment to the dot stream identifying the graphviz node representing port. More...

virtual std::unique_ptr< ContinuousState< T > > AllocateContinuousState () const
Returns a ContinuousState used to implement both CreateDefaultContext and AllocateTimeDerivatives. More...

virtual std::unique_ptr< DiscreteValues< T > > AllocateDiscreteState () const
Reserves the discrete state as required by CreateDefaultContext. More...

virtual std::unique_ptr< Parameters< T > > AllocateParameters () const
Reserves the parameters as required by CreateDefaultContext. More...

virtual optional< boolDoHasDirectFeedthrough (int input_port, int output_port) const
Returns true if there is direct-feedthrough from the given input_port to the given output_port, false if there is not direct-feedthrough, or nullopt if unknown (in which case SystemSymbolicInspector will attempt to measure the feedthrough using symbolic form). More...

int DeclareNumericParameter (const BasicVector< T > &model_vector)
Declares a numeric parameter using the given model_vector. More...

template<template< typename > class U = BasicVector>
const U< T > & GetNumericParameter (const Context< T > &context, int index) const
Extracts the numeric parameters of type U from the context at index. More...

template<template< typename > class U = BasicVector>
U< T > * GetMutableNumericParameter (Context< T > *context, int index) const
Extracts the numeric parameters of type U from the context at index. More...

template<typename EventType >
void DeclarePeriodicEvent (double period_sec, double offset_sec)
Declares that this System has a simple, fixed-period event specified with no custom callback function, and its attribute field contains an Event<T>::PeriodicAttribute constructed from the specified period_sec and offset_sec. More...

template<typename EventType >
void DeclarePeriodicEvent (double period_sec, double offset_sec, const EventType &event)
Declares that this System has a simple, fixed-period event specified by event. More...

void DeclarePeriodicDiscreteUpdate (double period_sec, double offset_sec=0)
Declares a periodic discrete update event with period = period_sec and offset = offset_sec. More...

void DeclarePeriodicUnrestrictedUpdate (double period_sec, double offset_sec=0)
Declares a periodic unrestricted update event with period = period_sec and offset = offset_sec. More...

void DeclarePeriodicPublish (double period_sec, double offset_sec=0)
Declares a periodic publish event with period = period_sec and offset = offset_sec. More...

template<typename EventType >
void DeclarePerStepEvent (const EventType &event)
Declares a per-step event using event, which is deep copied (the copy is maintained by this). More...

void DeclareContinuousState (int num_state_variables)
Declares that this System should reserve continuous state with num_state_variables state variables, which have no second-order structure. More...

void DeclareContinuousState (int num_q, int num_v, int num_z)
Declares that this System should reserve continuous state with num_q generalized positions, num_v generalized velocities, and num_z miscellaneous state variables. More...

void DeclareContinuousState (const BasicVector< T > &model_vector)
Declares that this System should reserve continuous state with model_vector.size() miscellaneous state variables, stored in a vector Cloned from model_vector. More...

void DeclareContinuousState (const BasicVector< T > &model_vector, int num_q, int num_v, int num_z)
Declares that this System should reserve continuous state with num_q generalized positions, num_v generalized velocities, and num_z miscellaneous state variables, stored in a vector Cloned from model_vector. More...

void DeclareContinuousState (std::unique_ptr< BasicVector< T >> model_vector, int num_q, int num_v, int num_z)
Declares that this System should reserve continuous state with num_q generalized positions, num_v generalized velocities, and num_z miscellaneous state variables, stored in the a vector Cloned from model_vector. More...

void DeclareDiscreteState (int num_state_variables)
Declares that this System should reserve discrete state with num_state_variables state variables. More...

int DeclareAbstractState (std::unique_ptr< AbstractValue > abstract_state)
Declares an abstract state. More...

template<class MySystem >
SystemConstraintIndex DeclareEqualityConstraint (void(MySystem::*calc)(const Context< T > &, VectorX< T > *) const, int count, const std::string &description)
Declares a system constraint of the form f(context) = 0 by specifying a member function to use to calculate the (VectorX) constraint value with a signature: More...

SystemConstraintIndex DeclareEqualityConstraint (typename SystemConstraint< T >::CalcCallback calc, int count, const std::string &description)
Declares a system constraint of the form f(context) = 0 by specifying a std::function to use to calculate the (Vector) constraint value with a signature: More...

template<class MySystem >
SystemConstraintIndex DeclareInequalityConstraint (void(MySystem::*calc)(const Context< T > &, VectorX< T > *) const, int count, const std::string &description)
Declares a system constraint of the form f(context) ≥ 0 by specifying a member function to use to calculate the (VectorX) constraint value with a signature: More...

SystemConstraintIndex DeclareInequalityConstraint (typename SystemConstraint< T >::CalcCallback calc, int count, const std::string &description)
Declares a system constraint of the form f(context) ≥ 0 by specifying a std::function to use to calculate the (Vector) constraint value with a signature: More...

virtual void DoPublish (const Context< T > &context, const std::vector< const PublishEvent< T > * > &events) const
Derived-class event handler for all simultaneous publish events in events. More...

virtual void DoCalcDiscreteVariableUpdates (const Context< T > &context, const std::vector< const DiscreteUpdateEvent< T > * > &events, DiscreteValues< T > *discrete_state) const
Derived-class event handler for all simultaneous discrete update events. More...

virtual void DoCalcUnrestrictedUpdate (const Context< T > &context, const std::vector< const UnrestrictedUpdateEvent< T > * > &events, State< T > *state) const
Derived-class event handler for all simultaneous unrestricted update events. More...

const InputPortDescriptor< T > & DeclareVectorInputPort (const BasicVector< T > &model_vector)
Declares a vector-valued input port using the given model_vector. More...

const InputPortDescriptor< T > & DeclareAbstractInputPort (const AbstractValue &model_value)
Declares an abstract-valued input port using the given model_value. More...

template<class MySystem , typename BasicVectorSubtype >
const OutputPort< T > & DeclareVectorOutputPort (const BasicVectorSubtype &model_vector, void(MySystem::*calc)(const Context< T > &, BasicVectorSubtype *) const)
Declares a vector-valued output port by specifying (1) a model vector of type BasicVectorSubtype derived from BasicVector and initialized to the correct size and desired initial value, and (2) a calculator function that is a class member function (method) with signature: More...

template<class MySystem , typename BasicVectorSubtype >
const OutputPort< T > & DeclareVectorOutputPort (void(MySystem::*calc)(const Context< T > &, BasicVectorSubtype *) const)
Declares a vector-valued output port by specifying only a calculator function that is a class member function (method) with signature: More...

const OutputPort< T > & DeclareVectorOutputPort (const BasicVector< T > &model_vector, typename LeafOutputPort< T >::CalcVectorCallback vector_calc_function)
(Advanced) Declares a vector-valued output port using the given model_vector and a function for calculating the port's value at runtime. More...

template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (const OutputType &model_value, void(MySystem::*calc)(const Context< T > &, OutputType *) const)
Declares an abstract-valued output port by specifying a model value of concrete type OutputType and a calculator function that is a class member function (method) with signature: More...

template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (void(MySystem::*calc)(const Context< T > &, OutputType *) const)
Declares an abstract-valued output port by specifying only a calculator function that is a class member function (method) with signature: More...

template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (OutputType(MySystem::*make)(const Context< T > &) const, void(MySystem::*calc)(const Context< T > &, OutputType *) const)
Declares an abstract-valued output port by specifying member functions to use both for the allocator and calculator. More...

template<class MySystem , typename OutputType >
const OutputPort< T > & DeclareAbstractOutputPort (OutputType(MySystem::*make)() const, void(MySystem::*calc)(const Context< T > &, OutputType *) const)
Declares an abstract-valued output port by specifying member functions to use both for the allocator and calculator. More...

const OutputPort< T > & DeclareAbstractOutputPort (typename LeafOutputPort< T >::AllocCallback alloc_function, typename LeafOutputPort< T >::CalcCallback calc_function)
(Advanced) Declares an abstract-valued output port using the given allocator and calculator functions provided in their most generic forms. More...

Protected Member Functions inherited from System< T >
virtual void DoGetWitnessFunctions (const Context< T > &, std::vector< const WitnessFunction< T > * > *) const
Derived classes can override this method to provide witness functions active at the beginning of a continuous time interval. More...

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 ()
Constructs an empty System base class object. More...

const InputPortDescriptor< T > & DeclareInputPort (PortDataType type, int size)
Adds a port with the specified type and size to the input topology. More...

const InputPortDescriptor< T > & DeclareAbstractInputPort ()
Adds an abstract-valued port to the input topology. More...

void CreateOutputPort (std::unique_ptr< OutputPort< T >> port)

virtual void DoCalcTimeDerivatives (const Context< T > &context, ContinuousState< T > *derivatives) const
Override this if you have any continuous state variables xc in your concrete System to calculate their time derivatives. 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 void DoMapQDotToVelocity (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &qdot, VectorBase< T > *generalized_velocity) const
Provides the substantive implementation of MapQDotToVelocity(). More...

virtual void DoMapVelocityToQDot (const Context< T > &context, const Eigen::Ref< const VectorX< T >> &generalized_velocity, VectorBase< T > *qdot) const
Provides the substantive implementation of MapVelocityToQDot(). 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...

void EvalInputPort (const Context< T > &context, int port_index) const
Causes an InputPortValue in the context to become up-to-date, delegating to the parent Diagram if necessary. More...

## Detailed Description

### template<typename T> class drake::examples::rod2d::Rod2D< T >

Dynamical system representation of a rod contacting a half-space in two dimensions.

### Notation

In the discussion below and in code comments, we will use the 2D analog of our standard multibody notation as described in detail here: Terminology and Notation.

For a quick summary and translation to 2D:

• When we combine rotational and translational quantities into a single quantity in 3D, we call those "spatial" quantities. In 2D those combined quantities are actually planar, but we will continue to refer to them as "spatial" to keep the notation analogous and promote easy extension of 2D pedagogical examples to 3D.
• We use capital letters to represent bodies and coordinate frames. Frame F has an origin point Fo, and a basis formed by orthogonal unit vector axes Fx and Fy, with an implicit Fz=Fx × Fy always pointing out of the screen for a 2D system. The inertial frame World is W, and the rod frame is R.
• We also use capitals to represent points, and we allow a frame name F to be used where a point is expected to represent its origin Fo.
• We use p_CD to represent the position vector from point C to point D. Note that if A and B are frames, p_AB means p_AoBo.
• If we need to be explicit about the expressed-in frame F for any quantity, we add the suffix _F to its symbol. So the position vector from C to D, expressed in W, is p_CD_W.
• R_AB is the rotation matrix giving frame B's orientation in frame A.
• X_AB is the transformation matrix giving frame B's pose in frame A, combining both a rotation and a translation; this is conventionally called a "transform". A transform is a spatial quantity.

In 2D, with frames A and B the above quantities are (conceptually) matrices with the indicated dimensions:

    p_AB = Bo-Ao = |x|      R_AB=| cθ -sθ |       X_AB=| R_AB p_AB |
|y|₂ₓ₁        | sθ  cθ |₂ₓ₂         | 0  0   1  |₃ₓ₃


where x,y are B's Cartesian coordinates in the A frame, and θ is the counterclockwise angle from Ax to Bx, measured about Az (and Bz). In practice, 2D rotations are represented just by the scalar angle θ, and 2D transforms are represented by (x,y,θ).

We use v for translational velocity of a point and w (ω) for rotational velocity of a frame. The symbols are:

• v_AP is point P's velocity in frame A, expressed in frame A if no other frame is given as a suffix.
• w_AB is frame B's angular velocity in frame A, expressed in frame A if no other frame is given as a suffix.
• V_AB is frame B's spatial velocity in A, meaning v_ABo and w_AB.

These quantities are conceptually:

    v_AB = |vx|      w_AB=|0|       V_AB=| w_AB |
|vy|           |0|            | v_AB |₆ₓ₁
| 0|₃ₓ₁        |ω|₃ₓ₁


but in 2D we represent translational velocity with just (vx,vy), angular velocity with just the scalar w=ω= $$\dot{\theta}$$ (that is, d/dt θ), and spatial velocity as (vx,vy,ω).

Forces f and torques τ are represented similarly:

• f_P is an in-plane force applied to a point P fixed to some rigid body.
• t_A is an in-plane torque applied to frame A (meaning it is about Az).
• F_A is a spatial force including both f_Ao and t_A.

The above symbols can be suffixed with an expressed-in frame if the frame is not already obvious, so F_A_W is a spatial force applied to frame A (at Ao) but expressed in W. These quantities are conceptually:

    f_A = |fx|      t_A=|0|       F_A=| t_A |
|fy|          |0|           | f_A |₆ₓ₁
| 0|₃ₓ₁       |τ|₃ₓ₁


but in 2D we represent translational force with just (fx,fy), torque with just the scalar t=τ, and spatial force as (fx,fy,τ).

### The 2D rod model

The rod's coordinate frame R is placed at the rod's center point Ro, which is also its center of mass Rcm. R's planar pose is given by a planar transform X_WR=(x,y,θ). When X_WR=0 (identity transform), R is coincident with the World frame W, and aligned horizontally as shown:

       +Wy                                  +Ry
|                                    |
|                                    |<---- h ----->
|                      ==============|==============
Wo*-----> +Wx         Rl*            Ro*-----> +Rx    *Rr
=============================
World frame                      Rod R, θ=0


θ is the angle between Rx and Wx, measured using the right hand rule about Wz (out of the screen), that is, counterclockwise. The rod has half-length h, and "left" and "right" endpoints Rl=Ro-h*Rx and Rr=Ro+h*Rx at which it can contact the halfspace whose surface is at Wy=0.

This system can be simulated using one of three models:

• a compliant contact model (the rod is rigid, but contact between the rod and the half-space is modeled as compliant) simulated using ordinary differential equations (ODEs),
• a fully rigid model simulated with piecewise differential algebraic equations (DAEs), and
• a fully rigid model simulated as a discrete system using a first-order time stepping approach.

The rod state is initialized to the configuration that corresponds to the Painlevé Paradox problem, described in [Stewart 2000]. The paradox consists of a rod contacting a planar surface without impact and subject to sliding Coulomb friction. The problem is well known to correspond to an inconsistent rigid contact configuration*, where impulsive forces are necessary to resolve the problem.

This class uses Drake's -inl.h pattern. When seeing linker errors from this class, please refer to http://drake.mit.edu/cxx_inl.html.

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

Instantiated templates for the following scalar types T are provided:

• double

Inputs: planar force (two-dimensional) and torque (scalar), which are arbitrary "external" forces (expressed in the world frame) applied at the center-of-mass of the rod.

States: planar position (state indices 0 and 1) and orientation (state index 2), and planar linear velocity (state indices 3 and 4) and scalar angular velocity (state index 5) in units of m, radians, m/s, and rad/s, respectively. Orientation is measured counter- clockwise with respect to the x-axis. For simulations using the piecewise DAE formulation, one abstract state variable (of type Rod2D::Mode) is used to identify which dynamic mode the system is in (e.g., ballistic, contacting at one point and sliding, etc.) and one abstract state variable (of type int) is used to determine which endpoint(s) of the rod contact the halfspace (k=-1 indicates the left endpoint Rl, k=+1 indicates the right endpoint Rr, and k=0 indicates that both endpoints of the rod are contacting the halfspace).

Outputs: Output Port 0 corresponds to the state vector; Output Port 1 corresponds to a PoseVector giving the 3D pose of the rod in the world frame.

• [Stewart, 2000] D. Stewart, "Rigid-Body Dynamics with Friction and Impact". SIAM Rev., 42(1), 3-39, 2000.

## Member Enumeration Documentation

 enum Mode

Possible dynamic modes for the 2D rod.

Enumerator
kInvalid

Mode is invalid.

kBallisticMotion

Rod is currently undergoing ballistic motion.

kSlidingSingleContact

Rod is sliding while undergoing non-impacting contact at one contact point (a rod endpoint); the other rod endpoint is not in contact.

kStickingSingleContact

Rod is sticking while undergoing non-impacting contact at one contact point (a rod endpoint); the other rod endpoint is not in contact.

kSlidingTwoContacts

Rod is sliding at two contact points without impact.

It should be evident that the tangent velocity at the two endpoints of the rod must be equal.

kStickingTwoContacts

Rod is sticking at two contact points without impact.

It should be evident that the tangent velocity at two endpoints of the rod must be both zero or both nonzero.

 enum SimulationType
strong

Simulation model and approach for the system.

Enumerator
kPiecewiseDAE

For simulating the system using rigid contact, Coulomb friction, and piecewise differential algebraic equations.

kTimeStepping

For simulating the system using rigid contact, Coulomb friction, and a first-order time stepping approach.

kCompliant

For simulating the system using compliant contact, Coulomb friction, and ordinary differential equations.

## Constructor & Destructor Documentation

 ~Rod2D ( )
inlineoverride
 Rod2D ( SimulationType simulation_type, double dt )
explicit

Constructor for the 2D rod system using the piecewise DAE (differential algebraic equation) based approach, the time stepping approach, or the compliant ordinary differential equation based approach.

Parameters
 dt The integration step size. This step size cannot be reset after construction.
Exceptions
 std::logic_error if dt is not positive and simulation_type is kTimeStepping or dt is not zero and simulation_type is kPiecewiseDAE or kCompliant.

Here is the call graph for this function:

## Member Function Documentation

 Vector2< T > CalcCoincidentRodPointVelocity ( const Vector2< T > & p_WRo, const Vector2< T > & v_WRo, const T & w_WR, const Vector2< T > & p_WC )
static

Given a location p_WC of a point C in the World frame, define the point Rc on the rod that is coincident with C, and report Rc's World frame velocity v_WRc.

We're given p_WRo=(x,y) and V_WRo = (v_WRo,w_WR) = (xdot,ydot,thetadot).

Parameters
 p_WRo The center-of-mass of the rod, expressed in the world frame. v_WRo The translational velocity of the rod, expressed in the world frame. w_WR The angular velocity of the rod. p_WC The location of a point on the rod.
Returns
The translational velocity of p_WC, expressed in the world frame.

Here is the call graph for this function:

Here is the caller graph for this function:

 Vector3< T > CalcCompliantContactForces ( const systems::Context< T > & context ) const

Return net contact forces as a spatial force F_Ro_W=(fx,fy,τ) where translational force f_Ro_W=(fx,fy) is applied at the rod origin Ro, and torque t_R=τ is the moment due to the contact forces actually being applied elsewhere.

The returned spatial force may be the resultant of multiple active contact points. Only valid for simulation type kCompliant.

Here is the call graph for this function:

Here is the caller graph for this function:

 void CalcConstraintProblemData ( const systems::Context< T > & context, const std::vector< Vector2< T >> & points, const std::vector< T > & tangent_vels, multibody::constraint::ConstraintAccelProblemData< T > * data ) const

Initializes the contact data for the rod, given a set of contact points.

Aborts if data is null or if points.size() != tangent_vels.size().

Parameters
 points a vector of contact points, expressed in the world frame. tangent_vels a vector of tangent velocities at the contact points, measured along the positive x-axis. [out] data the rigid contact problem data.

Here is the call graph for this function:

Here is the caller graph for this function:

 T CalcEndpointDistance ( const systems::Context< T > & context ) const

The witness function for the signed distance between one endpoint of the rod (not already touching the half-space) and the half-space for the case when the rod is contacting the ground with a single point of contact.

The witness function will return positive values when the other rod endpoint is above the halfspace, negative values when the other rod endpoint is strictly within the halfspace, and zero when the other rod endpoint is "kissing" the halfspace.

Precondition
One endpoint of the rod is in contact with the ground, indicated by the mode variable being set appropriately. Assertion failure is triggered if this is not the case.

Here is the call graph for this function:

Here is the caller graph for this function:

 void CalcImpactProblemData ( const systems::Context< T > & context, const std::vector< Vector2< T >> & points, multibody::constraint::ConstraintVelProblemData< T > * data ) const

Initializes the impacting contact data for the rod, given a set of contact points.

Aborts if data is null.

Parameters
 points a vector of contact points, expressed in the world frame. [out] data the rigid impact problem data.

Here is the call graph for this function:

Here is the caller graph for this function:

 T CalcNormalAccelWithoutContactForces ( const systems::Context< T > & context ) const

The witness function that determines whether the rod should separate from the halfspace.

The witness function will return a negative value when the rod should not separate and a positive value when it should begin to separate from the halfspace.

Precondition
It is assumed that the signed distance between the point of contact and the halfspace will be approximately zero and that the vertical velocity at the point of contact will be approximately zero. Assertion failure is triggered if the rod is in a ballistic mode.

Here is the call graph for this function:

Here is the caller graph for this function:

 Vector2< T > CalcRodEndpoint ( const T & x, const T & y, int k, const T & ctheta, const T & stheta, double half_rod_len )
static

Utility method for determining the World frame location of one of three points on the rod whose origin is Ro.

Let r be the half-length of the rod. Define point P = Ro+k*r where k = { -1, 0, 1 }. This returns p_WP.

Parameters
 x The horizontal location of the rod center of mass (expressed in the world frame). y The vertical location of the rod center of mass (expressed in the world frame). k The rod endpoint (k=+1 indicates the rod "right" endpoint, k=-1 indicates the rod "left" endpoint, and k=0 indicates the rod origin; each of these are described in the primary class documentation. ctheta cos(theta), where θ is the orientation of the rod (as described in the primary class documentation). stheta sin(theta), where θ is the orientation of the rod (as described in the class documentation). half_rod_len Half the length of the rod.
Returns
p_WP, the designated point on the rod, expressed in the world frame.

Here is the caller graph for this function:

 T CalcSignedDistance ( const systems::Context< T > & context ) const

The witness function for signed distance between the rod and the half-space.

The witness function will return positive values when the rod is separated from the halfspace, negative values when the rod is interpenetrating the halfspace, and zero values when the rod is "kissing" the halfspace.

Here is the call graph for this function:

Here is the caller graph for this function:

 T CalcSlidingDot ( const systems::Context< T > & context ) const

Evaluates the witness function for sliding direction changes.

The witness function will bracket a zero crossing when the direction of sliding changes over the interval; for example, when the rod is sliding to the right, CalcSlidingDot() will return a positive value, which evolves into a negative value (first crossing zero), as the rod begins sliding to the left (assuming that the rod remains in contact with the halfspace over the interval).

Here is the call graph for this function:

Here is the caller graph for this function:

 T CalcStickingFrictionForceSlack ( const systems::Context< T > & context ) const

Evaluates the witness function for determining whether the rod in sticking frictional contact should transition to sliding contact.

When the rod is in sticking contact at the beginning of an interval, the witness function will return a non-negative value. If the witness function returns a negative value at the end of an interval, a transition from sticking to sliding has been indicated.

Here is the call graph for this function:

Here is the caller graph for this function:

 int DetermineNumWitnessFunctions ( const systems::Context< T > & context ) const

Gets the number of witness functions for the system active in the system for a given state (using context).

Here is the call graph for this function:

Here is the caller graph for this function:

 double get_cfm ( ) const
inline

Gets the constraint force mixing parameter (CFM, used for time stepping systems only).

Here is the caller graph for this function:

 double get_dissipation ( ) const
inline

Get compliant contact normal dissipation in 1/velocity (s/m).

Here is the caller graph for this function:

 double get_erp ( ) const
inline

Gets the error reduction parameter (ERP, used for time stepping systems only).

Here is the caller graph for this function:

 double get_gravitational_acceleration ( ) const
inline

Gets the acceleration (with respect to the positive y-axis) due to gravity (i.e., this number should generally be negative).

Here is the caller graph for this function:

 double get_integration_step_size ( ) const
inline

Gets the integration step size for the time stepping system.

Returns
0 if this is a DAE-based system.
 double get_mu_coulomb ( ) const
inline

Gets the coefficient of dynamic (sliding) Coulomb friction.

Here is the caller graph for this function:

 double get_mu_static ( ) const
inline

Get compliant contact static friction (stiction) coefficient μ_s.

Here is the caller graph for this function:

 double get_rod_half_length ( ) const
inline

Gets the half-length h of the rod.

Here is the caller graph for this function:

 double get_rod_mass ( ) const
inline

Gets the mass of the rod.

Here is the caller graph for this function:

 double get_rod_moment_of_inertia ( ) const
inline

Gets the rod moment of inertia.

Here is the caller graph for this function:

 SimulationType get_simulation_type ( ) const
inline

Gets the model and simulation type for this system.

Here is the caller graph for this function:

 double get_stiction_speed_tolerance ( ) const
inline

Get the stiction speed tolerance (m/s).

Here is the caller graph for this function:

 double get_stiffness ( ) const
inline

Get compliant contact normal stiffness in N/m.

Here is the caller graph for this function:

 void GetContactPoints ( const systems::Context< T > & context, std::vector< Vector2< T >> * points ) const

Gets the point(s) of contact for the 2D rod.

context The context storing the current configuration and velocity of the rod. points Contains the contact points (those rod endpoints touching or lying within the ground halfspace) on return. This function aborts if points is null or points is non-empty.

Here is the call graph for this function:

Here is the caller graph for this function:

 void GetContactPointsTangentVelocities ( const systems::Context< T > & context, const std::vector< Vector2< T >> & points, std::vector< T > * vels ) const

Gets the tangent velocities for all contact points.

context The context storing the current configuration and velocity of the rod. points The set of context points. vels Contains the velocities (measured along the x-axis) on return. This function aborts if vels is null. vels will be resized appropriately (to the same number of elements as points) on return.

Here is the call graph for this function:

Here is the caller graph for this function:

 Matrix2< T > GetNonSlidingContactFrameToWorldTransform ( ) const

Gets the rotation matrix that transforms velocities from a non-sliding contact frame to the global frame.

Note: all such non-sliding frames are identical for this example.

Returns
a 2x2 orthogonal matrix with first column set to the contact normal, which is +y ([0 1]) and second column set to the contact tangent +x ([1 0]). Both directions are expressed in the global frame.

Here is the caller graph for this function:

 Vector3 GetRodConfig ( const systems::Context< T > & context ) const
inline

Gets the generalized position of the rod, given a Context.

The first two components represent the location of the rod's center-of-mass, expressed in the global frame. The third component represents the orientation of the rod, measured counter-clockwise with respect to the x-axis.

Here is the caller graph for this function:

 Vector3 GetRodVelocity ( const systems::Context< T > & context ) const
inline

Gets the generalized velocity of the rod, given a Context.

The first two components represent the translational velocities of the center-of-mass. The third component represents the angular velocity of the rod.

Here is the caller graph for this function:

 Matrix2< T > GetSlidingContactFrameToWorldTransform ( const T & xaxis_velocity ) const

Gets the rotation matrix that transforms velocities from a sliding contact frame to the global frame.

Parameters
 xaxis_velocity The velocity of the rod at the point of contact, projected along the +x-axis.
Returns
a 2x2 orthogonal matrix with first column set to the contact normal, which is +y ([0 1]) and second column set to the direction of sliding motion, ±x (±[1 0]). Both directions are expressed in the global frame.
Note
Aborts if xaxis_velocity is zero.

Here is the caller graph for this function:

 void HandleImpact ( const systems::Context< T > & context, systems::State< T > * new_state ) const

Models impact using an inelastic impact model with friction.

new_state is set to the output of the impact model on return.

Here is the call graph for this function:

Here is the caller graph for this function:

 bool IsImpacting ( const systems::Context< T > & context ) const

Checks whether the system is in an impacting state, meaning that the relative velocity along the contact normal between the rod and the halfspace is such that the rod will begin interpenetrating the halfspace at any time Δt in the future (i.e., Δt > 0).

If the context does not correspond to a configuration where the rod and halfspace are contacting, this method returns false.

Here is the call graph for this function:

Here is the caller graph for this function:

 const systems::OutputPort& pose_output ( ) const
inline

Returns the 3D pose of this rod.

Here is the caller graph for this function:

 void set_cfm ( double cfm )
inline

Sets the constraint force mixing parameter (CFM, used for time stepping systems only).

The default CFM value is 1e-8.

Parameters
 cfm a floating point value in the range [0, infinity].
Exceptions
 std::logic_error if contact is modeled as compliant or if cfm is set to a negative value.

Here is the caller graph for this function:

 void set_dissipation ( double dissipation )
inline

Set compliant contact normal dissipation in 1/velocity (s/m, >= 0).

This has no effect if the rod model is not compliant.

 void set_erp ( double erp )
inline

Sets the error reduction parameter (ERP, used for time stepping systems only).

The default ERP value is 0.8.

Parameters
 erp a floating point value in the range [0, 1].
Exceptions
 std::logic_error if this is not a time stepping system or if erp is set to a negative value.

Here is the caller graph for this function:

 void set_gravitational_acceleration ( double g )
inline

Sets the acceleration (with respect to the positive y-axis) due to gravity (i.e., this number should generally be negative).

 void set_mu_coulomb ( double mu )
inline

Sets the coefficient of dynamic (sliding) Coulomb friction.

Here is the caller graph for this function:

 void set_mu_static ( double mu_static )
inline

Set contact stiction coefficient (>= mu_coulomb).

This has no effect if the rod model is time stepping.

 void set_rod_half_length ( double half_length )
inline

Sets the half-length h of the rod.

 void set_rod_mass ( double mass )
inline

Sets the mass of the rod.

 void set_rod_moment_of_inertia ( double J )
inline

Sets the rod moment of inertia.

 void set_stiction_speed_tolerance ( double v_stick_tol )
inline

Set the stiction speed tolerance (m/s).

This is the maximum slip speed that we are willing to consider as sticking. For a given normal force N this is the speed at which the friction force will be largest, at μ_s*N where μ_s is the static coefficient of friction. This has no effect if the rod model is not compliant.

 void set_stiffness ( double stiffness )
inline

Set compliant contact normal stiffness in N/m (>= 0).

This has no effect if the rod model is not compliant.

## Friends And Related Function Documentation

 friend class Rod2DDAETest
friend
 friend class Rod2DDAETest_RigidContactProblemDataBallistic_Test
friend

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