BulletJoint.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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: 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(unsigned int _index,
70  const gazebo::math::Vector3 &_anchor);
71 
72  // Documentation inherited
73  public: virtual void SetDamping(unsigned int _index, double _damping);
74 
75  // Documentation inherited.
76  public: virtual bool SetPosition(unsigned int _index, double _position);
77 
78  // Documentation inherited.
79  public: virtual void SetStiffness(unsigned int _index,
80  const double _stiffness);
81 
82  // Documentation inherited.
83  public: virtual void SetStiffnessDamping(unsigned int _index,
84  double _stiffness, double _damping, double _reference = 0);
85 
87  public: virtual math::Vector3 GetAnchor(unsigned int _index) const;
88 
91  public: virtual math::Vector3 GetLinkForce(unsigned int _index) const;
92 
95  public: virtual math::Vector3 GetLinkTorque(unsigned int _index) const;
96 
97  // Documentation inherited.
98  public: virtual bool SetParam(const std::string &_key,
99  unsigned int _index,
100  const boost::any &_value);
101 
102  // Documentation inherited.
103  public: virtual double GetParam(const std::string &_key,
104  unsigned int _index);
105 
106  // Documentation inherited.
107  public: virtual math::Angle GetHighStop(unsigned int _index);
108 
109  // Documentation inherited.
110  public: virtual math::Angle GetLowStop(unsigned int _index);
111 
112  // Documentation inherited.
113  public: virtual void SetProvideFeedback(bool _enable);
114 
115  // Documentation inherited.
116  public: virtual void CacheForceTorque();
117 
118  // Documentation inherited.
119  public: virtual JointWrench GetForceTorque(unsigned int _index);
120 
121  // Documentation inherited.
122  public: virtual void SetForce(unsigned int _index, double _force);
123 
124  // Documentation inherited.
125  public: virtual double GetForce(unsigned int _index);
126 
127  // Documentation inherited.
128  public: virtual void Init();
129 
130  // Documentation inherited.
131  public: virtual void ApplyStiffnessDamping();
132 
143  protected: virtual void SetForceImpl(unsigned int _index,
144  double _force) = 0;
145 
148  protected: void SetupJointFeedback();
149 
153  private: void SaveForce(unsigned int _index, double _force);
154 
156  protected: btTypedConstraint *constraint;
157 
159  protected: btDynamicsWorld *bulletWorld;
160 
162  private: btJointFeedback *feedback;
163 
166  private: bool stiffnessDampingInitialized;
167 
173  private: double forceApplied[MAX_JOINT_AXIS];
174 
177  private: common::Time forceAppliedTime;
178  };
180  }
181 }
182 #endif
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
btTypedConstraint * constraint
Pointer to a contraint object in Bullet.
Definition: BulletJoint.hh:156
btDynamicsWorld * bulletWorld
Pointer to Bullet's btDynamicsWorld.
Definition: BulletJoint.hh:159
#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:39
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
An angle and related functions.
Definition: Angle.hh:53
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