BulletJoint.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /* Desc: The base Bullet joint class
18  * Author: Nate Koenig, Andrew Howard
19  * Date: 21 May 2003
20  */
21 
22 #ifndef _BULLETJOINT_HH_
23 #define _BULLETJOINT_HH_
24 
25 #include <boost/any.hpp>
26 #include <string>
27 
29 #include "gazebo/physics/Joint.hh"
30 #include "gazebo/util/system.hh"
31 
32 namespace gazebo
33 {
34  namespace physics
35  {
39 
41  class GZ_PHYSICS_VISIBLE BulletJoint : public Joint
42  {
44  public: explicit BulletJoint(BasePtr _parent);
45 
47  public: virtual ~BulletJoint();
48 
50  public: virtual void Load(sdf::ElementPtr _sdf) override;
51 
52  // Documentation inherited.
53  public: virtual void Fini() override;
54 
56  public: virtual void Reset() override;
57 
60  public: LinkPtr GetJointLink(unsigned int _index) const override;
61 
63  public: bool AreConnected(LinkPtr _one, LinkPtr _two) const override;
64 
66  public: virtual void Detach() override;
67 
69  public: virtual void SetAnchor(const unsigned int _index,
70  const ignition::math::Vector3d &_anchor)
71  override;
72 
73  // Documentation inherited
74  public: virtual void SetDamping(unsigned int _index, double _damping)
75  override;
76 
77  // Documentation inherited.
78  public: virtual bool SetPosition(
79  const unsigned int _index, const double _position,
80  const bool _preserveWorldVelocity = false) override;
81 
82  // Documentation inherited.
83  public: virtual void SetStiffness(unsigned int _index,
84  const double _stiffness) override;
85 
86  // Documentation inherited.
87  public: virtual void SetStiffnessDamping(unsigned int _index,
88  double _stiffness, double _damping, double _reference = 0) override;
89 
91  public: virtual ignition::math::Vector3d Anchor(
92  const unsigned int _index) const override;
93 
96  public: virtual ignition::math::Vector3d LinkForce(
97  const unsigned int _index) const override;
98 
101  public: virtual ignition::math::Vector3d LinkTorque(
102  const unsigned int _index) const override;
103 
104  // Documentation inherited.
105  public: virtual bool SetParam(const std::string &_key,
106  unsigned int _index,
107  const boost::any &_value) override;
108 
109  // Documentation inherited.
110  public: virtual double GetParam(const std::string &_key,
111  unsigned int _index) override;
112 
113  // Documentation inherited.
114  public: virtual void SetProvideFeedback(bool _enable) override;
115 
116  // Documentation inherited.
117  public: virtual void CacheForceTorque() override;
118 
119  // Documentation inherited.
120  public: virtual JointWrench GetForceTorque(unsigned int _index) override;
121 
122  // Documentation inherited.
123  public: virtual void SetForce(unsigned int _index, double _force)
124  override;
125 
126  // Documentation inherited.
127  public: virtual double GetForce(unsigned int _index) override;
128 
129  // Documentation inherited.
130  public: virtual void Init() override;
131 
132  // Documentation inherited.
133  public: virtual void ApplyStiffnessDamping() override;
134 
145  protected: virtual void SetForceImpl(unsigned int _index,
146  double _force) = 0;
147 
150  protected: void SetupJointFeedback();
151 
155  private: void SaveForce(unsigned int _index, double _force);
156 
158  protected: btTypedConstraint *constraint;
159 
161  protected: btDynamicsWorld *bulletWorld;
162 
164  private: btJointFeedback *feedback;
165 
168  private: bool stiffnessDampingInitialized;
169 
175  private: double forceApplied[MAX_JOINT_AXIS];
176 
179  private: common::Time forceAppliedTime;
180  };
182  }
183 }
184 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
Forward declarations for the common classes.
Definition: Animation.hh:26
btTypedConstraint * constraint
Pointer to a contraint object in Bullet.
Definition: BulletJoint.hh:158
btDynamicsWorld * bulletWorld
Pointer to Bullet&#39;s btDynamicsWorld.
Definition: BulletJoint.hh:161
#define MAX_JOINT_AXIS
maximum number of axis per joint anticipated.
Definition: Joint.hh:39
Base class for all joints.
Definition: Joint.hh:50
Wrench information from a joint.
Definition: JointWrench.hh:40
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Base class for all joints.
Definition: BulletJoint.hh:41
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44