12 #include <Ravelin/Vector3d.h>
13 #include <Ravelin/SForced.h>
14 #include <Ravelin/DynamicBodyd.h>
15 #include <boost/shared_ptr.hpp>
16 #include <Moby/Constants.h>
17 #include <Moby/Types.h>
18 #include <Moby/ContactParameters.h>
20 namespace osg {
class Node; }
24 class CollisionGeometry;
30 enum UnilateralConstraintType { eNone, eContact, eLimit };
31 enum UnilateralConstraintClass { ePositive, eZero, eNegative };
32 enum Compliance { eRigid, eCompliant};
35 static void determine_connected_constraints(
const std::vector<UnilateralConstraint>& constraints,
const std::vector<JointPtr>& implicit_joints, std::list<std::pair<std::list<UnilateralConstraint*>, std::list<boost::shared_ptr<Ravelin::SingleBodyd> > > >& groups, std::list<std::vector<boost::shared_ptr<Ravelin::DynamicBodyd> > >& remaining_islands);
36 static void remove_inactive_groups(std::list<std::pair<std::list<UnilateralConstraint*>, std::list<boost::shared_ptr<Ravelin::SingleBodyd> > > >& groups);
38 double calc_contact_vel(
const Ravelin::Vector3d& v)
const;
47 boost::shared_ptr<const Ravelin::Pose3d> get_pose()
const {
return GLOBAL; }
51 template <
class OutputIterator>
52 OutputIterator get_super_bodies(OutputIterator begin)
const;
64 double contact_stiffness;
67 double contact_damping;
70 double limit_stiffness;
136 void write_vrml(
const std::string& filename,
double sphere_radius = 0.1,
double normal_length = 1.0)
const;
142 bool operator()(
const std::pair<double, double>& a,
const std::pair<double, double>& b)
const
144 return (a.first < b.first - NEAR_ZERO && a.second < b.second - NEAR_ZERO);
149 boost::shared_ptr<Ravelin::Pose3d> _contact_frame;
150 static Ravelin::MatrixNd JJ, J, Jx, Jy, J1, J2, dJ1, dJ2, workM1, workM2;
151 static Ravelin::VectorNd v, workv, workv2;
153 void compute_cross_contact_contact_constraint_data(
const UnilateralConstraint& e, Ravelin::MatrixNd& M)
const;
154 void compute_cross_contact_contact_constraint_data(
const UnilateralConstraint& e, Ravelin::MatrixNd& M, boost::shared_ptr<Ravelin::DynamicBodyd> su)
const;
155 void compute_cross_contact_contact_constraint_data(
const UnilateralConstraint& e, Ravelin::MatrixNd& M, boost::shared_ptr<Ravelin::DynamicBodyd> su,
const Ravelin::MatrixNd& J)
const;
156 void compute_cross_contact_limit_constraint_data(
const UnilateralConstraint& e, Ravelin::MatrixNd& M)
const;
157 void compute_cross_limit_contact_constraint_data(
const UnilateralConstraint& e, Ravelin::MatrixNd& M)
const;
158 void compute_cross_limit_limit_constraint_data(
const UnilateralConstraint& e, Ravelin::MatrixNd& M)
const;
160 unsigned get_super_bodies(boost::shared_ptr<Ravelin::DynamicBodyd>& sb1, boost::shared_ptr<Ravelin::DynamicBodyd>& sb2)
const;
162 template <
class B
idirectionalIterator>
163 static void insertion_sort(BidirectionalIterator begin, BidirectionalIterator end);
166 std::ostream& operator<<(std::ostream& out,
const UnilateralConstraint& e);
168 #include "UnilateralConstraint.inl"
bool limit_upper
Whether the upper/lower limit is reached (for limit constraints)
Definition: UnilateralConstraint.h:85
void compute_constraint_data(Ravelin::MatrixNd &M, Ravelin::VectorNd &q) const
Computes the constraint data.
Definition: UnilateralConstraint.cpp:109
Ravelin::Vector3d contact_tan1
The first tangent direction to the contact normal.
Definition: UnilateralConstraint.h:97
double contact_epsilon
The coefficient of restitution (for contact constraints)
Definition: UnilateralConstraint.h:126
osg::Node * to_visualization_data() const
Makes a contact visualizable.
Definition: UnilateralConstraint.cpp:883
double contact_penalty_Kv
Penalty Method Interpenetration Speed.
Definition: UnilateralConstraint.h:123
Ravelin::Vector3d contact_normal
The vector pointing outward from the contact on the first body, in world coordinates (for contact con...
Definition: UnilateralConstraint.h:94
Ravelin::Vector3d contact_tan2
The second tangent direction to the contact normal.
Definition: UnilateralConstraint.h:100
UnilateralConstraint()
Creates an empty constraint.
Definition: UnilateralConstraint.cpp:49
double contact_penalty_Kp
Penalty Method Depth Penalty.
Definition: UnilateralConstraint.h:120
CollisionGeometryPtr contact_geom1
The collision geometries involved (for contact constraints)
Definition: UnilateralConstraint.h:111
double limit_impulse
Limit impulse magnitude (for limit constraints)
Definition: UnilateralConstraint.h:88
void determine_contact_tangents()
Determines the set of contact tangents.
Definition: UnilateralConstraint.cpp:1396
void compute_cross_constraint_data(const UnilateralConstraint &e, Ravelin::MatrixNd &M) const
Updates the constraint data.
Definition: UnilateralConstraint.cpp:296
boost::shared_ptr< CollisionGeometry > CollisionGeometryPtr
Collision geometry smart pointer.
Definition: Types.h:77
static void remove_inactive_groups(std::list< std::pair< std::list< UnilateralConstraint * >, std::list< boost::shared_ptr< Ravelin::SingleBodyd > > > > &groups)
Removes groups of contacts that contain no active contacts.
Definition: UnilateralConstraint.cpp:1206
double calc_constraint_tol() const
Computes the constraint tolerance.
Definition: UnilateralConstraint.cpp:1462
double limit_epsilon
The coefficient of restitution for this limit.
Definition: UnilateralConstraint.h:79
double tol
Tolerance for the constraint (users never need to modify this)
Definition: UnilateralConstraint.h:134
boost::shared_ptr< Joint > JointPtr
Reduced-coordinate articulated body joint smart pointer.
Definition: Types.h:74
void write_vrml(const std::string &filename, double sphere_radius=0.1, double normal_length=1.0) const
Writes an constraint to the specified filename in VRML format for visualization.
Definition: UnilateralConstraint.cpp:1240
Ravelin::Vector3d Point3d
Typedef to distinguish between a 3D vector and a point.
Definition: Types.h:47
double contact_mu_coulomb
The coefficient of Coulomb friction (for contact constraints)
Definition: UnilateralConstraint.h:114
void set_contact_parameters(const ContactParameters &cparams)
Sets the contact parameters for this constraint.
Definition: UnilateralConstraint.cpp:638
static void determine_connected_constraints(const std::vector< UnilateralConstraint > &constraints, const std::vector< JointPtr > &implicit_joints, std::list< std::pair< std::list< UnilateralConstraint * >, std::list< boost::shared_ptr< Ravelin::SingleBodyd > > > > &groups, std::list< std::vector< boost::shared_ptr< Ravelin::DynamicBodyd > > > &remaining_islands)
Given a vector of constraints, determines all of the sets of connected constraints.
Definition: UnilateralConstraint.cpp:949
double contact_mu_viscous
The coefficient of viscous friction (for contact constraints)
Definition: UnilateralConstraint.h:117
double signed_violation
Signed violation for this constraint.
Definition: UnilateralConstraint.h:76
unsigned limit_dof
The DOF at which the limit is reached (for limit constraints)
Definition: UnilateralConstraint.h:82
Container class for describing a unilateral constraint in the simulation.
Definition: UnilateralConstraint.h:27
unsigned contact_NK
The number of friction directions >= 4 (for contact constraints)
Definition: UnilateralConstraint.h:129
Ravelin::SMomentumd contact_impulse
Impulse that has been applied (for contact constraints)
Definition: UnilateralConstraint.h:108
UnilateralConstraintClass determine_constraint_class() const
Determines the type of constraint.
Definition: UnilateralConstraint.cpp:1442
Point3d contact_point
The point contact (for contact constraints)
Definition: UnilateralConstraint.h:91
UnilateralConstraintType constraint_type
The type of constraint.
Definition: UnilateralConstraint.h:55
JointPtr limit_joint
The joint at which the limit is reached (for limit constraints)
Definition: UnilateralConstraint.h:61
Compliance compliance
Compliance of the constraint.
Definition: UnilateralConstraint.h:58
double calc_constraint_vel() const
Computes the velocity of this constraint.
Definition: UnilateralConstraint.cpp:704