Bullet Collision Detection & Physics Library
btMultiBodySphericalJointMotor.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_MOTOR_H
19#define BT_MULTIBODY_SPHERICAL_JOINT_MOTOR_H
20
22struct btSolverInfo;
23
25{
26protected:
33 btScalar m_rhsClamp; //maximum error
36
37public:
38 btMultiBodySphericalJointMotor(btMultiBody* body, int link, btScalar maxMotorImpulse);
39
41 virtual void finalizeMultiDof();
42
43 virtual int getIslandIdA() const;
44 virtual int getIslandIdB() const;
45
46 virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
48 const btContactSolverInfo& infoGlobal);
49
50 virtual void setVelocityTarget(const btVector3& velTarget, btScalar kd = 1.0)
51 {
52 m_desiredVelocity = velTarget;
53 m_kd = btVector3(kd, kd, kd);
55 }
56
57 virtual void setVelocityTargetMultiDof(const btVector3& velTarget, const btVector3& kd = btVector3(1.0, 1.0, 1.0))
58 {
59 m_desiredVelocity = velTarget;
60 m_kd = kd;
62 }
63
64 virtual void setPositionTarget(const btQuaternion& posTarget, btScalar kp =1.f)
65 {
66 m_desiredPosition = posTarget;
67 m_kp = btVector3(kp, kp, kp);
69 }
70
71 virtual void setPositionTargetMultiDof(const btQuaternion& posTarget, const btVector3& kp = btVector3(1.f, 1.f, 1.f))
72 {
73 m_desiredPosition = posTarget;
74 m_kp = kp;
76 }
77
78 virtual void setErp(btScalar erp)
79 {
80 m_erp = erp;
81 }
82 virtual btScalar getErp() const
83 {
84 return m_erp;
85 }
86 virtual void setRhsClamp(btScalar rhsClamp)
87 {
88 m_rhsClamp = rhsClamp;
89 }
90
92 {
94 }
95
97 {
100 }
101
102 btScalar getDamping(int i) const
103 {
104 return m_damping[i];
105 }
106
107 void setDamping(const btVector3& damping)
108 {
109 m_damping = damping;
110 }
111
112 virtual void debugDraw(class btIDebugDraw* drawer)
113 {
114 //todo(erwincoumans)
115 }
116};
117
118#endif //BT_MULTIBODY_SPHERICAL_JOINT_MOTOR_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 setVelocityTarget(const btVector3 &velTarget, btScalar kd=1.0)
btMultiBodySphericalJointMotor(btMultiBody *body, int link, btScalar maxMotorImpulse)
This file was written by Erwin Coumans.
virtual void debugDraw(class btIDebugDraw *drawer)
virtual void setPositionTargetMultiDof(const btQuaternion &posTarget, const btVector3 &kp=btVector3(1.f, 1.f, 1.f))
void setDamping(const btVector3 &damping)
virtual void createConstraintRows(btMultiBodyConstraintArray &constraintRows, btMultiBodyJacobianData &data, const btContactSolverInfo &infoGlobal)
virtual void setVelocityTargetMultiDof(const btVector3 &velTarget, const btVector3 &kd=btVector3(1.0, 1.0, 1.0))
virtual void setRhsClamp(btScalar rhsClamp)
virtual void setPositionTarget(const btQuaternion &posTarget, btScalar kp=1.f)
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