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 
42  {
44  public: BulletJoint(BasePtr _parent);
45 
47  public: virtual ~BulletJoint();
48 
50  public: virtual void Load(sdf::ElementPtr _sdf);
51 
53  public: virtual void Reset();
54 
57  public: LinkPtr GetJointLink(unsigned int _index) const;
58 
60  public: bool AreConnected(LinkPtr _one, LinkPtr _two) const;
61 
63  public: virtual void Detach();
64 
66  public: virtual void SetAnchor(unsigned int _index,
67  const gazebo::math::Vector3 &_anchor);
68 
69  // Documentation inherited
70  public: virtual void SetDamping(unsigned int _index, double _damping);
71 
72  // Documentation inherited.
73  public: virtual bool SetPosition(unsigned int _index, double _position);
74 
75  // Documentation inherited.
76  public: virtual void SetStiffness(unsigned int _index,
77  const double _stiffness);
78 
79  // Documentation inherited.
80  public: virtual void SetStiffnessDamping(unsigned int _index,
81  double _stiffness, double _damping, double _reference = 0);
82 
84  public: virtual math::Vector3 GetAnchor(unsigned int _index) const;
85 
88  public: virtual math::Vector3 GetLinkForce(unsigned int _index) const;
89 
92  public: virtual math::Vector3 GetLinkTorque(unsigned int _index) const;
93 
94  // Documentation inherited.
95  public: virtual bool SetParam(const std::string &_key,
96  unsigned int _index,
97  const boost::any &_value);
98 
99  // Documentation inherited.
100  public: virtual double GetParam(const std::string &_key,
101  unsigned int _index);
102 
103  // Documentation inherited.
104  public: virtual math::Angle GetHighStop(unsigned int _index);
105 
106  // Documentation inherited.
107  public: virtual math::Angle GetLowStop(unsigned int _index);
108 
109  // Documentation inherited.
110  public: virtual void SetProvideFeedback(bool _enable);
111 
112  // Documentation inherited.
113  public: virtual void CacheForceTorque();
114 
115  // Documentation inherited.
116  public: virtual JointWrench GetForceTorque(unsigned int _index);
117 
118  // Documentation inherited.
119  public: virtual void SetForce(unsigned int _index, double _force);
120 
121  // Documentation inherited.
122  public: virtual double GetForce(unsigned int _index);
123 
124  // Documentation inherited.
125  public: virtual void Init();
126 
127  // Documentation inherited.
128  public: virtual void ApplyStiffnessDamping();
129 
140  protected: virtual void SetForceImpl(unsigned int _index,
141  double _force) = 0;
142 
145  protected: void SetupJointFeedback();
146 
150  private: void SaveForce(unsigned int _index, double _force);
151 
153  protected: btTypedConstraint *constraint;
154 
156  protected: btDynamicsWorld *bulletWorld;
157 
159  private: btJointFeedback *feedback;
160 
163  private: bool stiffnessDampingInitialized;
164 
170  private: double forceApplied[MAX_JOINT_AXIS];
171 
174  private: common::Time forceAppliedTime;
175  };
177  }
178 }
179 #endif
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:72
#define GZ_PHYSICS_VISIBLE
Definition: system.hh:259
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
#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.
btDynamicsWorld * bulletWorld
Pointer to Bullet's btDynamicsWorld.
Definition: BulletJoint.hh:156
An angle and related functions.
Definition: Angle.hh:53
btTypedConstraint * constraint
Pointer to a contraint object in Bullet.
Definition: BulletJoint.hh:153
Base class for all joints.
Definition: BulletJoint.hh:41
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:100
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44