Bullet Collision Detection & Physics Library: btMultiBodySphericalJointLimit.h Source File

Bullet Collision Detection & Physics Library

btMultiBodySphericalJointLimit.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2018 Erwin Coumans http://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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"
22struct btSolverInfo;
23
24 class btMultiBodySphericalJointLimit : public btMultiBodyConstraint
25{
26protected:
27 btVector3 m_desiredVelocity;
28 btQuaternion m_desiredPosition;
29 bool m_use_multi_dof_params;
30 btVector3 m_kd;
31 btVector3 m_kp;
32 btScalar m_erp;
33 btScalar m_rhsClamp; //maximum error
34 btVector3 m_maxAppliedImpulseMultiDof;
35 btVector3 m_pivotA;
36 btVector3 m_pivotB;
37 btScalar m_swingxRange;
38 btScalar m_swingyRange;
39 btScalar m_twistRange;
40
41public:
42 btMultiBodySphericalJointLimit(btMultiBody* body, int link,
43 btScalar swingxRange,
44 btScalar swingyRange,
45 btScalar twistRange,
46 btScalar maxAppliedImpulse);
47
48 virtual ~btMultiBodySphericalJointLimit();
49 virtual void finalizeMultiDof();
50
51 virtual int getIslandIdA() const;
52 virtual int getIslandIdB() const;
53
54 virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
55 btMultiBodyJacobianData& data,
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;
69 m_use_multi_dof_params = true;
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;
83 m_use_multi_dof_params = true;
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
99 btScalar getMaxAppliedImpulseMultiDof(int i) const
100 {
101 return m_maxAppliedImpulseMultiDof[i];
102 }
103
104 void setMaxAppliedImpulseMultiDof(const btVector3& maxImp)
105 {
106 m_maxAppliedImpulseMultiDof = maxImp;
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
btMultiBodyConstraint.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
btAlignedObjectArray< btMultiBodySolverConstraint >
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:27
btMultiBodyConstraint
Definition: btMultiBodyConstraint.h:57
btMultiBodySphericalJointLimit
Definition: btMultiBodySphericalJointLimit.h:25
btMultiBodySphericalJointLimit::setMaxAppliedImpulseMultiDof
void setMaxAppliedImpulseMultiDof(const btVector3 &maxImp)
Definition: btMultiBodySphericalJointLimit.h:104
btMultiBodySphericalJointLimit::setRhsClamp
virtual void setRhsClamp(btScalar rhsClamp)
Definition: btMultiBodySphericalJointLimit.h:94
btMultiBodySphericalJointLimit::m_kp
btVector3 m_kp
Definition: btMultiBodySphericalJointLimit.h:31
btMultiBodySphericalJointLimit::setPositionTarget
virtual void setPositionTarget(const btQuaternion &posTarget, btScalar kp=1.f)
Definition: btMultiBodySphericalJointLimit.h:72
btMultiBodySphericalJointLimit::m_twistRange
btScalar m_twistRange
Definition: btMultiBodySphericalJointLimit.h:39
btMultiBodySphericalJointLimit::setErp
virtual void setErp(btScalar erp)
Definition: btMultiBodySphericalJointLimit.h:86
btMultiBodySphericalJointLimit::debugDraw
virtual void debugDraw(class btIDebugDraw *drawer)
Definition: btMultiBodySphericalJointLimit.cpp:260
btMultiBodySphericalJointLimit::~btMultiBodySphericalJointLimit
virtual ~btMultiBodySphericalJointLimit()
Definition: btMultiBodySphericalJointLimit.cpp:70
btMultiBodySphericalJointLimit::m_pivotA
btVector3 m_pivotA
Definition: btMultiBodySphericalJointLimit.h:35
btMultiBodySphericalJointLimit::createConstraintRows
virtual void createConstraintRows(btMultiBodyConstraintArray &constraintRows, btMultiBodyJacobianData &data, const btContactSolverInfo &infoGlobal)
Definition: btMultiBodySphericalJointLimit.cpp:110
btMultiBodySphericalJointLimit::btMultiBodySphericalJointLimit
btMultiBodySphericalJointLimit(btMultiBody *body, int link, btScalar swingxRange, btScalar swingyRange, btScalar twistRange, btScalar maxAppliedImpulse)
This file was written by Erwin Coumans.
Definition: btMultiBodySphericalJointLimit.cpp:26
btMultiBodySphericalJointLimit::m_swingxRange
btScalar m_swingxRange
Definition: btMultiBodySphericalJointLimit.h:37
btMultiBodySphericalJointLimit::m_desiredVelocity
btVector3 m_desiredVelocity
Definition: btMultiBodySphericalJointLimit.h:27
btMultiBodySphericalJointLimit::finalizeMultiDof
virtual void finalizeMultiDof()
Definition: btMultiBodySphericalJointLimit.cpp:52
btMultiBodySphericalJointLimit::getIslandIdA
virtual int getIslandIdA() const
Definition: btMultiBodySphericalJointLimit.cpp:74
btMultiBodySphericalJointLimit::setVelocityTargetMultiDof
virtual void setVelocityTargetMultiDof(const btVector3 &velTarget, const btVector3 &kd=btVector3(1.0, 1.0, 1.0))
Definition: btMultiBodySphericalJointLimit.h:65
btMultiBodySphericalJointLimit::m_erp
btScalar m_erp
Definition: btMultiBodySphericalJointLimit.h:32
btMultiBodySphericalJointLimit::setPositionTargetMultiDof
virtual void setPositionTargetMultiDof(const btQuaternion &posTarget, const btVector3 &kp=btVector3(1.f, 1.f, 1.f))
Definition: btMultiBodySphericalJointLimit.h:79
btMultiBodySphericalJointLimit::getErp
virtual btScalar getErp() const
Definition: btMultiBodySphericalJointLimit.h:90
btMultiBodySphericalJointLimit::m_swingyRange
btScalar m_swingyRange
Definition: btMultiBodySphericalJointLimit.h:38
btMultiBodySphericalJointLimit::m_pivotB
btVector3 m_pivotB
Definition: btMultiBodySphericalJointLimit.h:36
btMultiBodySphericalJointLimit::setVelocityTarget
virtual void setVelocityTarget(const btVector3 &velTarget, btScalar kd=1.0)
Definition: btMultiBodySphericalJointLimit.h:58
btMultiBodySphericalJointLimit::m_rhsClamp
btScalar m_rhsClamp
Definition: btMultiBodySphericalJointLimit.h:33
btMultiBodySphericalJointLimit::m_kd
btVector3 m_kd
Definition: btMultiBodySphericalJointLimit.h:30
btMultiBodySphericalJointLimit::m_maxAppliedImpulseMultiDof
btVector3 m_maxAppliedImpulseMultiDof
Definition: btMultiBodySphericalJointLimit.h:34
btMultiBodySphericalJointLimit::m_use_multi_dof_params
bool m_use_multi_dof_params
Definition: btMultiBodySphericalJointLimit.h:29
btMultiBodySphericalJointLimit::m_desiredPosition
btQuaternion m_desiredPosition
Definition: btMultiBodySphericalJointLimit.h:28
btMultiBodySphericalJointLimit::getMaxAppliedImpulseMultiDof
btScalar getMaxAppliedImpulseMultiDof(int i) const
Definition: btMultiBodySphericalJointLimit.h:99
btMultiBodySphericalJointLimit::getIslandIdB
virtual int getIslandIdB() const
Definition: btMultiBodySphericalJointLimit.cpp:92
btMultiBody
Definition: btMultiBody.h:51
btQuaternion
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
Definition: btQuaternion.h:50
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
btContactSolverInfo
Definition: btContactSolverInfo.h:76
btMultiBodyJacobianData
Definition: btMultiBodyConstraint.h:44