Go to the documentation of this file.00001 #include "../include/contact_model.h"
00002 #include "../include/debug.h"
00003 #include "../include/target_object.h"
00004 #include <iostream>
00005 #include <cstdlib>
00006 #include <string>
00007
00008 namespace ICR
00009 {
00010
00011
00012 PointContactModel::PointContactModel() : id_(0),model_type_(Single_Point) {}
00013
00014 PointContactModel::PointContactModel(FingerParameters const& param) : id_(0),model_type_(Single_Point)
00015 {
00016 if (param.getContactType()==Frictionless)
00017 lim_surf_=LimitSurface(param.getForceMagnitude());
00018 else if (param.getContactType()==Frictional)
00019 lim_surf_=LimitSurface(param.getForceMagnitude(),param.getDisc(),param.getMu0());
00020 else if (param.getContactType()==Soft_Finger)
00021 lim_surf_=LimitSurface(param.getForceMagnitude(),param.getDisc(),param.getMu0(),param.getMuT());
00022 else
00023 {
00024 std::cout<<"Error in ContactModel: Invalid contact type. exiting..."<<std::endl;
00025 exit(1);
00026 }
00027 }
00028
00029 PointContactModel::PointContactModel(FingerParameters param,uint id) : id_(id),model_type_(Single_Point)
00030 {
00031 if (param.getContactType()==Frictionless)
00032 lim_surf_=LimitSurface(param.getForceMagnitude());
00033 else if (param.getContactType()==Frictional)
00034 lim_surf_=LimitSurface(param.getForceMagnitude(),param.getDisc(),param.getMu0());
00035 else if (param.getContactType()==Soft_Finger)
00036 lim_surf_=LimitSurface(param.getForceMagnitude(),param.getDisc(),param.getMu0(),param.getMuT());
00037 else
00038 {
00039 std::cout<<"Error in ContactModel: Invalid contact type. exiting..."<<std::endl;
00040 exit(1);
00041 }
00042 }
00043
00044 PointContactModel::PointContactModel(PointContactModel const& src) : id_(src.id_), lim_surf_(src.lim_surf_), model_type_(src.model_type_) {}
00045
00046 PointContactModel& PointContactModel::operator=(PointContactModel const& src)
00047 {
00048 if (this !=&src)
00049 {
00050 id_=src.id_;
00051 lim_surf_=src.lim_surf_;
00052 model_type_=src.model_type_;
00053 }
00054 return *this;
00055 }
00056
00057 bool PointContactModel::operator==(PointContactModel const& other)const
00058 {
00059 if((lim_surf_==other.lim_surf_) & (model_type_==other.model_type_))
00060 return true;
00061 else
00062 return false;
00063 }
00064
00065 PointContactModel::~PointContactModel() {}
00066
00067 LimitSurface const* PointContactModel::getLimitSurface()const{return &lim_surf_;}
00068
00069 ModelType PointContactModel::getModelType()const {return model_type_;}
00070
00071 uint PointContactModel::getId()const{return id_;}
00072
00073 void PointContactModel::setId(uint const id){id_=id;}
00074
00075 std::ostream& operator<<(std::ostream& stream, PointContactModel const& pc_model)
00076 {
00077 std::string model_type;
00078
00079 if (pc_model.model_type_==Single_Point) model_type="Single Point";
00080 else if (pc_model.model_type_==Multi_Point) model_type="Multi Point";
00081 else if (pc_model.model_type_==Undefined_MT) model_type="Undefined";
00082 else model_type="Warning in ContactModel: Invalid model type!";
00083
00084 stream <<'\n'<<"CONTACT MODEL: "<<'\n'
00085 <<"Id: " << pc_model.id_ <<'\n'
00086 <<"Model type: "<<model_type<<'\n'<<'\n';
00087
00088 return stream;
00089 }
00090
00091
00092 MultiPointContactModel::MultiPointContactModel(){model_type_=Multi_Point;}
00093
00094 MultiPointContactModel::MultiPointContactModel(FingerParameters const& param) : PointContactModel(param), inclusion_rule_(*param.getInclusionRule())
00095 {
00096 assert(param.getModelType()==Multi_Point);
00097 model_type_=Multi_Point;
00098 }
00099
00100 MultiPointContactModel::MultiPointContactModel(FingerParameters const& param,uint id) : PointContactModel(param,id), inclusion_rule_(*param.getInclusionRule())
00101 {
00102 assert(param.getModelType()==Multi_Point);
00103 model_type_=Multi_Point;
00104 }
00105
00106 bool MultiPointContactModel::operator==(MultiPointContactModel const& other)const
00107 {
00108 if((inclusion_rule_.rule_parameter_==other.inclusion_rule_.rule_parameter_) &
00109 (PointContactModel::operator==(other)) & (inclusion_rule_.rule_type_==other.inclusion_rule_.rule_type_ ))
00110 return true;
00111 else
00112 return false;
00113 }
00114
00115 MultiPointContactModel::MultiPointContactModel(MultiPointContactModel const& src) : PointContactModel(src), inclusion_rule_(src.inclusion_rule_) {}
00116
00117 MultiPointContactModel& MultiPointContactModel::operator=(MultiPointContactModel const& src)
00118 {
00119 if (this !=&src)
00120 {
00121 PointContactModel::operator=(src);
00122 inclusion_rule_=src.inclusion_rule_;
00123 }
00124 return *this;
00125 }
00126
00127 MultiPointContactModel::~MultiPointContactModel() {}
00128
00129 InclusionRule const* MultiPointContactModel::getInclusionRule()const{return &inclusion_rule_;}
00130
00131 void MultiPointContactModel::inclusionRuleSphere(uint center_pt_id,TargetObject const& obj,IndexList& included_points)const
00132 {
00133
00134 std::cout<<"Inclusion rule not implemented yet"<<std::endl;
00135
00136 std::cout<<"Center point id: "<<center_pt_id<<std::endl;
00137 TargetObject obj2=obj;
00138 IndexList list2=included_points;
00139 }
00140 void MultiPointContactModel::computeInclusion(uint center_pt_id,TargetObject const& obj,IndexList& included_points) const
00141 {
00142
00143 if (inclusion_rule_.rule_type_==Sphere)
00144 inclusionRuleSphere(center_pt_id,obj,included_points);
00145 else
00146 {
00147 std::cout<<"Invalid inclusion rule: exiting"<<std::endl;
00148 exit(1);
00149 }
00150 }
00151
00152
00153 }