Model.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 /* Desc: Base class for all models 00018 * Author: Nathan Koenig and Andrew Howard 00019 * Date: 8 May 2003 00020 */ 00021 00022 #ifndef MODEL_HH 00023 #define MODEL_HH 00024 00025 #include <string> 00026 00027 #include "common/CommonTypes.hh" 00028 #include "physics/PhysicsTypes.hh" 00029 00030 #include "physics/Entity.hh" 00031 00032 namespace boost 00033 { 00034 class recursive_mutex; 00035 } 00036 00037 namespace gazebo 00038 { 00039 namespace physics 00040 { 00043 00045 class Model : public Entity 00046 { 00049 public: Model(BasePtr parent); 00050 00052 public: virtual ~Model(); 00053 00056 public: void Load( sdf::ElementPtr &_sdf ); 00057 00059 public: virtual void Init(); 00060 00062 public: void Update(); 00063 00065 public: virtual void Fini(); 00066 00068 public: virtual void UpdateParameters( sdf::ElementPtr &_sdf ); 00069 00071 public: virtual const sdf::ElementPtr &GetSDF(); 00072 00075 public: virtual void RemoveChild(EntityPtr child); 00076 00078 public: void Reset(); 00079 00082 public: void SetLinearVel( const math::Vector3 &vel ); 00083 00086 public: void SetAngularVel( const math::Vector3 &vel ); 00087 00090 public: void SetLinearAccel( const math::Vector3 &vel ); 00091 00094 public: void SetAngularAccel( const math::Vector3 &vel ); 00095 00098 public: virtual math::Vector3 GetRelativeLinearVel() const; 00099 00102 public: virtual math::Vector3 GetWorldLinearVel() const; 00103 00106 public: virtual math::Vector3 GetRelativeAngularVel() const; 00107 00110 public: virtual math::Vector3 GetWorldAngularVel() const; 00111 00114 public: virtual math::Vector3 GetRelativeLinearAccel() const; 00115 00118 public: virtual math::Vector3 GetWorldLinearAccel() const; 00119 00122 public: virtual math::Vector3 GetRelativeAngularAccel() const; 00123 00126 public: virtual math::Vector3 GetWorldAngularAccel() const; 00127 00130 public: virtual math::Box GetBoundingBox() const; 00131 00134 public: unsigned int GetJointCount() const; 00135 00139 public: JointPtr GetJoint( unsigned int index ) const; 00140 00144 public: JointPtr GetJoint(const std::string &name); 00145 00148 public: LinkPtr GetLinkById(unsigned int _id) const; 00149 00152 public: LinkPtr GetLink(const std::string &name="canonical") const; 00153 00155 public: void SetGravityMode( const bool &v ); 00156 00159 public: void SetCollideMode( const std::string &m ); 00160 00163 public: void SetLaserRetro( const float &retro ); 00164 00167 public: void FillModelMsg(msgs::Model &_msg); 00168 00170 public: void ProcessMsg(const msgs::Model &_msg); 00171 00173 public: void SetJointPositions( 00174 const std::map<std::string, double> &_jointPositions); 00175 00176 public: void SetJointAnimation( 00177 const std::map<std::string, common::NumericAnimationPtr> anim, 00178 boost::function<void()> _onComplete); 00179 00181 public: void AttachStaticModel(ModelPtr &_model, math::Pose _offset); 00182 00183 public: void DetachStaticModel(const std::string &_model); 00184 00185 protected: virtual void OnPoseChange(); 00186 00187 private: void RotateBodyAndChildren(LinkPtr _body1, 00188 const math::Vector3 &_anchor, const math::Vector3 &_axis, 00189 double _dangle, bool _updateChildren); 00190 00191 private: void SlideBodyAndChildren(LinkPtr _body1, 00192 const math::Vector3 &_anchor, const math::Vector3 &_axis, 00193 double _dposition, bool _updateChildren); 00194 00195 private: void GetAllChildrenBodies(std::vector<LinkPtr> &_bodies, 00196 const LinkPtr &_body); 00197 00198 private: void GetAllParentBodies(std::vector<LinkPtr> &_bodies, 00199 const LinkPtr &_body, const LinkPtr &_origParentBody); 00200 00201 private: bool InBodies(const LinkPtr &_body, 00202 const std::vector<LinkPtr> &_bodies); 00203 00206 private: void LoadJoint( sdf::ElementPtr &_sdf ); 00207 00210 private: void LoadPlugin( sdf::ElementPtr &_sdf ); 00211 00212 private: LinkPtr canonicalLink; 00213 00214 private: Joint_V joints; 00215 00216 private: std::vector<ModelPluginPtr> plugins; 00217 00218 private: transport::PublisherPtr jointPub; 00219 private: std::map<std::string, common::NumericAnimationPtr> jointAnimations; 00220 private: boost::function<void()> onJointAnimationComplete; 00221 private: common::Time prevAnimationTime; 00222 00223 private: boost::recursive_mutex *updateMutex; 00224 00225 protected: std::vector<ModelPtr> attachedModels; 00226 protected: std::vector<math::Pose> attachedModelsOffset; 00227 }; 00229 } 00230 } 00231 #endif

1.7.5.1