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);
51 
52  // Documentation inherited.
53  public: virtual void Fini();
54 
56  public: virtual void Reset();
57 
60  public: LinkPtr GetJointLink(unsigned int _index) const;
61 
63  public: bool AreConnected(LinkPtr _one, LinkPtr _two) const;
64 
66  public: virtual void Detach();
67 
69  public: virtual void SetAnchor(const unsigned int _index,
70  const ignition::math::Vector3d &_anchor);
71 
72  // Documentation inherited
73  public: virtual void SetDamping(unsigned int _index, double _damping);
74 
75  // Documentation inherited.
76  public: virtual bool SetPosition(
77  const unsigned int _index, const double _position,
78  const bool _preserveWorldVelocity = false) override;
79 
80  // Documentation inherited.
81  public: virtual void SetStiffness(unsigned int _index,
82  const double _stiffness);
83 
84  // Documentation inherited.
85  public: virtual void SetStiffnessDamping(unsigned int _index,
86  double _stiffness, double _damping, double _reference = 0);
87 
89  public: virtual ignition::math::Vector3d Anchor(
90  const unsigned int _index) const;
91 
94  public: virtual ignition::math::Vector3d LinkForce(
95  const unsigned int _index) const;
96 
99  public: virtual ignition::math::Vector3d LinkTorque(
100  const unsigned int _index) const;
101 
102  // Documentation inherited.
103  public: virtual bool SetParam(const std::string &_key,
104  unsigned int _index,
105  const boost::any &_value);
106 
107  // Documentation inherited.
108  public: virtual double GetParam(const std::string &_key,
109  unsigned int _index);
110 
111  // Documentation inherited.
112  public: virtual void SetProvideFeedback(bool _enable);
113 
114  // Documentation inherited.
115  public: virtual void CacheForceTorque();
116 
117  // Documentation inherited.
118  public: virtual JointWrench GetForceTorque(unsigned int _index);
119 
120  // Documentation inherited.
121  public: virtual void SetForce(unsigned int _index, double _force);
122 
123  // Documentation inherited.
124  public: virtual double GetForce(unsigned int _index);
125 
126  // Documentation inherited.
127  public: virtual void Init();
128 
129  // Documentation inherited.
130  public: virtual void ApplyStiffnessDamping();
131 
142  protected: virtual void SetForceImpl(unsigned int _index,
143  double _force) = 0;
144 
147  protected: void SetupJointFeedback();
148 
152  private: void SaveForce(unsigned int _index, double _force);
153 
155  protected: btTypedConstraint *constraint;
156 
158  protected: btDynamicsWorld *bulletWorld;
159 
161  private: btJointFeedback *feedback;
162 
165  private: bool stiffnessDampingInitialized;
166 
172  private: double forceApplied[MAX_JOINT_AXIS];
173 
176  private: common::Time forceAppliedTime;
177  };
179  }
180 }
181 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
btTypedConstraint * constraint
Pointer to a contraint object in Bullet.
Definition: BulletJoint.hh:155
btDynamicsWorld * bulletWorld
Pointer to Bullet's btDynamicsWorld.
Definition: BulletJoint.hh:158
#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