00001
00002
00003
00004
00005
00006
00007 #ifndef _CONTACT_DATA_H
00008 #define _CONTACT_DATA_H
00009
00010 #include <Physsim/sorted_pair>
00011 #include <Physsim/Base.h>
00012
00013 namespace Physsim {
00014
00015 class RestingContactMethod;
00016 class CollisionMethod;
00017
00019
00024 class ContactData : public Base
00025 {
00026 public:
00027 ContactData();
00028 ContactData(BasePtr o1, BasePtr o2);
00029 virtual void load_from_xml(XMLTreeConstPtr node, std::map<std::string, BasePtr>& id_map);
00030 virtual void save_to_xml(XMLTreePtr node, std::list<BaseConstPtr>& shared_objects) const;
00031 virtual bool is_struct_identical(BaseConstPtr object) const;
00032 virtual void clone(BasePtr& cloned, bimap<BasePtr, BasePtr>* obj_map = NULL) const;
00033 virtual void load_state(BaseConstPtr object, bimap<BasePtr, BasePtr>* correspondence = NULL);
00034 virtual void save_state(BasePtr object, bimap<BasePtr, BasePtr>* correspondence = NULL) const;
00035
00037 void set_penalty_gains(Real kp, Real kv, Real ki) { assert(kp >= 0.0 && kv >= 0.0 && ki >= 0.0); _kp = kp; _kv = kv; _ki = ki; }
00038
00040 void set_static_friction_gains(Real kp_static, Real kv_static) { assert(kp_static >= 0.0 && kv_static >= 0.0); _kp_static = kp_static; _kv_static = kv_static; }
00041
00043 void set_restitution(Real restitution) { assert(restitution >= 0.0 && restitution <= 1.0); _restitution = restitution; }
00044
00046 void set_mu_coulomb(Real mu) { assert(mu >= 0.0); _mu_coulomb = mu; }
00047
00049 void set_mu_viscous(Real mu) { assert(mu >= 0.0); _mu_viscous = mu; }
00050
00052
00055 void set_num_samples(unsigned num_samples) { _num_samples = num_samples; }
00056
00058
00061 void set_static_friction_velocity_thresh(Real thresh) { assert(thresh >= 0.0); _fs_velocity_thresh = thresh; }
00062
00064 void set_resting_contact_method(boost::shared_ptr<RestingContactMethod> rcm) { _rcm = rcm; }
00065
00067 void set_collision_method(boost::shared_ptr<CollisionMethod> cm) { _cm = cm; }
00068
00070 Real get_kp() const { return _kp; }
00071
00073 Real get_kv() const { return _kv; }
00074
00076 Real get_ki() const { return _ki; }
00077
00079 Real get_kp_static() const { return _kp_static; }
00080
00082 Real get_kv_static() const { return _kv_static; }
00083
00085
00088 Real get_static_friction_velocity_thresh() const { return _fs_velocity_thresh; }
00089
00091 Real get_restitution() const { return _restitution; }
00092
00094 Real get_mu_coulomb() const { return _mu_coulomb; }
00095
00097 Real get_mu_viscous() const { return _mu_viscous; }
00098
00100
00103 unsigned get_num_samples() const { return _num_samples; }
00104
00106 boost::shared_ptr<RestingContactMethod> get_resting_contact_method() const { return _rcm; }
00107
00109 boost::shared_ptr<CollisionMethod> get_collision_method() const { return _cm; }
00110
00112 sorted_pair<BasePtr> objects;
00113
00115
00119 bool operator==(const ContactData& cd) const { return objects == cd.objects; }
00120
00122
00125 bool operator<(const ContactData& cd) const { return objects < cd.objects; }
00126
00127 private:
00129 Real _fs_velocity_thresh;
00130
00132 unsigned _num_samples;
00133
00135 Real _kp;
00136
00138 Real _kv;
00139
00141 Real _ki;
00142
00144 Real _kp_static;
00145
00147 Real _kv_static;
00148
00150 Real _restitution;
00151
00153 Real _mu_coulomb;
00154
00156 Real _mu_viscous;
00157
00159 boost::shared_ptr<RestingContactMethod> _rcm;
00160
00162 boost::shared_ptr<CollisionMethod> _cm;
00163 };
00164
00165 }
00166
00167 #endif
00168