Link.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: Link class 00018 * Author: Nate Koenig 00019 */ 00020 00021 #ifndef LINK_HH 00022 #define LINK_HH 00023 00024 #include <map> 00025 #include <vector> 00026 00027 #include "common/Event.hh" 00028 #include "common/CommonTypes.hh" 00029 00030 #include "physics/Entity.hh" 00031 #include "physics/Inertial.hh" 00032 #include "physics/Joint.hh" 00033 00034 namespace gazebo 00035 { 00036 namespace physics 00037 { 00038 class Model; 00039 class Collision; 00040 00043 00045 class Link : public Entity 00046 { 00048 public: Link(EntityPtr parent); 00049 00051 public: virtual ~Link(); 00052 00055 public: virtual void Load( sdf::ElementPtr &_sdf ); 00056 00058 public: virtual void Init(); 00059 00061 public: void Fini(); 00062 00063 public: void Reset(); 00064 00066 public: virtual void UpdateParameters( sdf::ElementPtr &_sdf ); 00067 00069 public: virtual void Update(); 00070 00072 public: virtual void SetEnabled(bool enable) const = 0; 00073 00075 public: virtual bool GetEnabled() const = 0; 00076 00079 public: virtual bool SetSelected( bool s ); 00080 00082 public: virtual void SetGravityMode(bool mode) = 0; 00083 00085 public: virtual bool GetGravityMode() = 0; 00086 00087 00089 public: virtual void SetSelfCollide(bool collide) = 0; 00090 00092 public: void SetCollideMode( const std::string &m ); 00093 00096 public: bool GetSelfCollide(); 00097 00099 public: void SetLaserRetro(float retro); 00100 00102 public: virtual void SetLinearVel(const math::Vector3 &vel) = 0; 00103 00105 public: virtual void SetAngularVel(const math::Vector3 &vel) = 0; 00106 00108 public: void SetLinearAccel(const math::Vector3 &accel); 00109 00111 public: void SetAngularAccel(const math::Vector3 &accel); 00112 00114 public: virtual void SetForce(const math::Vector3 &_force) = 0; 00115 00117 public: virtual void SetTorque(const math::Vector3 &_force) = 0; 00118 00120 public: virtual void AddForce(const math::Vector3 &_force) = 0; 00121 00124 public: virtual void AddRelativeForce(const math::Vector3 &_force) = 0; 00125 00128 public: virtual void AddForceAtRelativePosition( 00129 const math::Vector3 &_force, 00130 const math::Vector3 &_relpos) = 0; 00131 00133 public: virtual void AddTorque(const math::Vector3 &_torque) = 0; 00134 00137 public: virtual void AddRelativeTorque(const math::Vector3 &_torque) = 0; 00138 00140 public: math::Vector3 GetRelativeLinearVel() const; 00141 00143 public: math::Vector3 GetRelativeAngularVel() const; 00144 00146 public: math::Vector3 GetRelativeLinearAccel() const; 00147 00149 public: math::Vector3 GetWorldLinearAccel() const; 00150 00152 public: math::Vector3 GetRelativeAngularAccel() const; 00153 00155 public: math::Vector3 GetWorldAngularAccel() const; 00156 00158 public: math::Vector3 GetRelativeForce() const; 00159 00161 public: virtual math::Vector3 GetWorldForce() const = 0; 00162 00164 public: math::Vector3 GetRelativeTorque() const; 00165 00167 public: virtual math::Vector3 GetWorldTorque() const = 0; 00168 00170 public: ModelPtr GetModel() const; 00171 00173 public: InertialPtr GetInertial() const { return this->inertial; } 00174 00176 public: void SetInertial(const InertialPtr &_inertial); 00177 00178 public: virtual void UpdateMass() {} 00179 00182 private: void LoadCollision( sdf::ElementPtr &_sdf ); 00183 00186 public: CollisionPtr GetCollisionById(unsigned int _id) const; 00187 00189 public: CollisionPtr GetCollision(const std::string &name); 00190 00192 public: virtual math::Box GetBoundingBox() const; 00193 00195 public: virtual void SetLinearDamping(double damping) = 0; 00196 00198 public: virtual void SetAngularDamping(double damping) = 0; 00199 00201 public: virtual void SetKinematic(const bool &) {} 00202 00204 public: virtual bool GetKinematic() const {return false;} 00205 00207 public: unsigned int GetSensorCount() const; 00208 00210 public: std::string GetSensorName(unsigned int _i) const; 00211 00213 public: template<typename T> 00214 event::ConnectionPtr ConnectEnabled( T subscriber ) 00215 { return enabledSignal.Connect(subscriber); } 00216 00217 public: void DisconnectEnabled( event::ConnectionPtr &c ) 00218 { enabledSignal.Disconnect(c); } 00219 00222 public: void FillLinkMsg( msgs::Link &_msg ); 00223 00226 public: void ProcessMsg(const msgs::Link &_msg); 00227 00229 public: void AddChildJoint(JointPtr joint); 00230 00232 public: void AddParentJoint(JointPtr joint); 00233 00235 public: void AttachStaticModel(ModelPtr &_model, 00236 const math::Pose &_offset); 00237 00239 public: void DetachStaticModel(const std::string &_modelName); 00240 00241 public: virtual void OnPoseChange(); 00242 00243 protected: bool isStatic; 00244 00245 protected: InertialPtr inertial; 00246 00247 protected: std::vector<std::string> cgVisuals; 00248 protected: std::vector<std::string> visuals; 00249 00250 protected: math::Vector3 linearAccel; 00251 protected: math::Vector3 angularAccel; 00252 00253 private: event::EventT<void (bool)> enabledSignal; 00254 private: event::ConnectionPtr showPhysicsConnection; 00255 00257 private: bool enabled; 00258 00259 protected: math::Pose newPose; 00260 00261 private: std::vector<std::string> sensors; 00262 private: std::vector<JointPtr> parentJoints; 00263 private: std::vector<JointPtr> childJoints; 00264 00265 private: std::vector<ModelPtr> attachedModels; 00266 protected: std::vector<math::Pose> attachedModelsOffset; 00267 }; 00269 } 00270 } 00271 #endif

1.7.5.1