Bullet Collision Detection & Physics Library
btMultiBodySphericalJointLimit.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2018 Erwin Coumans http://bulletphysics.org
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
17 
18 #ifndef BT_MULTIBODY_SPHERICAL_JOINT_LIMIT_H
19 #define BT_MULTIBODY_SPHERICAL_JOINT_LIMIT_H
20 
21 #include "btMultiBodyConstraint.h"
22 struct btSolverInfo;
23 
25 {
26 protected:
33  btScalar m_rhsClamp; //maximum error
40 
41 public:
43  btScalar swingxRange,
44  btScalar swingyRange,
45  btScalar twistRange,
46  btScalar maxAppliedImpulse);
47 
49  virtual void finalizeMultiDof();
50 
51  virtual int getIslandIdA() const;
52  virtual int getIslandIdB() const;
53 
54  virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
56  const btContactSolverInfo& infoGlobal);
57 
58  virtual void setVelocityTarget(const btVector3& velTarget, btScalar kd = 1.0)
59  {
60  m_desiredVelocity = velTarget;
61  m_kd = btVector3(kd, kd, kd);
62  m_use_multi_dof_params = false;
63  }
64 
65  virtual void setVelocityTargetMultiDof(const btVector3& velTarget, const btVector3& kd = btVector3(1.0, 1.0, 1.0))
66  {
67  m_desiredVelocity = velTarget;
68  m_kd = kd;
70  }
71 
72  virtual void setPositionTarget(const btQuaternion& posTarget, btScalar kp =1.f)
73  {
74  m_desiredPosition = posTarget;
75  m_kp = btVector3(kp, kp, kp);
76  m_use_multi_dof_params = false;
77  }
78 
79  virtual void setPositionTargetMultiDof(const btQuaternion& posTarget, const btVector3& kp = btVector3(1.f, 1.f, 1.f))
80  {
81  m_desiredPosition = posTarget;
82  m_kp = kp;
84  }
85 
86  virtual void setErp(btScalar erp)
87  {
88  m_erp = erp;
89  }
90  virtual btScalar getErp() const
91  {
92  return m_erp;
93  }
94  virtual void setRhsClamp(btScalar rhsClamp)
95  {
96  m_rhsClamp = rhsClamp;
97  }
98 
100  {
101  return m_maxAppliedImpulseMultiDof[i];
102  }
103 
105  {
107  m_use_multi_dof_params = true;
108  }
109 
110 
111  virtual void debugDraw(class btIDebugDraw* drawer);
112 
113 };
114 
115 #endif //BT_MULTIBODY_SPHERICAL_JOINT_LIMIT_H
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:27
void setMaxAppliedImpulseMultiDof(const btVector3 &maxImp)
virtual void setRhsClamp(btScalar rhsClamp)
virtual void setPositionTarget(const btQuaternion &posTarget, btScalar kp=1.f)
virtual void debugDraw(class btIDebugDraw *drawer)
virtual void createConstraintRows(btMultiBodyConstraintArray &constraintRows, btMultiBodyJacobianData &data, const btContactSolverInfo &infoGlobal)
btMultiBodySphericalJointLimit(btMultiBody *body, int link, btScalar swingxRange, btScalar swingyRange, btScalar twistRange, btScalar maxAppliedImpulse)
This file was written by Erwin Coumans.
virtual void setVelocityTargetMultiDof(const btVector3 &velTarget, const btVector3 &kd=btVector3(1.0, 1.0, 1.0))
virtual void setPositionTargetMultiDof(const btQuaternion &posTarget, const btVector3 &kp=btVector3(1.f, 1.f, 1.f))
virtual void setVelocityTarget(const btVector3 &velTarget, btScalar kd=1.0)
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:50
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82