update pybullet quickstart quide PDF

hook up the loadMJCF importing MuJoCo xml files in pybullet and shared memory API b3LoadMJCFCommandInit
This commit is contained in:
Erwin Coumans
2016-12-31 14:43:15 -08:00
parent 63d3374c00
commit c940f0ec47
18 changed files with 288 additions and 138 deletions

View File

@@ -120,7 +120,10 @@ struct BulletMJCFImporterInternalData
btAlignedObjectArray<UrdfModel*> m_models;
int m_activeModel;
//those collision shapes are deleted by caller (todo: make sure this happens!)
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
BulletMJCFImporterInternalData()
:m_activeModel(-1)
{
@@ -794,7 +797,7 @@ bool BulletMJCFImporter::loadMJCF(const char* fileName, MJCFErrorLogger* logger,
m_data->m_pathPrefix[0] = 0;
if (!fileFound){
std::cerr << "URDF file not found" << std::endl;
std::cerr << "MJCF file not found" << std::endl;
return false;
} else
{
@@ -1017,6 +1020,8 @@ int BulletMJCFImporter::getBodyUniqueId() const
class btCompoundShape* BulletMJCFImporter::convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const
{
btCompoundShape* compound = new btCompoundShape();
m_data->m_allocatedCollisionShapes.push_back(compound);
const UrdfLink* link = m_data->getLink(m_data->m_activeModel,linkIndex);
if (link)
{
@@ -1075,6 +1080,7 @@ class btCompoundShape* BulletMJCFImporter::convertLinkCollisionShapes(int linkIn
}
if (childShape)
{
m_data->m_allocatedCollisionShapes.push_back(childShape);
compound->addChildShape(col->m_linkLocalFrame,childShape);
}
}
@@ -1082,6 +1088,15 @@ class btCompoundShape* BulletMJCFImporter::convertLinkCollisionShapes(int linkIn
return compound;
}
int BulletMJCFImporter::getNumAllocatedCollisionShapes() const
{
return m_data->m_allocatedCollisionShapes.size();
}
class btCollisionShape* BulletMJCFImporter::getAllocatedCollisionShape(int index)
{
return m_data->m_allocatedCollisionShapes[index];
}
int BulletMJCFImporter::getNumModels() const
{

View File

@@ -27,9 +27,6 @@ public:
virtual bool loadMJCF(const char* fileName, MJCFErrorLogger* logger, bool forceFixedBase = false);
int getNumModels() const;
void activateModel(int modelIndex);
virtual bool loadURDF(const char* fileName, bool forceFixedBase = false)
{
@@ -71,6 +68,10 @@ public:
virtual int getBodyUniqueId() const;
virtual class btCompoundShape* convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const ;
virtual int getNumAllocatedCollisionShapes() const;
virtual class btCollisionShape* getAllocatedCollisionShape(int index);
virtual int getNumModels() const;
virtual void activateModel(int modelIndex);
};

View File

@@ -77,7 +77,7 @@ struct ImportMJCFInternalData
ImportMJCFSetup::ImportMJCFSetup(struct GUIHelperInterface* helper, int option, const char* fileName)
:CommonMultiBodyBase(helper),
m_grav(-10),
m_grav(0),
m_upAxis(2)
{
m_data = new ImportMJCFInternalData;
@@ -238,7 +238,7 @@ void ImportMJCFSetup::initPhysics()
ConvertURDF2Bullet(importer,creation, rootTrans,m_dynamicsWorld,m_useMultiBody,importer.getPathPrefix(),CUF_USE_MJCF);
mb = creation.getBulletMultiBody();
if (mb)
if (0)//mb)
{
printf("first MJCF file converted!\n");
std::string* name = new std::string(importer.getLinkName(importer.getRootLinkIndex()));

View File

@@ -53,6 +53,12 @@ public:
virtual int getBodyUniqueId() const { return 0;}
virtual class btCompoundShape* convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const = 0;
virtual int getNumAllocatedCollisionShapes() const = 0;
virtual class btCollisionShape* getAllocatedCollisionShape(int index) = 0;
virtual int getNumModels() const=0;
virtual void activateModel(int modelIndex)=0;
};
#endif //URDF_IMPORTER_INTERFACE_H