2015-04-16 16:55:32 +00:00
|
|
|
|
|
|
|
#include "ImportURDFSetup.h"
|
|
|
|
#include "BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.h"
|
2015-04-22 23:35:27 +00:00
|
|
|
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
#include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h"
|
|
|
|
#include "Bullet3Common/b3FileUtils.h"
|
2015-04-22 23:35:27 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
#include "BulletDynamics/Featherstone/btMultiBodyJointMotor.h"
|
|
|
|
#include "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.h"
|
|
|
|
#include "../CommonInterfaces/CommonParameterInterface.h"
|
2015-07-10 00:36:00 +00:00
|
|
|
#include "../../Utils/b3ResourcePath.h"
|
|
|
|
|
2015-07-04 01:17:14 +00:00
|
|
|
#ifdef ENABLE_ROS_URDF
|
2015-06-28 21:09:21 +00:00
|
|
|
#include "ROSURDFImporter.h"
|
2015-07-04 01:17:14 +00:00
|
|
|
#endif
|
2015-07-01 15:58:14 +00:00
|
|
|
#include "BulletUrdfImporter.h"
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
#include "URDF2Bullet.h"
|
|
|
|
|
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
//#include "urdf_samples.h"
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "../CommonInterfaces/CommonMultiBodyBase.h"
|
|
|
|
|
2015-04-22 23:35:27 +00:00
|
|
|
#include "MyMultiBodyCreator.h"
|
2015-04-16 16:55:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ImportUrdfSetup : public CommonMultiBodyBase
|
|
|
|
{
|
|
|
|
char m_fileName[1024];
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
struct ImportUrdfInternalData* m_data;
|
|
|
|
bool m_useMultiBody;
|
2015-07-10 00:36:00 +00:00
|
|
|
btAlignedObjectArray<std::string* > m_nameMemory;
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
public:
|
2015-05-01 18:42:14 +00:00
|
|
|
ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName);
|
2015-04-16 16:55:32 +00:00
|
|
|
virtual ~ImportUrdfSetup();
|
|
|
|
|
|
|
|
virtual void initPhysics();
|
|
|
|
virtual void stepSimulation(float deltaTime);
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
void setFileName(const char* urdfFileName);
|
2015-05-01 18:42:14 +00:00
|
|
|
|
|
|
|
virtual void resetCamera()
|
|
|
|
{
|
|
|
|
float dist = 3.5;
|
|
|
|
float pitch = -136;
|
|
|
|
float yaw = 28;
|
|
|
|
float targetPos[3]={0.47,0,-0.64};
|
|
|
|
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
|
|
|
}
|
2015-04-16 16:55:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
btAlignedObjectArray<std::string> gFileNameArray;
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_NUM_MOTORS 1024
|
|
|
|
|
|
|
|
struct ImportUrdfInternalData
|
|
|
|
{
|
|
|
|
ImportUrdfInternalData()
|
|
|
|
:m_numMotors(0)
|
|
|
|
{
|
2015-06-25 06:19:00 +00:00
|
|
|
for (int i=0;i<MAX_NUM_MOTORS;i++)
|
|
|
|
{
|
|
|
|
m_jointMotors[i] = 0;
|
|
|
|
m_generic6DofJointMotors[i] = 0;
|
|
|
|
}
|
2015-04-16 16:55:32 +00:00
|
|
|
}
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
btScalar m_motorTargetVelocities[MAX_NUM_MOTORS];
|
|
|
|
btMultiBodyJointMotor* m_jointMotors [MAX_NUM_MOTORS];
|
2015-06-25 06:19:00 +00:00
|
|
|
btGeneric6DofSpring2Constraint* m_generic6DofJointMotors [MAX_NUM_MOTORS];
|
2015-04-16 16:55:32 +00:00
|
|
|
int m_numMotors;
|
2015-06-25 06:19:00 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName)
|
2015-04-16 16:55:32 +00:00
|
|
|
:CommonMultiBodyBase(helper)
|
|
|
|
{
|
2015-05-01 18:42:14 +00:00
|
|
|
m_data = new ImportUrdfInternalData;
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
if (option==1)
|
|
|
|
{
|
|
|
|
m_useMultiBody = true;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
m_useMultiBody = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int count = 0;
|
2015-05-01 18:42:14 +00:00
|
|
|
if (fileName)
|
|
|
|
{
|
|
|
|
setFileName(fileName);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
gFileNameArray.clear();
|
2015-06-25 06:19:00 +00:00
|
|
|
|
2015-06-05 18:46:53 +00:00
|
|
|
|
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
//load additional urdf file names from file
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
FILE* f = fopen("urdf_files.txt","r");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
//warning: we don't avoid string buffer overflow in this basic example in fscanf
|
|
|
|
char fileName[1024];
|
|
|
|
do
|
|
|
|
{
|
|
|
|
result = fscanf(f,"%s",fileName);
|
2015-05-05 19:51:38 +00:00
|
|
|
b3Printf("urdf_files.txt entry %s",fileName);
|
2015-05-01 18:42:14 +00:00
|
|
|
if (result==1)
|
|
|
|
{
|
|
|
|
gFileNameArray.push_back(fileName);
|
|
|
|
}
|
|
|
|
} while (result==1);
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
fclose(f);
|
|
|
|
}
|
2015-06-25 06:19:00 +00:00
|
|
|
|
|
|
|
if (gFileNameArray.size()==0)
|
|
|
|
{
|
2015-06-28 21:09:21 +00:00
|
|
|
gFileNameArray.push_back("r2d2.urdf");//husky/husky.urdf");
|
2015-06-25 06:19:00 +00:00
|
|
|
|
|
|
|
}
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
int numFileNames = gFileNameArray.size();
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
if (count>=numFileNames)
|
|
|
|
{
|
|
|
|
count=0;
|
|
|
|
}
|
|
|
|
sprintf(m_fileName,gFileNameArray[count++].c_str());
|
2015-04-16 16:55:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImportUrdfSetup::~ImportUrdfSetup()
|
|
|
|
{
|
2015-07-10 00:36:00 +00:00
|
|
|
for (int i=0;i<m_nameMemory.size();i++)
|
|
|
|
{
|
|
|
|
delete m_nameMemory[i];
|
|
|
|
}
|
|
|
|
m_nameMemory.clear();
|
2015-04-16 16:55:32 +00:00
|
|
|
delete m_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static btVector4 colors[4] =
|
|
|
|
{
|
|
|
|
btVector4(1,0,0,1),
|
|
|
|
btVector4(0,1,0,1),
|
|
|
|
btVector4(0,1,1,1),
|
|
|
|
btVector4(1,1,0,1),
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
btVector3 selectColor()
|
|
|
|
{
|
|
|
|
|
|
|
|
static int curColor = 0;
|
|
|
|
btVector4 color = colors[curColor];
|
|
|
|
curColor++;
|
|
|
|
curColor&=3;
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImportUrdfSetup::setFileName(const char* urdfFileName)
|
|
|
|
{
|
|
|
|
memcpy(m_fileName,urdfFileName,strlen(urdfFileName)+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ImportUrdfSetup::initPhysics()
|
|
|
|
{
|
|
|
|
|
|
|
|
int upAxis = 2;
|
|
|
|
m_guiHelper->setUpAxis(2);
|
|
|
|
|
|
|
|
this->createEmptyDynamicsWorld();
|
|
|
|
//m_dynamicsWorld->getSolverInfo().m_numIterations = 100;
|
|
|
|
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
|
|
|
m_dynamicsWorld->getDebugDrawer()->setDebugMode(
|
|
|
|
btIDebugDraw::DBG_DrawConstraints
|
|
|
|
+btIDebugDraw::DBG_DrawContactPoints
|
|
|
|
+btIDebugDraw::DBG_DrawAabb
|
|
|
|
);//+btIDebugDraw::DBG_DrawConstraintLimits);
|
|
|
|
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
btVector3 gravity(0,0,0);
|
2015-06-25 06:27:50 +00:00
|
|
|
gravity[upAxis]=-9.8;
|
2015-04-16 16:55:32 +00:00
|
|
|
|
|
|
|
m_dynamicsWorld->setGravity(gravity);
|
|
|
|
|
2015-07-10 00:36:00 +00:00
|
|
|
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
//now print the tree using the new interface
|
2015-06-30 04:30:44 +00:00
|
|
|
URDFImporterInterface* bla=0;
|
2015-06-28 21:09:21 +00:00
|
|
|
|
2015-07-04 01:17:14 +00:00
|
|
|
static bool newURDF = true;
|
2015-06-30 04:30:44 +00:00
|
|
|
if (newURDF)
|
|
|
|
{
|
|
|
|
b3Printf("using new URDF\n");
|
|
|
|
bla = new BulletURDFImporter(m_guiHelper);
|
2015-07-04 01:17:14 +00:00
|
|
|
}
|
|
|
|
#ifdef USE_ROS_URDF
|
|
|
|
else
|
2015-06-30 04:30:44 +00:00
|
|
|
{
|
|
|
|
b3Printf("using ROS URDF\n");
|
|
|
|
bla = new ROSURDFImporter(m_guiHelper);
|
|
|
|
}
|
2015-07-04 01:17:14 +00:00
|
|
|
newURDF = !newURDF;
|
|
|
|
#endif//USE_ROS_URDF
|
2015-06-30 04:30:44 +00:00
|
|
|
URDFImporterInterface& u2b = *bla;
|
2015-04-23 22:41:17 +00:00
|
|
|
bool loadOk = u2b.loadURDF(m_fileName);
|
2015-07-10 00:36:00 +00:00
|
|
|
|
|
|
|
//test to serialize a multibody to disk or shared memory, with base, link and joint names
|
|
|
|
btSerializer* s = new btDefaultSerializer;
|
2015-04-23 22:41:17 +00:00
|
|
|
|
|
|
|
if (loadOk)
|
|
|
|
{
|
2015-06-30 04:30:44 +00:00
|
|
|
printTree(u2b,u2b.getRootLinkIndex());
|
|
|
|
|
|
|
|
//u2b.printTree();
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
btTransform identityTrans;
|
|
|
|
identityTrans.setIdentity();
|
2015-06-05 18:46:53 +00:00
|
|
|
|
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
{
|
2015-06-05 18:46:53 +00:00
|
|
|
|
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
btMultiBody* mb = 0;
|
2015-06-05 18:46:53 +00:00
|
|
|
|
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
//todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user
|
|
|
|
int rootLinkIndex = u2b.getRootLinkIndex();
|
2015-07-04 01:54:41 +00:00
|
|
|
b3Printf("urdf root link index = %d\n",rootLinkIndex);
|
2015-04-23 22:41:17 +00:00
|
|
|
MyMultiBodyCreator creation(m_guiHelper);
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
ConvertURDF2Bullet(u2b,creation, identityTrans,m_dynamicsWorld,m_useMultiBody,u2b.getPathPrefix());
|
|
|
|
mb = creation.getBulletMultiBody();
|
2015-04-22 23:35:27 +00:00
|
|
|
|
2015-07-10 00:36:00 +00:00
|
|
|
if (m_useMultiBody && mb )
|
2015-04-23 22:41:17 +00:00
|
|
|
{
|
2015-07-10 00:36:00 +00:00
|
|
|
std::string* name = new std::string(u2b.getLinkName(u2b.getRootLinkIndex()));
|
|
|
|
m_nameMemory.push_back(name);
|
|
|
|
s->registerNameForPointer(name->c_str(),name->c_str());
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-07-10 00:36:00 +00:00
|
|
|
mb->setBaseName(name->c_str());
|
2015-06-25 06:19:00 +00:00
|
|
|
//create motors for each btMultiBody joint
|
2015-06-30 04:30:44 +00:00
|
|
|
int numLinks = mb->getNumLinks();
|
|
|
|
for (int i=0;i<numLinks;i++)
|
2015-04-23 22:41:17 +00:00
|
|
|
{
|
|
|
|
int mbLinkIndex = i;
|
2015-07-10 00:36:00 +00:00
|
|
|
int urdfLinkIndex = creation.m_mb2urdfLink[mbLinkIndex];
|
|
|
|
|
|
|
|
std::string* jointName = new std::string(u2b.getJointName(urdfLinkIndex));
|
|
|
|
std::string* linkName = new std::string(u2b.getLinkName(urdfLinkIndex).c_str());
|
|
|
|
s->registerNameForPointer(jointName->c_str(),jointName->c_str());
|
|
|
|
s->registerNameForPointer(linkName->c_str(),linkName->c_str());
|
|
|
|
|
|
|
|
m_nameMemory.push_back(jointName);
|
|
|
|
m_nameMemory.push_back(linkName);
|
|
|
|
|
|
|
|
mb->getLink(i).m_linkName = linkName->c_str();
|
|
|
|
mb->getLink(i).m_jointName = jointName->c_str();
|
|
|
|
|
2015-06-05 18:46:53 +00:00
|
|
|
if (mb->getLink(mbLinkIndex).m_jointType==btMultibodyLink::eRevolute
|
2015-06-04 01:02:15 +00:00
|
|
|
||mb->getLink(mbLinkIndex).m_jointType==btMultibodyLink::ePrismatic
|
|
|
|
)
|
2015-04-23 22:41:17 +00:00
|
|
|
{
|
|
|
|
if (m_data->m_numMotors<MAX_NUM_MOTORS)
|
|
|
|
{
|
2015-07-10 00:36:00 +00:00
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
char motorName[1024];
|
2015-07-10 00:36:00 +00:00
|
|
|
sprintf(motorName,"%s q'", jointName->c_str());
|
2015-04-23 22:41:17 +00:00
|
|
|
btScalar* motorVel = &m_data->m_motorTargetVelocities[m_data->m_numMotors];
|
|
|
|
*motorVel = 0.f;
|
|
|
|
SliderParams slider(motorName,motorVel);
|
|
|
|
slider.m_minVal=-4;
|
|
|
|
slider.m_maxVal=4;
|
|
|
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
|
|
|
|
float maxMotorImpulse = 0.1f;
|
|
|
|
btMultiBodyJointMotor* motor = new btMultiBodyJointMotor(mb,mbLinkIndex,0,0,maxMotorImpulse);
|
2015-06-25 06:19:00 +00:00
|
|
|
//motor->setMaxAppliedImpulse(0);
|
2015-04-23 22:41:17 +00:00
|
|
|
m_data->m_jointMotors[m_data->m_numMotors]=motor;
|
|
|
|
m_dynamicsWorld->addMultiBodyConstraint(motor);
|
|
|
|
m_data->m_numMotors++;
|
|
|
|
}
|
|
|
|
}
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
}
|
2015-06-25 06:19:00 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (1)
|
|
|
|
{
|
|
|
|
//create motors for each generic joint
|
2015-06-30 04:30:44 +00:00
|
|
|
int num6Dof = creation.getNum6DofConstraints();
|
|
|
|
for (int i=0;i<num6Dof;i++)
|
2015-06-25 06:19:00 +00:00
|
|
|
{
|
|
|
|
btGeneric6DofSpring2Constraint* c = creation.get6DofConstraint(i);
|
|
|
|
if (c->getUserConstraintPtr())
|
|
|
|
{
|
|
|
|
GenericConstraintUserInfo* jointInfo = (GenericConstraintUserInfo*)c->getUserConstraintPtr();
|
|
|
|
if ((jointInfo->m_urdfJointType ==URDFRevoluteJoint) ||
|
|
|
|
(jointInfo->m_urdfJointType ==URDFPrismaticJoint) ||
|
|
|
|
(jointInfo->m_urdfJointType ==URDFContinuousJoint))
|
|
|
|
{
|
|
|
|
int urdfLinkIndex = jointInfo->m_urdfIndex;
|
|
|
|
std::string jointName = u2b.getJointName(urdfLinkIndex);
|
|
|
|
char motorName[1024];
|
|
|
|
sprintf(motorName,"%s q'", jointName.c_str());
|
|
|
|
btScalar* motorVel = &m_data->m_motorTargetVelocities[m_data->m_numMotors];
|
|
|
|
|
|
|
|
*motorVel = 0.f;
|
|
|
|
SliderParams slider(motorName,motorVel);
|
|
|
|
slider.m_minVal=-4;
|
|
|
|
slider.m_maxVal=4;
|
|
|
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
|
|
|
|
m_data->m_generic6DofJointMotors[m_data->m_numMotors]=c;
|
|
|
|
bool motorOn = true;
|
|
|
|
c->enableMotor(jointInfo->m_jointAxisIndex,motorOn);
|
|
|
|
c->setMaxMotorForce(jointInfo->m_jointAxisIndex,10000);
|
|
|
|
c->setTargetVelocity(jointInfo->m_jointAxisIndex,0);
|
|
|
|
|
|
|
|
m_data->m_numMotors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
}
|
|
|
|
}
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
//the btMultiBody support is work-in-progress :-)
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-06-05 18:46:53 +00:00
|
|
|
for (int i=0;i<m_dynamicsWorld->getNumMultiBodyConstraints();i++)
|
|
|
|
{
|
|
|
|
m_dynamicsWorld->getMultiBodyConstraint(i)->finalizeMultiDof();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
bool createGround=true;
|
|
|
|
if (createGround)
|
|
|
|
{
|
|
|
|
btVector3 groundHalfExtents(20,20,20);
|
|
|
|
groundHalfExtents[upAxis]=1.f;
|
|
|
|
btBoxShape* box = new btBoxShape(groundHalfExtents);
|
|
|
|
box->initializePolyhedralFeatures();
|
|
|
|
|
|
|
|
m_guiHelper->createCollisionShapeGraphicsObject(box);
|
|
|
|
btTransform start; start.setIdentity();
|
|
|
|
btVector3 groundOrigin(0,0,0);
|
|
|
|
groundOrigin[upAxis]=-2;//.5;
|
|
|
|
start.setOrigin(groundOrigin);
|
|
|
|
btRigidBody* body = createRigidBody(0,start,box);
|
|
|
|
//m_dynamicsWorld->removeRigidBody(body);
|
|
|
|
// m_dynamicsWorld->addRigidBody(body,2,1);
|
|
|
|
btVector3 color(0.5,0.5,0.5);
|
|
|
|
m_guiHelper->createRigidBodyGraphicsObject(body,color);
|
|
|
|
}
|
|
|
|
|
|
|
|
///this extra stepSimulation call makes sure that all the btMultibody transforms are properly propagates.
|
|
|
|
m_dynamicsWorld->stepSimulation(1. / 240., 0);// 1., 10, 1. / 240.);
|
|
|
|
}
|
2015-07-10 00:36:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
m_dynamicsWorld->serialize(s);
|
|
|
|
b3ResourcePath p;
|
|
|
|
char resourcePath[1024];
|
|
|
|
if (p.findResourcePath("r2d2_multibody.bullet",resourcePath,1024))
|
|
|
|
{
|
|
|
|
FILE* f = fopen(resourcePath,"wb");
|
|
|
|
fwrite(s->getBufferPointer(),s->getCurrentBufferSize(),1,f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
2015-04-16 16:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImportUrdfSetup::stepSimulation(float deltaTime)
|
|
|
|
{
|
|
|
|
if (m_dynamicsWorld)
|
|
|
|
{
|
|
|
|
for (int i=0;i<m_data->m_numMotors;i++)
|
|
|
|
{
|
2015-06-25 06:19:00 +00:00
|
|
|
if (m_data->m_jointMotors[i])
|
|
|
|
{
|
|
|
|
m_data->m_jointMotors[i]->setVelocityTarget(m_data->m_motorTargetVelocities[i]);
|
|
|
|
}
|
|
|
|
if (m_data->m_generic6DofJointMotors[i])
|
|
|
|
{
|
|
|
|
GenericConstraintUserInfo* jointInfo = (GenericConstraintUserInfo*)m_data->m_generic6DofJointMotors[i]->getUserConstraintPtr();
|
|
|
|
m_data->m_generic6DofJointMotors[i]->setTargetVelocity(jointInfo->m_jointAxisIndex,m_data->m_motorTargetVelocities[i]);
|
|
|
|
//jointInfo->
|
|
|
|
}
|
2015-04-16 16:55:32 +00:00
|
|
|
}
|
2015-06-05 18:46:53 +00:00
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
//the maximal coordinates/iterative MLCP solver requires a smallish timestep to converge
|
|
|
|
m_dynamicsWorld->stepSimulation(deltaTime,10,1./240.);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
class CommonExampleInterface* ImportURDFCreateFunc(struct CommonExampleOptions& options)
|
2015-04-16 16:55:32 +00:00
|
|
|
{
|
|
|
|
|
2015-05-01 18:42:14 +00:00
|
|
|
return new ImportUrdfSetup(options.m_guiHelper, options.m_option,options.m_fileName);
|
2015-05-04 23:52:43 +00:00
|
|
|
}
|