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

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
21#include "btMultiBodyConstraint.h"
22struct btSolverInfo;
23
24 class btMultiBodySphericalJointMotor : 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_damping;
36
37public:
38 btMultiBodySphericalJointMotor(btMultiBody* body, int link, btScalar maxMotorImpulse);
39
40 virtual ~btMultiBodySphericalJointMotor();
41 virtual void finalizeMultiDof();
42
43 virtual int getIslandIdA() const;
44 virtual int getIslandIdB() const;
45
46 virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
47 btMultiBodyJacobianData& data,
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);
54 m_use_multi_dof_params = false;
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;
61 m_use_multi_dof_params = true;
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);
68 m_use_multi_dof_params = false;
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;
75 m_use_multi_dof_params = true;
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
91 btScalar getMaxAppliedImpulseMultiDof(int i) const
92 {
93 return m_maxAppliedImpulseMultiDof[i];
94 }
95
96 void setMaxAppliedImpulseMultiDof(const btVector3& maxImp)
97 {
98 m_maxAppliedImpulseMultiDof = maxImp;
99 m_use_multi_dof_params = true;
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
btMultiBodyConstraint.h
btMultiBodyConstraintArray
btAlignedObjectArray< btMultiBodySolverConstraint > btMultiBodyConstraintArray
Definition btMultiBodySolverConstraint.h:88
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition btIDebugDraw.h:27
btMultiBodyConstraint::btMultiBodyConstraint
btMultiBodyConstraint(btMultiBody *bodyA, btMultiBody *bodyB, int linkA, int linkB, int numRows, bool isUnilateral, int type)
Definition btMultiBodyConstraint.cpp:5
btMultiBodySphericalJointMotor::getIslandIdA
virtual int getIslandIdA() const
Definition btMultiBodySphericalJointMotor.cpp:62
btMultiBodySphericalJointMotor::m_desiredVelocity
btVector3 m_desiredVelocity
Definition btMultiBodySphericalJointMotor.h:27
btMultiBodySphericalJointMotor::m_maxAppliedImpulseMultiDof
btVector3 m_maxAppliedImpulseMultiDof
Definition btMultiBodySphericalJointMotor.h:34
btMultiBodySphericalJointMotor::setMaxAppliedImpulseMultiDof
void setMaxAppliedImpulseMultiDof(const btVector3 &maxImp)
Definition btMultiBodySphericalJointMotor.h:96
btMultiBodySphericalJointMotor::m_rhsClamp
btScalar m_rhsClamp
Definition btMultiBodySphericalJointMotor.h:33
btMultiBodySphericalJointMotor::setVelocityTarget
virtual void setVelocityTarget(const btVector3 &velTarget, btScalar kd=1.0)
Definition btMultiBodySphericalJointMotor.h:50
btMultiBodySphericalJointMotor::btMultiBodySphericalJointMotor
btMultiBodySphericalJointMotor(btMultiBody *body, int link, btScalar maxMotorImpulse)
This file was written by Erwin Coumans.
Definition btMultiBodySphericalJointMotor.cpp:25
btMultiBodySphericalJointMotor::debugDraw
virtual void debugDraw(class btIDebugDraw *drawer)
Definition btMultiBodySphericalJointMotor.h:112
btMultiBodySphericalJointMotor::setPositionTargetMultiDof
virtual void setPositionTargetMultiDof(const btQuaternion &posTarget, const btVector3 &kp=btVector3(1.f, 1.f, 1.f))
Definition btMultiBodySphericalJointMotor.h:71
btMultiBodySphericalJointMotor::finalizeMultiDof
virtual void finalizeMultiDof()
Definition btMultiBodySphericalJointMotor.cpp:42
btMultiBodySphericalJointMotor::setDamping
void setDamping(const btVector3 &damping)
Definition btMultiBodySphericalJointMotor.h:107
btMultiBodySphericalJointMotor::createConstraintRows
virtual void createConstraintRows(btMultiBodyConstraintArray &constraintRows, btMultiBodyJacobianData &data, const btContactSolverInfo &infoGlobal)
Definition btMultiBodySphericalJointMotor.cpp:98
btMultiBodySphericalJointMotor::getIslandIdB
virtual int getIslandIdB() const
Definition btMultiBodySphericalJointMotor.cpp:80
btMultiBodySphericalJointMotor::m_desiredPosition
btQuaternion m_desiredPosition
Definition btMultiBodySphericalJointMotor.h:28
btMultiBodySphericalJointMotor::setVelocityTargetMultiDof
virtual void setVelocityTargetMultiDof(const btVector3 &velTarget, const btVector3 &kd=btVector3(1.0, 1.0, 1.0))
Definition btMultiBodySphericalJointMotor.h:57
btMultiBodySphericalJointMotor::setErp
virtual void setErp(btScalar erp)
Definition btMultiBodySphericalJointMotor.h:78
btMultiBodySphericalJointMotor::m_kd
btVector3 m_kd
Definition btMultiBodySphericalJointMotor.h:30
btMultiBodySphericalJointMotor::m_damping
btVector3 m_damping
Definition btMultiBodySphericalJointMotor.h:35
btMultiBodySphericalJointMotor::m_erp
btScalar m_erp
Definition btMultiBodySphericalJointMotor.h:32
btMultiBodySphericalJointMotor::m_kp
btVector3 m_kp
Definition btMultiBodySphericalJointMotor.h:31
btMultiBodySphericalJointMotor::getErp
virtual btScalar getErp() const
Definition btMultiBodySphericalJointMotor.h:82
btMultiBodySphericalJointMotor::setRhsClamp
virtual void setRhsClamp(btScalar rhsClamp)
Definition btMultiBodySphericalJointMotor.h:86
btMultiBodySphericalJointMotor::m_use_multi_dof_params
bool m_use_multi_dof_params
Definition btMultiBodySphericalJointMotor.h:29
btMultiBodySphericalJointMotor::getDamping
btScalar getDamping(int i) const
Definition btMultiBodySphericalJointMotor.h:102
btMultiBodySphericalJointMotor::~btMultiBodySphericalJointMotor
virtual ~btMultiBodySphericalJointMotor()
Definition btMultiBodySphericalJointMotor.cpp:58
btMultiBodySphericalJointMotor::setPositionTarget
virtual void setPositionTarget(const btQuaternion &posTarget, btScalar kp=1.f)
Definition btMultiBodySphericalJointMotor.h:64
btMultiBodySphericalJointMotor::getMaxAppliedImpulseMultiDof
btScalar getMaxAppliedImpulseMultiDof(int i) const
Definition btMultiBodySphericalJointMotor.h:91
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