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: 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(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 ignition::math::Vector3d Anchor(
88  const unsigned int _index) const;
89 
92  public: virtual ignition::math::Vector3d LinkForce(
93  const unsigned int _index) const;
94 
97  public: virtual ignition::math::Vector3d LinkTorque(
98  const unsigned int _index) const;
99 
100  // Documentation inherited.
101  public: virtual bool SetParam(const std::string &_key,
102  unsigned int _index,
103  const boost::any &_value);
104 
105  // Documentation inherited.
106  public: virtual double GetParam(const std::string &_key,
107  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< Link > LinkPtr
Definition: PhysicsTypes.hh:109
Forward declarations for the common classes.
Definition: Animation.hh:33
btTypedConstraint * constraint
Pointer to a contraint object in Bullet.
Definition: BulletJoint.hh:153
btDynamicsWorld * bulletWorld
Pointer to Bullet&#39;s btDynamicsWorld.
Definition: BulletJoint.hh:156
#define MAX_JOINT_AXIS
maximum number of axis per joint anticipated.
Definition: Joint.hh:42
Base class for all joints.
Definition: Joint.hh:53
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