Bullet Collision Detection & Physics Library
btMultiBodyJointMotor.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2013 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 #include "btMultiBodyJointMotor.h"
19 #include "btMultiBody.h"
22 
23 
24 btMultiBodyJointMotor::btMultiBodyJointMotor(btMultiBody* body, int link, btScalar desiredVelocity, btScalar maxMotorImpulse)
25  :btMultiBodyConstraint(body,body,link,link,1,true),
26  m_desiredVelocity(desiredVelocity)
27 {
28  m_maxAppliedImpulse = maxMotorImpulse;
29  // the data.m_jacobians never change, so may as well
30  // initialize them here
31 
32  // note: we rely on the fact that data.m_jacobians are
33  // always initialized to zero by the Constraint ctor
34 
35  // row 0: the lower bound
36  jacobianA(0)[6 + link] = 1;
37 }
39 {
40 }
41 
43 {
45  if (col)
46  return col->getIslandTag();
47  for (int i=0;i<m_bodyA->getNumLinks();i++)
48  {
49  if (m_bodyA->getLink(i).m_collider)
50  return m_bodyA->getLink(i).m_collider->getIslandTag();
51  }
52  return -1;
53 }
54 
56 {
58  if (col)
59  return col->getIslandTag();
60 
61  for (int i=0;i<m_bodyB->getNumLinks();i++)
62  {
63  col = m_bodyB->getLink(i).m_collider;
64  if (col)
65  return col->getIslandTag();
66  }
67  return -1;
68 }
69 
70 
73  const btContactSolverInfo& infoGlobal)
74 {
75  // only positions need to be updated -- data.m_jacobians and force
76  // directions were set in the ctor and never change.
77 
78 
79 
80  for (int row=0;row<getNumRows();row++)
81  {
82  btMultiBodySolverConstraint& constraintRow = constraintRows.expandNonInitializing();
83 
84  btScalar penetration = 0;
86  }
87 
88 }
89 
virtual int getIslandIdB() const
btScalar * jacobianB(int row)
const btMultibodyLink & getLink(int index) const
Definition: btMultiBody.h:76
1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and fr...
int getNumLinks() const
Definition: btMultiBody.h:112
btScalar * jacobianA(int row)
btMultiBodyJointMotor(btMultiBody *body, int link, btScalar desiredVelocity, btScalar maxMotorImpulse)
This file was written by Erwin Coumans.
virtual int getIslandIdA() const
virtual void createConstraintRows(btMultiBodyConstraintArray &constraintRows, btMultiBodyJacobianData &data, const btContactSolverInfo &infoGlobal)
btScalar fillConstraintRowMultiBodyMultiBody(btMultiBodySolverConstraint &constraintRow, btMultiBodyJacobianData &data, btScalar *jacOrgA, btScalar *jacOrgB, const btContactSolverInfo &infoGlobal, btScalar desiredVelocity, btScalar lowerLimit, btScalar upperLimit)
int getIslandTag() const
const btMultiBodyLinkCollider * getBaseCollider() const
Definition: btMultiBody.h:91
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:266