summaryrefslogtreecommitdiff
path: root/thirdparty/bullet/BulletDynamics
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/bullet/BulletDynamics')
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp13
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h20
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp5
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h2
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp9
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp1
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp21
-rw-r--r--thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h49
-rw-r--r--thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp4
9 files changed, 101 insertions, 23 deletions
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp
index 7cb92fa3b4..d7588aedc8 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.cpp
@@ -33,8 +33,8 @@
namespace
{
-const btScalar SLEEP_EPSILON = btScalar(0.05); // this is a squared velocity (m^2 s^-2)
-const btScalar SLEEP_TIMEOUT = btScalar(2); // in seconds
+const btScalar INITIAL_SLEEP_EPSILON = btScalar(0.05); // this is a squared velocity (m^2 s^-2)
+const btScalar INITIAL_SLEEP_TIMEOUT = btScalar(2); // in seconds
} // namespace
void btMultiBody::spatialTransform(const btMatrix3x3 &rotation_matrix, // rotates vectors in 'from' frame to vectors in 'to' frame
@@ -110,6 +110,9 @@ btMultiBody::btMultiBody(int n_links,
m_canSleep(canSleep),
m_canWakeup(true),
m_sleepTimer(0),
+ m_sleepEpsilon(INITIAL_SLEEP_EPSILON),
+ m_sleepTimeout(INITIAL_SLEEP_TIMEOUT),
+
m_userObjectPointer(0),
m_userIndex2(-1),
m_userIndex(-1),
@@ -1411,7 +1414,7 @@ void btMultiBody::solveImatrix(const btSpatialForceVector &rhs, btSpatialMotionV
}
}
-void btMultiBody::mulMatrix(btScalar *pA, btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const
+void btMultiBody::mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const
{
for (int row = 0; row < rowsA; row++)
{
@@ -2104,10 +2107,10 @@ void btMultiBody::checkMotionAndSleepIfRequired(btScalar timestep)
motion += m_realBuf[i] * m_realBuf[i];
}
- if (motion < SLEEP_EPSILON)
+ if (motion < m_sleepEpsilon)
{
m_sleepTimer += timestep;
- if (m_sleepTimer > SLEEP_TIMEOUT)
+ if (m_sleepTimer > m_sleepTimeout)
{
goToSleep();
}
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h
index 5a3efc9414..345970d261 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBody.h
@@ -545,7 +545,10 @@ public:
{
m_canWakeup = canWakeup;
}
- bool isAwake() const { return m_awake; }
+ bool isAwake() const
+ {
+ return m_awake;
+ }
void wakeUp();
void goToSleep();
void checkMotionAndSleepIfRequired(btScalar timestep);
@@ -726,6 +729,17 @@ public:
bool isLinkAndAllAncestorsKinematic(const int i) const;
+ void setSleepThreshold(btScalar sleepThreshold)
+ {
+ m_sleepEpsilon = sleepThreshold;
+ }
+
+ void setSleepTimeout(btScalar sleepTimeout)
+ {
+ this->m_sleepTimeout = sleepTimeout;
+ }
+
+
private:
btMultiBody(const btMultiBody &); // not implemented
void operator=(const btMultiBody &); // not implemented
@@ -745,7 +759,7 @@ private:
}
}
- void mulMatrix(btScalar * pA, btScalar * pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const;
+ void mulMatrix(const btScalar *pA, const btScalar *pB, int rowsA, int colsA, int rowsB, int colsB, btScalar *pC) const;
private:
btMultiBodyLinkCollider *m_baseCollider; //can be NULL
@@ -801,6 +815,8 @@ private:
bool m_canSleep;
bool m_canWakeup;
btScalar m_sleepTimer;
+ btScalar m_sleepEpsilon;
+ btScalar m_sleepTimeout;
void *m_userObjectPointer;
int m_userIndex2;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
index 1ba5861145..00d5fd5609 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp
@@ -61,7 +61,8 @@ btScalar btMultiBodyConstraint::fillMultiBodyConstraint(btMultiBodySolverConstra
btScalar lowerLimit, btScalar upperLimit,
bool angConstraint,
btScalar relaxation,
- bool isFriction, btScalar desiredVelocity, btScalar cfmSlip)
+ bool isFriction, btScalar desiredVelocity, btScalar cfmSlip,
+ btScalar damping)
{
solverConstraint.m_multiBodyA = m_bodyA;
solverConstraint.m_multiBodyB = m_bodyB;
@@ -348,7 +349,7 @@ btScalar btMultiBodyConstraint::fillMultiBodyConstraint(btMultiBodySolverConstra
{
btScalar positionalError = 0.f;
- btScalar velocityError = desiredVelocity - rel_vel; // * damping;
+ btScalar velocityError = (desiredVelocity - rel_vel) * damping;
btScalar erp = infoGlobal.m_erp2;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h
index 4a6007ee3e..1aaa07b69e 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyConstraint.h
@@ -94,7 +94,7 @@ protected:
bool angConstraint = false,
btScalar relaxation = 1.f,
- bool isFriction = false, btScalar desiredVelocity = 0, btScalar cfmSlip = 0);
+ bool isFriction = false, btScalar desiredVelocity = 0, btScalar cfmSlip = 0, btScalar damping = 1.0);
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
index fef95f0c4e..e7af332eb3 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp
@@ -137,7 +137,14 @@ void btMultiBodyDynamicsWorld::updateActivationState(btScalar timeStep)
btMultiBodyLinkCollider* col = body->getBaseCollider();
if (col && col->getActivationState() == ACTIVE_TAG)
{
- col->setActivationState(WANTS_DEACTIVATION);
+ if (body->hasFixedBase())
+ {
+ col->setActivationState(FIXED_BASE_MULTI_BODY);
+ } else
+ {
+ col->setActivationState(WANTS_DEACTIVATION);
+ }
+
col->setDeactivationTime(0.f);
}
for (int b = 0; b < body->getNumLinks(); b++)
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
index 4372489fa1..fec9b03213 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp
@@ -43,6 +43,7 @@ void btMultiBodyJointMotor::finalizeMultiDof()
unsigned int offset = 6 + (m_bodyA->getLink(m_linkA).m_dofOffset + linkDoF);
// row 0: the lower bound
+ // row 0: the lower bound
jacobianA(0)[offset] = 1;
m_numDofsFinalized = m_jacSizeBoth;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp
index 5c20d2a0d4..00a7ef3579 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp
@@ -26,10 +26,13 @@ btMultiBodySphericalJointMotor::btMultiBodySphericalJointMotor(btMultiBody* body
: btMultiBodyConstraint(body, body, link, body->getLink(link).m_parent, 3, true, MULTIBODY_CONSTRAINT_SPHERICAL_MOTOR),
m_desiredVelocity(0, 0, 0),
m_desiredPosition(0,0,0,1),
- m_kd(1.),
- m_kp(0.2),
+ m_use_multi_dof_params(false),
+ m_kd(1., 1., 1.),
+ m_kp(0.2, 0.2, 0.2),
m_erp(1),
- m_rhsClamp(SIMD_INFINITY)
+ m_rhsClamp(SIMD_INFINITY),
+ m_maxAppliedImpulseMultiDof(maxMotorImpulse, maxMotorImpulse, maxMotorImpulse),
+ m_damping(1.0, 1.0, 1.0)
{
m_maxAppliedImpulse = maxMotorImpulse;
@@ -45,6 +48,7 @@ void btMultiBodySphericalJointMotor::finalizeMultiDof()
unsigned int offset = 6 + (m_bodyA->getLink(m_linkA).m_dofOffset + linkDoF);
// row 0: the lower bound
+ // row 0: the lower bound
jacobianA(0)[offset] = 1;
m_numDofsFinalized = m_jacSizeBoth;
@@ -138,7 +142,8 @@ btQuaternion relRot = currentQuat.inverse() * desiredQuat;
btScalar currentVelocity = m_bodyA->getJointVelMultiDof(m_linkA)[dof];
btScalar desiredVelocity = this->m_desiredVelocity[row];
- btScalar velocityError = desiredVelocity - currentVelocity;
+ double kd = m_use_multi_dof_params ? m_kd[row % 3] : m_kd[0];
+ btScalar velocityError = (desiredVelocity - currentVelocity) * kd;
btMatrix3x3 frameAworld;
frameAworld.setIdentity();
@@ -151,12 +156,16 @@ btQuaternion relRot = currentQuat.inverse() * desiredQuat;
case btMultibodyLink::eSpherical:
{
btVector3 constraintNormalAng = frameAworld.getColumn(row % 3);
- posError = m_kp*angleDiff[row % 3];
+ double kp = m_use_multi_dof_params ? m_kp[row % 3] : m_kp[0];
+ posError = kp*angleDiff[row % 3];
+ double max_applied_impulse = m_use_multi_dof_params ? m_maxAppliedImpulseMultiDof[row % 3] : m_maxAppliedImpulse;
fillMultiBodyConstraint(constraintRow, data, 0, 0, constraintNormalAng,
btVector3(0,0,0), dummy, dummy,
posError,
infoGlobal,
- -m_maxAppliedImpulse, m_maxAppliedImpulse, true);
+ -max_applied_impulse, max_applied_impulse, true,
+ 1.0, false, 0, 0,
+ m_damping[row % 3]);
constraintRow.m_orgConstraint = this;
constraintRow.m_orgDofIndex = row;
break;
diff --git a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h
index 621beab5a4..bdeccc2e24 100644
--- a/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h
+++ b/thirdparty/bullet/BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.h
@@ -26,10 +26,13 @@ class btMultiBodySphericalJointMotor : public btMultiBodyConstraint
protected:
btVector3 m_desiredVelocity;
btQuaternion m_desiredPosition;
- btScalar m_kd;
- btScalar m_kp;
+ bool m_use_multi_dof_params;
+ btVector3 m_kd;
+ btVector3 m_kp;
btScalar m_erp;
btScalar m_rhsClamp; //maximum error
+ btVector3 m_maxAppliedImpulseMultiDof;
+ btVector3 m_damping;
public:
btMultiBodySphericalJointMotor(btMultiBody* body, int link, btScalar maxMotorImpulse);
@@ -44,16 +47,32 @@ public:
btMultiBodyJacobianData& data,
const btContactSolverInfo& infoGlobal);
- virtual void setVelocityTarget(const btVector3& velTarget, btScalar kd = 1.f)
+ virtual void setVelocityTarget(const btVector3& velTarget, btScalar kd = 1.0)
+ {
+ m_desiredVelocity = velTarget;
+ m_kd = btVector3(kd, kd, kd);
+ m_use_multi_dof_params = false;
+ }
+
+ virtual void setVelocityTargetMultiDof(const btVector3& velTarget, const btVector3& kd = btVector3(1.0, 1.0, 1.0))
{
m_desiredVelocity = velTarget;
m_kd = kd;
+ m_use_multi_dof_params = true;
}
- virtual void setPositionTarget(const btQuaternion& posTarget, btScalar kp = 1.f)
+ virtual void setPositionTarget(const btQuaternion& posTarget, btScalar kp =1.f)
+ {
+ m_desiredPosition = posTarget;
+ m_kp = btVector3(kp, kp, kp);
+ m_use_multi_dof_params = false;
+ }
+
+ virtual void setPositionTargetMultiDof(const btQuaternion& posTarget, const btVector3& kp = btVector3(1.f, 1.f, 1.f))
{
m_desiredPosition = posTarget;
m_kp = kp;
+ m_use_multi_dof_params = true;
}
virtual void setErp(btScalar erp)
@@ -68,6 +87,28 @@ public:
{
m_rhsClamp = rhsClamp;
}
+
+ btScalar getMaxAppliedImpulseMultiDof(int i) const
+ {
+ return m_maxAppliedImpulseMultiDof[i];
+ }
+
+ void setMaxAppliedImpulseMultiDof(const btVector3& maxImp)
+ {
+ m_maxAppliedImpulseMultiDof = maxImp;
+ m_use_multi_dof_params = true;
+ }
+
+ btScalar getDamping(int i) const
+ {
+ return m_damping[i];
+ }
+
+ void setDamping(const btVector3& damping)
+ {
+ m_damping = damping;
+ }
+
virtual void debugDraw(class btIDebugDraw* drawer)
{
//todo(erwincoumans)
diff --git a/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp b/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
index 5d864f2757..ed4e0b686d 100644
--- a/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
+++ b/thirdparty/bullet/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp
@@ -532,7 +532,7 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
J_transpose = J.transpose();
btMatrixXu& tmp = m_scratchTmp;
-
+ //Minv.printMatrix("Minv=");
{
{
BT_PROFILE("J*Minv");
@@ -543,7 +543,7 @@ void btMLCPSolver::createMLCP(const btContactSolverInfo& infoGlobal)
m_A = tmp * J_transpose;
}
}
-
+ //J.printMatrix("J");
if (1)
{
// add cfm to the diagonal of m_A