00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _OBJECT_H_
00021 #define _OBJECT_H_
00022
00023 #include "mbsim/element.h"
00024
00025
00026 namespace MBSim {
00027
00028 class DynamicSystem;
00029 class Link;
00030
00041
00042 class Object : public Element {
00043 public:
00047 Object(const std::string &name);
00048
00052 virtual ~Object();
00053
00054
00055 virtual void updateT(double t) {};
00056 virtual void updateh(double t, int j=0) {};
00057 virtual void updateM(double t, int i=0) {};
00058 virtual void updatedhdz(double t);
00059 virtual void updatedq(double t, double dt) { qd = T * u * dt; }
00060 virtual void updatedu(double t, double dt) { ud[0] = slvLLFac(LLM[0], h[0] * dt + r[0]); }
00061 virtual void updateud(double t, int i=0) { ud[i] = slvLLFac(LLM[i], h[i] + r[i]); }
00062 virtual void updateqd(double t) { qd = T * u; }
00063 virtual void updatezd(double t) { updateqd(t); updateud(t); updatexd(t); }
00064 virtual void sethSize(int hSize_, int i=0);
00065 virtual int gethSize(int i=0) const { return hSize[i]; }
00066 virtual int getqSize() const { return qSize; }
00067 virtual int getuSize(int i=0) const { return uSize[i]; }
00068 virtual void calcqSize() {};
00069 virtual void calcuSize(int j) {};
00070
00071 virtual int getuInd(int i=0) { return uInd[i]; }
00072
00073 virtual void setqInd(int qInd_) { qInd = qInd_; }
00074 virtual void setuInd(int uInd_, int i=0) { uInd[i] = uInd_; }
00075
00076 virtual const fmatvec::Vec& getq() const { return q; };
00077 virtual const fmatvec::Vec& getu() const { return u; };
00078 virtual H5::GroupBase *getPlotGroup() { return plotGroup; }
00079 virtual PlotFeatureStatus getPlotFeature(PlotFeature fp) { return Element::getPlotFeature(fp); };
00080 virtual PlotFeatureStatus getPlotFeatureForChildren(PlotFeature fp) { return Element::getPlotFeatureForChildren(fp); };
00081 virtual void updateStateDependentVariables(double t) = 0;
00082 virtual void updateStateDerivativeDependentVariables(double t) {};
00083 virtual void updateJacobians(double t, int j=0) = 0;
00084 virtual void updatehInverseKinetics(double t, int i=0) {};
00085
00086
00087
00088 virtual void plot(double t, double dt = 1);
00089 virtual void closePlot();
00090 virtual std::string getType() const { return "Object"; }
00091
00092
00093
00094 virtual void updatedx(double t, double dt) {}
00095 virtual void updatexd(double t) {}
00096 virtual void calcxSize() { xSize = 0; }
00097 virtual const fmatvec::Vec& getx() const { return x; }
00098 virtual fmatvec::Vec& getx() { return x; }
00099 virtual void setxInd(int xInd_) { xInd = xInd_; };
00100 virtual int getxSize() const { return xSize; }
00101 virtual void updatexRef(const fmatvec::Vec& ref);
00102 virtual void updatexdRef(const fmatvec::Vec& ref);
00103
00108 virtual void updateqRef(const fmatvec::Vec& qRef);
00109
00114 virtual void updateqdRef(const fmatvec::Vec& qdRef);
00115
00120 virtual void updateuRef(const fmatvec::Vec& uRef);
00121
00126 virtual void updateuallRef(const fmatvec::Vec& uallRef);
00127
00132 virtual void updateudRef(const fmatvec::Vec& udRef, int i=0);
00133
00138 virtual void updateudallRef(const fmatvec::Vec& udallRef, int i=0);
00139
00145 virtual void updatehRef(const fmatvec::Vec& hRef, int i=0);
00146
00152 virtual void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0);
00153
00159 virtual void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0);
00160
00166 virtual void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0);
00167
00172 virtual void updaterRef(const fmatvec::Vec& ref, int i=0);
00173
00178 virtual void updateTRef(const fmatvec::Mat &ref);
00179
00185 virtual void updateMRef(const fmatvec::SymMat &ref, int i=0);
00186
00192 virtual void updateLLMRef(const fmatvec::SymMat &ref, int i=0);
00193
00197 virtual void init(InitStage stage);
00198
00202 virtual void initz();
00203
00207 virtual void writez(H5::GroupBase *group);
00208
00212 virtual void readz0(H5::GroupBase *group);
00213
00217 virtual void facLLM(int i=0) { LLM[i] = facLL(M[i]); }
00218
00223 virtual void calcSize(int j) {}
00224
00228 virtual double computeKineticEnergy() { return 0.5*u.T()*M[0]*u; }
00229
00233 virtual double computePotentialEnergy() { return 0; }
00234
00238 virtual void setUpInverseKinetics() {}
00239
00240
00241
00242 void setqSize(int qSize_) { qSize = qSize_; }
00243 void setuSize(int uSize_, int i=0) { uSize[i] = uSize_; }
00244 int getzSize() const { return qSize + uSize[0]; }
00245
00246 virtual void sethInd(int hInd_, int i=0);
00247 int gethInd(int i=0) { return hInd[i]; }
00248
00249 const fmatvec::Vec& geth(int i=0) const { return h[i]; };
00250 fmatvec::Vec& geth(int i=0) { return h[i]; };
00251 const fmatvec::Vec& getr(int i=0) const { return r[i]; };
00252 fmatvec::Vec& getr(int i=0) { return r[i]; };
00253 const fmatvec::SymMat& getM(int i=0) const { return M[i]; };
00254 fmatvec::SymMat& getM(int i=0) { return M[i]; };
00255 const fmatvec::Mat& getT() const { return T; };
00256 fmatvec::Mat& getT() { return T; };
00257 const fmatvec::SymMat& getLLM(int i=0) const { return LLM[i]; };
00258 fmatvec::SymMat& getLLM(int i=0) { return LLM[i]; };
00259
00260 fmatvec::Vec& getq() { return q; };
00261 fmatvec::Vec& getu() { return u; };
00262
00263 const fmatvec::Vec& getq0() const { return q0; };
00264 const fmatvec::Vec& getu0() const { return u0; };
00265 fmatvec::Vec& getq0() { return q0; };
00266 fmatvec::Vec& getu0() { return u0; };
00267
00268 const fmatvec::Vec& getqd() const { return qd; };
00269 const fmatvec::Vec& getud(int i=0) const { return ud[i]; };
00270 fmatvec::Vec& getqd() { return qd; };
00271 fmatvec::Vec& getud(int i=0) { return ud[i]; };
00272
00273 void setq(const fmatvec::Vec &q_) { q = q_; }
00274 void setu(const fmatvec::Vec &u_) { u = u_; }
00275
00276
00277
00278 virtual void initializeUsingXML(xercesc::DOMElement *element);
00279 virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00280
00281 protected:
00285 int qSize;
00286
00290 int uSize[2];
00291
00295 int hSize[2];
00296
00300 int qInd, uInd[2], hInd[2];
00301
00305 int xSize, xInd;
00306
00310 fmatvec::Vec q, u, uall, x;
00311
00315 fmatvec::Vec q0, u0, x0;
00316
00320 fmatvec::Vec qd, ud[2], udall[2], xd;
00321
00325 fmatvec::Vec h[2], r[2];
00326
00327 fmatvec::Mat W[2], V[2];
00328
00332 fmatvec::Mat dhdq;
00333 fmatvec::SqrMat dhdu;
00334 fmatvec::Vec dhdt;
00335
00339 fmatvec::Mat T;
00340
00344 fmatvec::SymMat M[2];
00345
00349 fmatvec::SymMat LLM[2];
00350 };
00351
00352 }
00353
00354 #endif
00355