fix windows build for b3ResourcePath
replace print -> b3Printf in URDF2Bullet.cpp
This commit is contained in:
@@ -234,7 +234,7 @@ void ImportUrdfSetup::initPhysics()
|
|||||||
|
|
||||||
//todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user
|
//todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user
|
||||||
int rootLinkIndex = u2b.getRootLinkIndex();
|
int rootLinkIndex = u2b.getRootLinkIndex();
|
||||||
printf("urdf root link index = %d\n",rootLinkIndex);
|
b3Printf("urdf root link index = %d\n",rootLinkIndex);
|
||||||
MyMultiBodyCreator creation(m_guiHelper);
|
MyMultiBodyCreator creation(m_guiHelper);
|
||||||
|
|
||||||
ConvertURDF2Bullet(u2b,creation, identityTrans,m_dynamicsWorld,m_useMultiBody,u2b.getPathPrefix());
|
ConvertURDF2Bullet(u2b,creation, identityTrans,m_dynamicsWorld,m_useMultiBody,u2b.getPathPrefix());
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "URDFImporterInterface.h"
|
#include "URDFImporterInterface.h"
|
||||||
#include "MultiBodyCreationInterface.h"
|
#include "MultiBodyCreationInterface.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "Bullet3Common/b3Logging.h"
|
||||||
|
|
||||||
static int bodyCollisionFilterGroup=btBroadphaseProxy::CharacterFilter;
|
static int bodyCollisionFilterGroup=btBroadphaseProxy::CharacterFilter;
|
||||||
static int bodyCollisionFilterMask=btBroadphaseProxy::AllFilter&(~btBroadphaseProxy::CharacterFilter);
|
static int bodyCollisionFilterMask=btBroadphaseProxy::AllFilter&(~btBroadphaseProxy::CharacterFilter);
|
||||||
static bool enableConstraints = true;
|
static bool enableConstraints = true;
|
||||||
@@ -41,11 +43,11 @@ void printTree(const URDFImporterInterface& u2b, int linkIndex, int indentationL
|
|||||||
u2b.getMassAndInertia(linkIndex,mass,localInertia,inertialFrame);
|
u2b.getMassAndInertia(linkIndex,mass,localInertia,inertialFrame);
|
||||||
std::string name = u2b.getLinkName(linkIndex);
|
std::string name = u2b.getLinkName(linkIndex);
|
||||||
for(int j=0;j<indentationLevel;j++)
|
for(int j=0;j<indentationLevel;j++)
|
||||||
printf(" "); //indent
|
b3Printf(" "); //indent
|
||||||
printf("link %s mass=%f\n",name.c_str(),mass);
|
b3Printf("link %s mass=%f\n",name.c_str(),mass);
|
||||||
for(int j=0;j<indentationLevel;j++)
|
for(int j=0;j<indentationLevel;j++)
|
||||||
printf(" "); //indent
|
b3Printf(" "); //indent
|
||||||
printf("local inertia:%f,%f,%f\n",localInertia[0],
|
b3Printf("local inertia:%f,%f,%f\n",localInertia[0],
|
||||||
localInertia[1],
|
localInertia[1],
|
||||||
localInertia[2]);
|
localInertia[2]);
|
||||||
|
|
||||||
@@ -62,8 +64,9 @@ void printTree(const URDFImporterInterface& u2b, int linkIndex, int indentationL
|
|||||||
std::string name = u2b.getLinkName(childLinkIndex);
|
std::string name = u2b.getLinkName(childLinkIndex);
|
||||||
|
|
||||||
|
|
||||||
for(int j=0;j<indentationLevel;j++) printf(" "); //indent
|
for(int j=0;j<indentationLevel;j++)
|
||||||
printf("child(%d).name=%s with childIndex=%d\n",(count++)+1, name.c_str(),childLinkIndex);
|
b3Printf(" "); //indent
|
||||||
|
b3Printf("child(%d).name=%s with childIndex=%d\n",(count++)+1, name.c_str(),childLinkIndex);
|
||||||
// first grandchild
|
// first grandchild
|
||||||
printTree(u2b,childLinkIndex,indentationLevel);
|
printTree(u2b,childLinkIndex,indentationLevel);
|
||||||
}
|
}
|
||||||
@@ -129,11 +132,11 @@ void ComputeTotalNumberOfJoints(const URDFImporterInterface& u2b, URDF2BulletCac
|
|||||||
{
|
{
|
||||||
btAlignedObjectArray<int> childIndices;
|
btAlignedObjectArray<int> childIndices;
|
||||||
u2b.getLinkChildIndices(linkIndex,childIndices);
|
u2b.getLinkChildIndices(linkIndex,childIndices);
|
||||||
printf("link %s has %d children\n", u2b.getLinkName(linkIndex).c_str(),childIndices.size());
|
//b3Printf("link %s has %d children\n", u2b.getLinkName(linkIndex).c_str(),childIndices.size());
|
||||||
for (int i=0;i<childIndices.size();i++)
|
//for (int i=0;i<childIndices.size();i++)
|
||||||
{
|
//{
|
||||||
printf("child %d has childIndex%d=%s\n",i,childIndices[i],u2b.getLinkName(childIndices[i]).c_str());
|
// b3Printf("child %d has childIndex%d=%s\n",i,childIndices[i],u2b.getLinkName(childIndices[i]).c_str());
|
||||||
}
|
//}
|
||||||
cache.m_totalNumJoints1 += childIndices.size();
|
cache.m_totalNumJoints1 += childIndices.size();
|
||||||
for (int i=0;i<childIndices.size();i++)
|
for (int i=0;i<childIndices.size();i++)
|
||||||
{
|
{
|
||||||
@@ -179,7 +182,7 @@ void InitURDF2BulletCache(const URDFImporterInterface& u2b, URDF2BulletCachedDat
|
|||||||
|
|
||||||
void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreationInterface& creation, URDF2BulletCachedData& cache, int urdfLinkIndex, const btTransform& parentTransformInWorldSpace, btMultiBodyDynamicsWorld* world1,bool createMultiBody, const char* pathPrefix)
|
void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreationInterface& creation, URDF2BulletCachedData& cache, int urdfLinkIndex, const btTransform& parentTransformInWorldSpace, btMultiBodyDynamicsWorld* world1,bool createMultiBody, const char* pathPrefix)
|
||||||
{
|
{
|
||||||
printf("start converting/extracting data from URDF interface\n");
|
b3Printf("start converting/extracting data from URDF interface\n");
|
||||||
|
|
||||||
btTransform linkTransformInWorldSpace;
|
btTransform linkTransformInWorldSpace;
|
||||||
linkTransformInWorldSpace.setIdentity();
|
linkTransformInWorldSpace.setIdentity();
|
||||||
@@ -192,8 +195,8 @@ void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreat
|
|||||||
btRigidBody* parentRigidBody = 0;
|
btRigidBody* parentRigidBody = 0;
|
||||||
|
|
||||||
std::string name = u2b.getLinkName(urdfLinkIndex);
|
std::string name = u2b.getLinkName(urdfLinkIndex);
|
||||||
printf("link name=%s urdf link index=%d\n",name.c_str(),urdfLinkIndex);
|
b3Printf("link name=%s urdf link index=%d\n",name.c_str(),urdfLinkIndex);
|
||||||
printf("mb link index = %d\n",mbLinkIndex);
|
b3Printf("mb link index = %d\n",mbLinkIndex);
|
||||||
|
|
||||||
btTransform parentLocalInertialFrame;
|
btTransform parentLocalInertialFrame;
|
||||||
parentLocalInertialFrame.setIdentity();
|
parentLocalInertialFrame.setIdentity();
|
||||||
@@ -202,11 +205,11 @@ void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreat
|
|||||||
|
|
||||||
if (urdfParentIndex==-2)
|
if (urdfParentIndex==-2)
|
||||||
{
|
{
|
||||||
printf("root link has no parent\n");
|
b3Printf("root link has no parent\n");
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
printf("urdf parent index = %d\n",urdfParentIndex);
|
b3Printf("urdf parent index = %d\n",urdfParentIndex);
|
||||||
printf("mb parent index = %d\n",mbParentIndex);
|
b3Printf("mb parent index = %d\n",mbParentIndex);
|
||||||
parentRigidBody = cache.getRigidBodyFromLink(urdfParentIndex);
|
parentRigidBody = cache.getRigidBodyFromLink(urdfParentIndex);
|
||||||
u2b.getMassAndInertia(urdfParentIndex, parentMass,parentLocalInertiaDiagonal,parentLocalInertialFrame);
|
u2b.getMassAndInertia(urdfParentIndex, parentMass,parentLocalInertiaDiagonal,parentLocalInertialFrame);
|
||||||
|
|
||||||
@@ -302,7 +305,7 @@ void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreat
|
|||||||
{
|
{
|
||||||
//todo: adjust the center of mass transform and pivot axis properly
|
//todo: adjust the center of mass transform and pivot axis properly
|
||||||
|
|
||||||
printf("Fixed joint (btMultiBody)\n");
|
b3Printf("Fixed joint (btMultiBody)\n");
|
||||||
btQuaternion rot = offsetInA.inverse().getRotation();//parent2joint.inverse().getRotation();
|
btQuaternion rot = offsetInA.inverse().getRotation();//parent2joint.inverse().getRotation();
|
||||||
cache.m_bulletMultiBody->setupFixed(mbLinkIndex, mass, localInertiaDiagonal, mbParentIndex,
|
cache.m_bulletMultiBody->setupFixed(mbLinkIndex, mass, localInertiaDiagonal, mbParentIndex,
|
||||||
rot*offsetInB.getRotation(), offsetInA.getOrigin(),-offsetInB.getOrigin(),disableParentCollision);
|
rot*offsetInB.getRotation(), offsetInA.getOrigin(),-offsetInB.getOrigin(),disableParentCollision);
|
||||||
@@ -311,7 +314,7 @@ void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreat
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
printf("Fixed joint\n");
|
b3Printf("Fixed joint\n");
|
||||||
|
|
||||||
btGeneric6DofSpring2Constraint* dof6 = creation.createFixedJoint(urdfLinkIndex,*parentRigidBody, *linkRigidBody, offsetInA, offsetInB);
|
btGeneric6DofSpring2Constraint* dof6 = creation.createFixedJoint(urdfLinkIndex,*parentRigidBody, *linkRigidBody, offsetInA, offsetInB);
|
||||||
|
|
||||||
@@ -340,7 +343,7 @@ void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreat
|
|||||||
|
|
||||||
if (enableConstraints)
|
if (enableConstraints)
|
||||||
world1->addConstraint(dof6,true);
|
world1->addConstraint(dof6,true);
|
||||||
printf("Revolute/Continuous joint\n");
|
b3Printf("Revolute/Continuous joint\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -368,13 +371,13 @@ void ConvertURDF2BulletInternal(const URDFImporterInterface& u2b, MultiBodyCreat
|
|||||||
if (enableConstraints)
|
if (enableConstraints)
|
||||||
world1->addConstraint(dof6,true);
|
world1->addConstraint(dof6,true);
|
||||||
|
|
||||||
printf("Prismatic\n");
|
b3Printf("Prismatic\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
printf("Error: unsupported joint type in URDF (%d)\n", jointType);
|
b3Printf("Error: unsupported joint type in URDF (%d)\n", jointType);
|
||||||
btAssert(0);
|
btAssert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
|
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
|
||||||
#else
|
#else
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <Windows.h>
|
||||||
#else
|
#else
|
||||||
//not Mac, not Windows, let's cross the fingers it is Linux :-)
|
//not Mac, not Windows, let's cross the fingers it is Linux :-)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -31,8 +32,11 @@ int b3ResourcePath::getExePath(char* path, int maxPathLenInBytes)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#error not yet
|
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197(v=vs.85).aspx
|
||||||
|
HMODULE hModule = GetModuleHandle(NULL);
|
||||||
|
numBytes = GetModuleFileName(hModule, path, maxPathLenInBytes);
|
||||||
#else
|
#else
|
||||||
|
///http://stackoverflow.com/questions/933850/how-to-find-the-location-of-the-executable-in-c
|
||||||
numBytes = (int)readlink("/proc/self/exe", path, maxPathLenInBytes-1);
|
numBytes = (int)readlink("/proc/self/exe", path, maxPathLenInBytes-1);
|
||||||
if (numBytes > 0)
|
if (numBytes > 0)
|
||||||
{
|
{
|
||||||
@@ -60,12 +64,19 @@ int b3ResourcePath::findResourcePath(const char* resourceName, char* resourcePat
|
|||||||
int exeNamePos = b3FileUtils::extractPath(exePath,pathToExe,B3_MAX_EXE_PATH_LEN);
|
int exeNamePos = b3FileUtils::extractPath(exePath,pathToExe,B3_MAX_EXE_PATH_LEN);
|
||||||
if (exeNamePos)
|
if (exeNamePos)
|
||||||
{
|
{
|
||||||
sprintf(resourcePath,"%s../resources/%s/%s",pathToExe,&exePath[exeNamePos],resourceName);
|
sprintf(resourcePath,"%s../data/%s",pathToExe,resourceName);
|
||||||
//printf("try resource at %s\n", resourcePath);
|
//printf("try resource at %s\n", resourcePath);
|
||||||
if (b3FileUtils::findFile(resourcePath, resourcePath, resourcePathMaxNumBytes))
|
if (b3FileUtils::findFile(resourcePath, resourcePath, resourcePathMaxNumBytes))
|
||||||
{
|
{
|
||||||
return strlen(resourcePath);
|
return strlen(resourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprintf(resourcePath,"%s../resources/%s/%s",pathToExe,&exePath[exeNamePos],resourceName);
|
||||||
|
//printf("try resource at %s\n", resourcePath);
|
||||||
|
if (b3FileUtils::findFile(resourcePath, resourcePath, resourcePathMaxNumBytes))
|
||||||
|
{
|
||||||
|
return strlen(resourcePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user