2015-06-28 21:09:21 +00:00
|
|
|
#ifndef BULLET_URDF_IMPORTER_H
|
2018-09-23 21:17:31 +00:00
|
|
|
#define BULLET_URDF_IMPORTER_H
|
2015-04-22 23:35:27 +00:00
|
|
|
|
|
|
|
#include "URDFImporterInterface.h"
|
|
|
|
|
2018-01-17 20:48:48 +00:00
|
|
|
#include "UrdfRenderingInterface.h"
|
2016-05-20 01:37:15 +00:00
|
|
|
|
2017-10-08 01:50:23 +00:00
|
|
|
struct BulletURDFTexture
|
|
|
|
{
|
|
|
|
int m_width;
|
|
|
|
int m_height;
|
2017-10-25 15:15:01 +00:00
|
|
|
unsigned char* textureData1;
|
|
|
|
bool m_isCached;
|
2017-10-08 01:50:23 +00:00
|
|
|
};
|
|
|
|
|
2016-05-10 00:25:07 +00:00
|
|
|
///BulletURDFImporter can deal with URDF and (soon) SDF files
|
2015-06-28 21:09:21 +00:00
|
|
|
class BulletURDFImporter : public URDFImporterInterface
|
2015-04-22 23:35:27 +00:00
|
|
|
{
|
2015-06-28 21:09:21 +00:00
|
|
|
struct BulletURDFInternalData* m_data;
|
2015-04-22 23:35:27 +00:00
|
|
|
|
|
|
|
public:
|
2018-10-09 23:25:32 +00:00
|
|
|
BulletURDFImporter(struct GUIHelperInterface* helper, UrdfRenderingInterface* customConverter, struct CommonFileIOInterface* fileIO=0,double globalScaling=1, int flags=0);
|
2015-04-23 22:41:17 +00:00
|
|
|
|
2015-06-28 21:09:21 +00:00
|
|
|
virtual ~BulletURDFImporter();
|
2015-04-23 22:41:17 +00:00
|
|
|
|
2018-10-02 15:39:47 +00:00
|
|
|
virtual bool loadURDF(const char* fileName, bool forceFixedBase = false);
|
2015-04-23 22:41:17 +00:00
|
|
|
|
2017-08-15 17:46:09 +00:00
|
|
|
//warning: some quick test to load SDF: we 'activate' a model, so we can re-use URDF code path
|
|
|
|
virtual bool loadSDF(const char* fileName, bool forceFixedBase = false);
|
|
|
|
virtual int getNumModels() const;
|
|
|
|
virtual void activateModel(int modelIndex);
|
|
|
|
virtual void setBodyUniqueId(int bodyId);
|
|
|
|
virtual int getBodyUniqueId() const;
|
2015-04-23 22:41:17 +00:00
|
|
|
const char* getPathPrefix();
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
void printTree(); //for debugging
|
|
|
|
|
2015-04-23 22:41:17 +00:00
|
|
|
virtual int getRootLinkIndex() const;
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
virtual void getLinkChildIndices(int linkIndex, btAlignedObjectArray<int>& childLinkIndices) const;
|
|
|
|
|
2017-03-29 22:37:33 +00:00
|
|
|
virtual std::string getBodyName() const;
|
2015-04-22 23:35:27 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual std::string getLinkName(int linkIndex) const;
|
2015-11-07 01:11:15 +00:00
|
|
|
|
|
|
|
virtual bool getLinkColor(int linkIndex, btVector4& colorRGBA) const;
|
2016-07-11 07:26:40 +00:00
|
|
|
|
2017-06-01 19:32:44 +00:00
|
|
|
virtual bool getLinkColor2(int linkIndex, UrdfMaterialColor& matCol) const;
|
|
|
|
|
2018-05-23 03:26:00 +00:00
|
|
|
virtual void setLinkColor2(int linkIndex, struct UrdfMaterialColor& matCol) const;
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual bool getLinkContactInfo(int urdflinkIndex, URDFLinkContactInfo& contactInfo) const;
|
|
|
|
|
2017-05-01 18:14:09 +00:00
|
|
|
virtual bool getLinkAudioSource(int linkIndex, SDFAudioSource& audioSource) const;
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual std::string getJointName(int linkIndex) const;
|
2018-05-03 21:24:16 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void getMassAndInertia(int linkIndex, btScalar& mass, btVector3& localInertiaDiagonal, btTransform& inertialFrame) const;
|
|
|
|
virtual void getMassAndInertia2(int urdfLinkIndex, btScalar& mass, btVector3& localInertiaDiagonal, btTransform& inertialFrame, int flags) const;
|
2017-03-26 20:06:46 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual bool getJointInfo(int urdfLinkIndex, btTransform& parent2joint, btTransform& linkTransformInWorld, btVector3& jointAxisInJointSpace, int& jointType, btScalar& jointLowerLimit, btScalar& jointUpperLimit, btScalar& jointDamping, btScalar& jointFriction) const;
|
|
|
|
virtual bool getJointInfo2(int urdfLinkIndex, btTransform& parent2joint, btTransform& linkTransformInWorld, btVector3& jointAxisInJointSpace, int& jointType, btScalar& jointLowerLimit, btScalar& jointUpperLimit, btScalar& jointDamping, btScalar& jointFriction, btScalar& jointMaxForce, btScalar& jointMaxVelocity) const;
|
|
|
|
|
|
|
|
virtual bool getRootTransformInWorld(btTransform& rootTransformInWorld) const;
|
2017-06-03 17:57:56 +00:00
|
|
|
virtual void setRootTransformInWorld(const btTransform& rootTransformInWorld);
|
2015-04-22 23:35:27 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual int convertLinkVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& inertialFrame) const;
|
2016-06-01 05:55:13 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
virtual void convertLinkVisualShapes2(int linkIndex, int urdfIndex, const char* pathPrefix, const btTransform& inertialFrame, class btCollisionObject* colObj, int bodyUniqueId) const;
|
2015-04-22 23:35:27 +00:00
|
|
|
|
2017-08-24 16:16:11 +00:00
|
|
|
class btCollisionShape* convertURDFToCollisionShape(const struct UrdfCollision* collision, const char* urdfPathPrefix) const;
|
|
|
|
|
2018-01-08 20:25:56 +00:00
|
|
|
virtual int getUrdfFromCollisionShape(const btCollisionShape* collisionShape, UrdfCollision& collision) const;
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
///todo(erwincoumans) refactor this convertLinkCollisionShapes/memory allocation
|
|
|
|
|
2015-04-22 23:35:27 +00:00
|
|
|
virtual class btCompoundShape* convertLinkCollisionShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const;
|
2018-09-13 02:30:49 +00:00
|
|
|
|
|
|
|
virtual int getCollisionGroupAndMask(int linkIndex, int& colGroup, int& colMask) const;
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
virtual int getNumAllocatedCollisionShapes() const;
|
|
|
|
virtual class btCollisionShape* getAllocatedCollisionShape(int index);
|
2015-04-22 23:35:27 +00:00
|
|
|
|
2017-08-24 16:16:11 +00:00
|
|
|
virtual int getNumAllocatedMeshInterfaces() const;
|
|
|
|
virtual class btStridingMeshInterface* getAllocatedMeshInterface(int index);
|
|
|
|
|
2018-02-22 07:22:16 +00:00
|
|
|
virtual int getNumAllocatedTextures() const;
|
|
|
|
virtual int getAllocatedTexture(int index) const;
|
2018-09-23 21:17:31 +00:00
|
|
|
|
2017-10-06 20:46:24 +00:00
|
|
|
virtual void setEnableTinyRenderer(bool enable);
|
2018-10-14 19:54:34 +00:00
|
|
|
void convertURDFToVisualShapeInternal(const struct UrdfVisual* visual, const char* urdfPathPrefix, const class btTransform& visualTransform, btAlignedObjectArray<struct GLInstanceVertex>& verticesOut, btAlignedObjectArray<int>& indicesOut, btAlignedObjectArray<struct BulletURDFTexture>& texturesOut, struct b3ImportMeshData& meshData) const;
|
2015-04-22 23:35:27 +00:00
|
|
|
};
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
#endif //BULLET_URDF_IMPORTER_H
|