Merge branch 'master' into 3D-NN-walkers-example

This commit is contained in:
Benelot
2017-05-28 15:10:45 +02:00
895 changed files with 953183 additions and 13171 deletions

View File

@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 2.4.3)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
cmake_policy(SET CMP0017 NEW)
#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
SET(MSVC_INCREMENTAL_DEFAULT ON)
PROJECT(BULLET_PHYSICS)
SET(BULLET_VERSION 2.85)
FILE (STRINGS "VERSION" BULLET_VERSION)
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
@@ -27,7 +27,7 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF)
OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF)
OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" OFF)
OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" OFF)
OPTION(BULLET2_USE_THREAD_LOCKS "Build Bullet 2 libraries with mutex locking around certain operations" OFF)
OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF)
@@ -85,15 +85,60 @@ IF(MSVC)
ADD_DEFINITIONS(-D_WIN64)
ELSE()
OPTION(USE_MSVC_SSE "Use MSVC /arch:sse option" ON)
option(USE_MSVC_SSE2 "Compile your program with SSE2 instructions" ON)
IF (USE_MSVC_SSE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
ENDIF()
IF (USE_MSVC_SSE2)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
ENDIF()
ENDIF()
option(USE_MSVC_AVX "Compile your program with AVX instructions" OFF)
IF(USE_MSVC_AVX)
add_definitions(/arch:AVX)
ENDIF()
OPTION(USE_MSVC_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF (USE_MSVC_FAST_FLOATINGPOINT)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
ENDIF()
OPTION(USE_MSVC_STRING_POOLING "Use MSVC /GF string pooling option" ON)
IF (USE_MSVC_STRING_POOLING)
SET(CMAKE_C_FLAGS "/GF ${CMAKE_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "/GF ${CMAKE_CXX_FLAGS}")
ENDIF()
OPTION(USE_MSVC_FUNCTION_LEVEL_LINKING "Use MSVC /Gy function level linking option" ON)
IF(USE_MSVC_FUNCTION_LEVEL_LINKING)
SET(CMAKE_C_FLAGS "/Gy ${CMAKE_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "/Gy ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF")
ENDIF(USE_MSVC_FUNCTION_LEVEL_LINKING)
OPTION(USE_MSVC_EXEPTIONS "Use MSVC C++ exceptions option" OFF)
OPTION(USE_MSVC_COMDAT_FOLDING "Use MSVC /OPT:ICF COMDAT folding option" ON)
IF(USE_MSVC_COMDAT_FOLDING)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:ICF")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:ICF")
ENDIF()
OPTION(USE_MSVC_DISABLE_RTTI "Use MSVC /GR- disabled RTTI flags option" ON)
IF(USE_MSVC_DISABLE_RTTI)
STRING(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI
SET(CMAKE_C_FLAGS "/GR- ${CMAKE_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "/GR- ${CMAKE_CXX_FLAGS}")
ENDIF(USE_MSVC_DISABLE_RTTI)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267")
ENDIF(MSVC)
@@ -209,18 +254,39 @@ ENDIF()
OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON)
OPTION(BUILD_PYBULLET "Set when you want to build pybullet (experimental Python bindings for Bullet)" OFF)
# Optional Python configuration
# builds pybullet automatically if all the requirements are met
SET(PYTHON_VERSION_PYBULLET "2.7" CACHE STRING "Python version pybullet will use.")
SET(Python_ADDITIONAL_VERSIONS 2.7 2.7.3 3 3.0 3.1 3.2 3.3 3.4 3.5 3.6)
SET_PROPERTY(CACHE PYTHON_VERSION_PYBULLET PROPERTY STRINGS ${Python_ADDITIONAL_VERSIONS})
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build3/cmake ${CMAKE_MODULE_PATH})
OPTION(EXACT_PYTHON_VERSION "Require Python and match PYTHON_VERSION_PYBULLET exactly, e.g. 2.7.3" OFF)
IF(EXACT_PYTHON_VERSION)
set(EXACT_PYTHON_VERSION_FLAG EXACT REQUIRED)
ENDIF(EXACT_PYTHON_VERSION)
# first find the python interpreter
FIND_PACKAGE(PythonInterp ${PYTHON_VERSION_PYBULLET} ${EXACT_PYTHON_VERSION_FLAG})
# python library should exactly match that of the interpreter
FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
SET(DEFAULT_BUILD_PYBULLET OFF)
IF(PYTHONLIBS_FOUND)
SET(DEFAULT_BUILD_PYBULLET ON)
ENDIF(PYTHONLIBS_FOUND)
OPTION(BUILD_PYBULLET "Set when you want to build pybullet (Python bindings for Bullet)" ${DEFAULT_BUILD_PYBULLET})
OPTION(BUILD_ENET "Set when you want to build apps with enet UDP networking support" ON)
OPTION(BUILD_CLSOCKET "Set when you want to build apps with enet TCP networking support" ON)
IF(BUILD_PYBULLET)
FIND_PACKAGE(PythonLibs)
OPTION(BUILD_PYBULLET_NUMPY "Set when you want to build pybullet with NumPy support" OFF)
OPTION(BUILD_PYBULLET_NUMPY "Set when you want to build pybullet with NumPy support" ON)
OPTION(BUILD_PYBULLET_ENET "Set when you want to build pybullet with enet UDP networking support" ON)
IF(BUILD_PYBULLET_NUMPY)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/build3/cmake)
OPTION(BUILD_PYBULLET_CLSOCKET "Set when you want to build pybullet with enet TCP networking support" ON)
OPTION(BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK "Set when you want to use the Python Framework on Mac" OFF)
IF(BUILD_PYBULLET_NUMPY)
#include(FindNumPy)
FIND_PACKAGE(NumPy)
if (PYTHON_NUMPY_FOUND)
@@ -230,13 +296,25 @@ IF(BUILD_PYBULLET)
message("NumPy not found")
endif()
ENDIF()
OPTION(BUILD_PYBULLET "Set when you want to build pybullet (experimental Python bindings for Bullet)" OFF)
IF(WIN32)
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Shared Libs" FORCE)
ELSE(WIN32)
SET(BUILD_SHARED_LIBS ON CACHE BOOL "Shared Libs" FORCE)
ENDIF(WIN32)
IF(APPLE)
OPTION(BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK "Set when you want to use the Python Framework on Mac" ON)
IF(NOT BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK)
add_definitions(-DB3_NO_PYTHON_FRAMEWORK)
ENDIF(NOT BUILD_PYBULLET_MAC_USE_PYTHON_FRAMEWORK)
OPTION(BUILD_PYBULLET_SHOW_PY_VERSION "Set when you want to show the PY_MAJOR_VERSION and PY_MAJOR_VERSION using #pragme message." OFF)
IF(BUILD_PYBULLET_SHOW_PY_VERSION)
add_definitions(-DB3_DUMP_PYTHON_VERSION)
ENDIF()
ENDIF(APPLE)
ENDIF(BUILD_PYBULLET)
IF(BUILD_BULLET3)

View File

@@ -1,4 +1,4 @@
SUBDIRS( Serialize ConvexDecomposition HACD GIMPACTUtils )
SUBDIRS( obj2sdf Serialize ConvexDecomposition HACD GIMPACTUtils )
IF(BUILD_BULLET3)
SUBDIRS( InverseDynamics)

View File

@@ -12,9 +12,9 @@ unsigned int MAXDEPTH = 8 ;
float CONCAVE_PERCENT = 1.0f ;
float MERGE_PERCENT = 2.0f ;
CHull::CHull(const ConvexResult &result)
CHull::CHull(const ConvexDecomposition::ConvexResult &result)
{
mResult = new ConvexResult(result);
mResult = new ConvexDecomposition::ConvexResult(result);
mVolume = computeMeshVolume( result.mHullVertices, result.mHullTcount, result.mHullIndices );
mDiagonal = getBoundingRegion( result.mHullVcount, result.mHullVertices, sizeof(float)*3, mMin, mMax );
@@ -81,7 +81,7 @@ bool ConvexBuilder::isDuplicate(unsigned int i1,unsigned int i2,unsigned int i3,
return dcount == 3;
}
void ConvexBuilder::getMesh(const ConvexResult &cr,VertexLookup vc,UintVector &indices)
void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr,VertexLookup vc,UintVector &indices)
{
unsigned int *src = cr.mHullIndices;
@@ -154,19 +154,19 @@ CHull * ConvexBuilder::canMerge(CHull *a,CHull *b)
return 0;
}
HullResult hresult;
HullLibrary hl;
HullDesc desc;
ConvexDecomposition::HullResult hresult;
ConvexDecomposition::HullLibrary hl;
ConvexDecomposition::HullDesc desc;
desc.SetHullFlag(QF_TRIANGLES);
desc.SetHullFlag(ConvexDecomposition::QF_TRIANGLES);
desc.mVcount = vcount;
desc.mVertices = vertices;
desc.mVertexStride = sizeof(float)*3;
HullError hret = hl.CreateConvexHull(desc,hresult);
ConvexDecomposition::HullError hret = hl.CreateConvexHull(desc,hresult);
if ( hret == QE_OK )
if ( hret == ConvexDecomposition::QE_OK )
{
float combineVolume = computeMeshVolume( hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices );
@@ -175,7 +175,7 @@ CHull * ConvexBuilder::canMerge(CHull *a,CHull *b)
float percent = (sumVolume*100) / combineVolume;
if ( percent >= (100.0f-MERGE_PERCENT) )
{
ConvexResult cr(hresult.mNumOutputVertices, hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
ConvexDecomposition::ConvexResult cr(hresult.mNumOutputVertices, hresult.mOutputVertices, hresult.mNumFaces, hresult.mIndices);
ret = new CHull(cr);
}
}
@@ -259,7 +259,7 @@ bool ConvexBuilder::combineHulls(void)
return combine;
}
unsigned int ConvexBuilder::process(const DecompDesc &desc)
unsigned int ConvexBuilder::process(const ConvexDecomposition::DecompDesc &desc)
{
unsigned int ret = 0;
@@ -282,13 +282,13 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc)
// before we hand it back to the application, we need to regenerate the hull based on the
// limits given by the user.
const ConvexResult &c = *cr->mResult; // the high resolution hull...
const ConvexDecomposition::ConvexResult &c = *cr->mResult; // the high resolution hull...
HullResult result;
HullLibrary hl;
HullDesc hdesc;
ConvexDecomposition::HullResult result;
ConvexDecomposition::HullLibrary hl;
ConvexDecomposition::HullDesc hdesc;
hdesc.SetHullFlag(QF_TRIANGLES);
hdesc.SetHullFlag(ConvexDecomposition::QF_TRIANGLES);
hdesc.mVcount = c.mHullVcount;
hdesc.mVertices = c.mHullVertices;
@@ -298,14 +298,14 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc)
if ( desc.mSkinWidth )
{
hdesc.mSkinWidth = desc.mSkinWidth;
hdesc.SetHullFlag(QF_SKIN_WIDTH); // do skin width computation.
hdesc.SetHullFlag(ConvexDecomposition::QF_SKIN_WIDTH); // do skin width computation.
}
HullError ret = hl.CreateConvexHull(hdesc,result);
ConvexDecomposition::HullError ret = hl.CreateConvexHull(hdesc,result);
if ( ret == QE_OK )
if ( ret == ConvexDecomposition::QE_OK )
{
ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
ConvexDecomposition::ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);
r.mHullVolume = computeMeshVolume( result.mOutputVertices, result.mNumFaces, result.mIndices ); // the volume of the hull.
@@ -358,7 +358,7 @@ void ConvexBuilder::ConvexDebugBound(const float *bmin,const float *bmax,unsigne
mCallback->ConvexDebugBound(bmin,bmax,color);
}
void ConvexBuilder::ConvexDecompResult(ConvexResult &result)
void ConvexBuilder::ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
{
CHull *ch = new CHull(result);
mChulls.push_back(ch);

View File

@@ -40,13 +40,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vlookup.h"
#include "LinearMath/btAlignedObjectArray.h"
using namespace ConvexDecomposition;
class CHull
{
public:
CHull(const ConvexResult &result);
CHull(const ConvexDecomposition::ConvexResult &result);
~CHull(void);
@@ -56,7 +54,7 @@ public:
float mMax[3];
float mVolume;
float mDiagonal; // long edge..
ConvexResult *mResult;
ConvexDecomposition::ConvexResult *mResult;
};
// Usage: std::sort( list.begin(), list.end(), StringSortRef() );
@@ -75,23 +73,23 @@ typedef btAlignedObjectArray< CHull * > CHullVector;
class ConvexBuilder : public ConvexDecompInterface
class ConvexBuilder : public ConvexDecomposition::ConvexDecompInterface
{
public:
ConvexBuilder(ConvexDecompInterface *callback);
ConvexBuilder(ConvexDecomposition::ConvexDecompInterface *callback);
virtual ~ConvexBuilder(void);
bool isDuplicate(unsigned int i1,unsigned int i2,unsigned int i3,
unsigned int ci1,unsigned int ci2,unsigned int ci3);
void getMesh(const ConvexResult &cr,VertexLookup vc,UintVector &indices);
void getMesh(const ConvexDecomposition::ConvexResult &cr,VertexLookup vc,UintVector &indices);
CHull * canMerge(CHull *a,CHull *b);
bool combineHulls(void);
unsigned int process(const DecompDesc &desc);
unsigned int process(const ConvexDecomposition::DecompDesc &desc);
virtual void ConvexDebugTri(const float *p1,const float *p2,const float *p3,unsigned int color);
@@ -100,7 +98,7 @@ public:
virtual void ConvexDebugBound(const float *bmin,const float *bmax,unsigned int color);
virtual void ConvexDecompResult(ConvexResult &result);
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result);
void sortChulls(CHullVector &hulls);

View File

@@ -705,6 +705,7 @@ float computeConcavity(unsigned int vcount,
}
}
#if 0
if ( ftris.size() && 0 )
{
@@ -725,17 +726,17 @@ float computeConcavity(unsigned int vcount,
do
{
found = false;
CTriVector::iterator i;
for (i=ftris.begin(); i!=ftris.end(); ++i)
{
CTri &t = (*i);
if ( isFeatureTri(t,flist,maxc,callback,color) )
{
found = true;
totalarea+=t.area();
}
}
found = false;
CTriVector::iterator i;
for (i=ftris.begin(); i!=ftris.end(); ++i)
{
CTri &t = (*i);
if ( isFeatureTri(t,flist,maxc,callback,color) )
{
found = true;
totalarea+=t.area();
}
}
} while ( found );
@@ -759,6 +760,7 @@ float computeConcavity(unsigned int vcount,
}
}
}
}
unsigned int color = getDebugColor();
@@ -786,7 +788,7 @@ float computeConcavity(unsigned int vcount,
hl.ReleaseResult(result);
}
#endif
return cret;
}

View File

@@ -63,7 +63,7 @@ vec3 randomAxis() {
axis(1) = randomFloat(-1.0, 1.0);
axis(2) = randomFloat(-1.0, 1.0);
length = std::sqrt(std::pow(axis(0), 2) + std::pow(axis(1), 2) + std::pow(axis(2), 2));
length = BT_ID_SQRT(BT_ID_POW(axis(0), 2) + BT_ID_POW(axis(1), 2) + BT_ID_POW(axis(2), 2));
} while (length < 0.01);
return axis / length;

View File

@@ -172,7 +172,7 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
printf("bt:ddot_q[%d]= %f, id:ddot_q= %e, diff= %e\n", i, joint_accel[i],
dot_u(i + dot_u_offset), joint_accel[i] - dot_u(i));
}
*acc_error += std::pow(joint_accel[i] - dot_u(i + dot_u_offset), 2);
*acc_error += BT_ID_POW(joint_accel[i] - dot_u(i + dot_u_offset), 2);
}
} else {
vec3 base_dot_omega;
@@ -196,14 +196,14 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
printf("bt::base_dot_omega(%d)= %e dot_u[%d]= %e, diff= %e\n", i, base_dot_omega(i),
i, dot_u[i], base_dot_omega(i) - dot_u[i]);
}
*acc_error += std::pow(base_dot_omega(i) - dot_u(i), 2);
*acc_error += BT_ID_POW(base_dot_omega(i) - dot_u(i), 2);
}
for (int i = 0; i < 3; i++) {
if (verbose) {
printf("bt::base_ddot_com(%d)= %e dot_u[%d]= %e, diff= %e\n", i, base_ddot_com(i),
i, dot_u[i + 3], base_ddot_com(i) - dot_u[i + 3]);
}
*acc_error += std::pow(base_ddot_com(i) - dot_u(i + 3), 2);
*acc_error += BT_ID_POW(base_ddot_com(i) - dot_u(i + 3), 2);
}
for (int i = 0; i < btmb->getNumDofs(); i++) {
@@ -211,7 +211,7 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
printf("bt:ddot_q[%d]= %f, id:ddot_q= %e, diff= %e\n", i, joint_accel[i],
dot_u(i + 6), joint_accel[i] - dot_u(i + 6));
}
*acc_error += std::pow(joint_accel[i] - dot_u(i + 6), 2);
*acc_error += BT_ID_POW(joint_accel[i] - dot_u(i + 6), 2);
}
}
*acc_error = std::sqrt(*acc_error);
@@ -288,12 +288,12 @@ int compareInverseAndForwardDynamics(vecx &q, vecx &u, vecx &dot_u, btVector3 &g
diff_basis(1, 2), diff_basis(2, 0), diff_basis(2, 1), diff_basis(2, 2));
}
double total_pos_err =
std::sqrt(std::pow(diff_com(0), 2) + std::pow(diff_com(1), 2) +
std::pow(diff_com(2), 2) + std::pow(diff_basis(0, 0), 2) +
std::pow(diff_basis(0, 1), 2) + std::pow(diff_basis(0, 2), 2) +
std::pow(diff_basis(1, 0), 2) + std::pow(diff_basis(1, 1), 2) +
std::pow(diff_basis(1, 2), 2) + std::pow(diff_basis(2, 0), 2) +
std::pow(diff_basis(2, 1), 2) + std::pow(diff_basis(2, 2), 2));
BT_ID_SQRT(BT_ID_POW(diff_com(0), 2) + BT_ID_POW(diff_com(1), 2) +
BT_ID_POW(diff_com(2), 2) + BT_ID_POW(diff_basis(0, 0), 2) +
BT_ID_POW(diff_basis(0, 1), 2) + BT_ID_POW(diff_basis(0, 2), 2) +
BT_ID_POW(diff_basis(1, 0), 2) + BT_ID_POW(diff_basis(1, 1), 2) +
BT_ID_POW(diff_basis(1, 2), 2) + BT_ID_POW(diff_basis(2, 0), 2) +
BT_ID_POW(diff_basis(2, 1), 2) + BT_ID_POW(diff_basis(2, 2), 2));
if (verbose) {
printf("======kin-pos-err: %e\n", total_pos_err);
}

View File

@@ -1368,6 +1368,10 @@ typedef struct bInvalidHandle {
double m_jointTorque[6];
double m_jointDamping;
double m_jointFriction;
double m_jointLowerLimit;
double m_jointUpperLimit;
double m_jointMaxForce;
double m_jointMaxVelocity;
char *m_linkName;
char *m_jointName;
btCollisionObjectDoubleData *m_linkCollider;
@@ -1395,6 +1399,10 @@ typedef struct bInvalidHandle {
int m_posVarCount;
float m_jointDamping;
float m_jointFriction;
float m_jointLowerLimit;
float m_jointUpperLimit;
float m_jointMaxForce;
float m_jointMaxVelocity;
char *m_linkName;
char *m_jointName;
btCollisionObjectFloatData *m_linkCollider;

View File

@@ -349,7 +349,8 @@ static int name_is_array(char* name, int* dim1, int* dim2) {
void bDNA::init(char *data, int len, bool swap)
{
int *intPtr=0;short *shtPtr=0;
char *cp = 0;int dataLen =0;long nr=0;
char *cp = 0;int dataLen =0;
//long nr=0;
intPtr = (int*)data;
/*

View File

@@ -75,7 +75,8 @@ bFile::bFile(const char *filename, const char headerString[7])
fseek(fp, 0L, SEEK_SET);
mFileBuffer = (char*)malloc(mFileLen+1);
fread(mFileBuffer, mFileLen, 1, fp);
size_t bytesRead;
bytesRead = fread(mFileBuffer, mFileLen, 1, fp);
fclose(fp);
@@ -411,7 +412,7 @@ void bFile::swapDNA(char* ptr)
// void bDNA::init(char *data, int len, bool swap)
int *intPtr=0;short *shtPtr=0;
char *cp = 0;int dataLen =0;long nr=0;
char *cp = 0;int dataLen =0;
intPtr = (int*)data;
/*
@@ -573,7 +574,7 @@ void bFile::writeFile(const char* fileName)
void bFile::preSwap()
{
const bool brokenDNA = (mFlags&FD_BROKEN_DNA)!=0;
//const bool brokenDNA = (mFlags&FD_BROKEN_DNA)!=0;
//FD_ENDIAN_SWAP
//byte 8 determines the endianness of the file, little (v) versus big (V)
int littleEndian= 1;
@@ -1285,7 +1286,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
}
//skip the *
printf("<%s type=\"pointer\"> ",&memName[1]);
printf("%d ", array[a]);
printf("%p ", array[a]);
printf("</%s>\n",&memName[1]);
}
@@ -1303,7 +1304,7 @@ int bFile::resolvePointersStructRecursive(char *strcPtr, int dna_nr, int verbose
printf(" ");
}
printf("<%s type=\"pointer\"> ",&memName[1]);
printf("%d ", ptr);
printf("%p ", ptr);
printf("</%s>\n",&memName[1]);
}
ptr = findLibPointer(ptr);
@@ -1484,7 +1485,7 @@ void bFile::resolvePointers(int verboseMode)
char* oldType = fileDna->getType(oldStruct[0]);
if (verboseMode & FD_VERBOSE_EXPORT_XML)
printf(" <%s pointer=%d>\n",oldType,dataChunk.oldPtr);
printf(" <%s pointer=%p>\n",oldType,dataChunk.oldPtr);
resolvePointersChunk(dataChunk, verboseMode);

View File

@@ -307,8 +307,6 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
for (i=0;i<bulletFile2->m_constraints.size();i++)
{
btTypedConstraintData2* constraintData = (btTypedConstraintData2*)bulletFile2->m_constraints[i];
btTypedConstraintFloatData* singleC = (btTypedConstraintFloatData*)bulletFile2->m_constraints[i];
btTypedConstraintDoubleData* doubleC = (btTypedConstraintDoubleData*)bulletFile2->m_constraints[i];
btCollisionObject** colAptr = m_bodyMap.find(constraintData->m_rbA);
btCollisionObject** colBptr = m_bodyMap.find(constraintData->m_rbB);

View File

@@ -468,14 +468,11 @@ btCollisionShape* btWorldImporter::convertCollisionShape( btCollisionShapeData*
btCompoundShapeData* compoundData = (btCompoundShapeData*)shapeData;
btCompoundShape* compoundShape = createCompoundShape();
btCompoundShapeChildData* childShapeDataArray = &compoundData->m_childShapePtr[0];
btAlignedObjectArray<btCollisionShape*> childShapes;
for (int i=0;i<compoundData->m_numChildShapes;i++)
{
btCompoundShapeChildData* ptr = &compoundData->m_childShapePtr[i];
btCollisionShapeData* cd = compoundData->m_childShapePtr[i].m_childShape;
btCollisionShape* childShape = convertCollisionShape(cd);
@@ -997,11 +994,11 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra
dof->setStiffness(i,dofData->m_linearSpringStiffness.m_floats[i],dofData->m_linearSpringStiffnessLimited[i]!=0);
dof->setEquilibriumPoint(i,dofData->m_linearEquilibriumPoint.m_floats[i]);
dof->enableSpring(i,dofData->m_linearEnableSpring[i]!=0);
dof->setDamping(i,dofData->m_linearSpringDamping.m_floats[i],dofData->m_linearSpringDampingLimited[i]);
dof->setDamping(i,dofData->m_linearSpringDamping.m_floats[i],(dofData->m_linearSpringDampingLimited[i]!=0));
}
for (i=0;i<3;i++)
{
dof->setStiffness(i+3,dofData->m_angularSpringStiffness.m_floats[i],dofData->m_angularSpringStiffnessLimited[i]);
dof->setStiffness(i+3,dofData->m_angularSpringStiffness.m_floats[i],(dofData->m_angularSpringStiffnessLimited[i]!=0));
dof->setEquilibriumPoint(i+3,dofData->m_angularEquilibriumPoint.m_floats[i]);
dof->enableSpring(i+3,dofData->m_angularEnableSpring[i]!=0);
dof->setDamping(i+3,dofData->m_angularSpringDamping.m_floats[i],dofData->m_angularSpringDampingLimited[i]);
@@ -1327,14 +1324,14 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const
dof->setStiffness(i,dofData->m_linearSpringStiffness.m_floats[i],dofData->m_linearSpringStiffnessLimited[i]);
dof->setEquilibriumPoint(i,dofData->m_linearEquilibriumPoint.m_floats[i]);
dof->enableSpring(i,dofData->m_linearEnableSpring[i]!=0);
dof->setDamping(i,dofData->m_linearSpringDamping.m_floats[i],dofData->m_linearSpringDampingLimited[i]);
dof->setDamping(i,dofData->m_linearSpringDamping.m_floats[i],(dofData->m_linearSpringDampingLimited[i]!=0));
}
for (i=0;i<3;i++)
{
dof->setStiffness(i+3,dofData->m_angularSpringStiffness.m_floats[i],dofData->m_angularSpringStiffnessLimited[i]);
dof->setStiffness(i+3,dofData->m_angularSpringStiffness.m_floats[i],(dofData->m_angularSpringStiffnessLimited[i]!=0));
dof->setEquilibriumPoint(i+3,dofData->m_angularEquilibriumPoint.m_floats[i]);
dof->enableSpring(i+3,dofData->m_angularEnableSpring[i]!=0);
dof->setDamping(i+3,dofData->m_angularSpringDamping.m_floats[i],dofData->m_angularSpringDampingLimited[i]);
dof->setDamping(i+3,dofData->m_angularSpringDamping.m_floats[i],(dofData->m_angularSpringDampingLimited[i]!=0));
}
}

View File

@@ -18,6 +18,16 @@ subject to the following restrictions:
#include "btBulletDynamicsCommon.h"
#include "string_split.h"
struct MyLocalCaster
{
void* m_ptr;
int m_int;
MyLocalCaster()
:m_ptr(0)
{
}
};
btBulletXmlWorldImporter::btBulletXmlWorldImporter(btDynamicsWorld* world)
:btWorldImporter(world),
@@ -32,7 +42,7 @@ btBulletXmlWorldImporter::~btBulletXmlWorldImporter()
}
#if 0
static int get_double_attribute_by_name(const TiXmlElement* pElement, const char* attribName,double* value)
{
if ( !pElement )
@@ -48,7 +58,7 @@ static int get_double_attribute_by_name(const TiXmlElement* pElement, const char
}
return 0;
}
#endif
static int get_int_attribute_by_name(const TiXmlElement* pElement, const char* attribName,int* value)
{
@@ -130,7 +140,9 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt
if (node)\
{\
const char* txt = (node)->ToElement()->GetText();\
(targetdata).argname= (pointertype) (int) atof(txt);\
MyLocalCaster cast;\
cast.m_int = (int) atof(txt);\
(targetdata).argname= (pointertype)cast.m_ptr;\
}\
}
@@ -216,8 +228,8 @@ void btBulletXmlWorldImporter::deSerializeCollisionShapeData(TiXmlNode* pParent,
void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent)
{
int ptr;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr);
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btConvexHullShapeData* convexHullData = (btConvexHullShapeData*)btAlignedAlloc(sizeof(btConvexHullShapeData), 16);
@@ -233,18 +245,33 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent
SET_VECTOR4_VALUE(xmlConvexInt,&convexHullData->m_convexInternalShapeData,m_localScaling)
SET_VECTOR4_VALUE(xmlConvexInt,&convexHullData->m_convexInternalShapeData,m_implicitShapeDimensions)
//convexHullData->m_unscaledPointsFloatPtr
//#define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype)
{
TiXmlNode* node = pParent->FirstChild("m_unscaledPointsFloatPtr");
btAssert(node);
if (node)
{
const char* txt = (node)->ToElement()->GetText();
MyLocalCaster cast;
cast.m_int = (int) atof(txt);
(*convexHullData).m_unscaledPointsFloatPtr= (btVector3FloatData*) cast.m_ptr;
}
}
SET_POINTER_VALUE(pParent,*convexHullData,m_unscaledPointsFloatPtr,btVector3FloatData*);
SET_POINTER_VALUE(pParent,*convexHullData,m_unscaledPointsDoublePtr,btVector3DoubleData*);
SET_INT_VALUE(pParent,convexHullData,m_numUnscaledPoints);
m_collisionShapeData.push_back((btCollisionShapeData*)convexHullData);
m_pointerLookup.insert((void*)ptr,convexHullData);
m_pointerLookup.insert(cast.m_ptr,convexHullData);
}
void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pParent)
{
int ptr;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr);
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
int numChildren = 0;
btAlignedObjectArray<btCompoundShapeChildData>* compoundChildArrayPtr = new btAlignedObjectArray<btCompoundShapeChildData>;
@@ -262,7 +289,9 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar
SET_MATRIX33_VALUE(transNode,&compoundChildArrayPtr->at(i).m_transform,m_basis)
const char* txt = (colShapeNode)->ToElement()->GetText();
compoundChildArrayPtr->at(i).m_childShape = (btCollisionShapeData*) (int) atof(txt);
MyLocalCaster cast;
cast.m_int = (int) atof(txt);
compoundChildArrayPtr->at(i).m_childShape = (btCollisionShapeData*) cast.m_ptr;
btAssert(childTypeNode->ToElement());
if (childTypeNode->ToElement())
@@ -292,15 +321,15 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar
{
m_compoundShapeChildDataArrays.push_back(compoundChildArrayPtr);
btCompoundShapeChildData* cd = &compoundChildArrayPtr->at(0);
m_pointerLookup.insert((void*)ptr,cd);
m_pointerLookup.insert(cast.m_ptr,cd);
}
}
void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent)
{
int ptr;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr);
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btCompoundShapeData* compoundData = (btCompoundShapeData*) btAlignedAlloc(sizeof(btCompoundShapeData),16);
@@ -319,7 +348,9 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent)
while (node)
{
const char* txt = (node)->ToElement()->GetText();
compoundData->m_childShapePtr = (btCompoundShapeChildData*) (int) atof(txt);
MyLocalCaster cast;
cast.m_int = (int) atof(txt);
compoundData->m_childShapePtr = (btCompoundShapeChildData*) cast.m_ptr;
node = node->NextSibling("m_childShapePtr");
}
//SET_POINTER_VALUE(xmlColShape, *compoundData,m_childShapePtr,btCompoundShapeChildData*);
@@ -328,14 +359,14 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent)
SET_FLOAT_VALUE(pParent, compoundData,m_collisionMargin);
m_collisionShapeData.push_back((btCollisionShapeData*)compoundData);
m_pointerLookup.insert((void*)ptr,compoundData);
m_pointerLookup.insert(cast.m_ptr,compoundData);
}
void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(TiXmlNode* pParent)
{
int ptr;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr);
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*) btAlignedAlloc(sizeof(btStaticPlaneShapeData),16);
@@ -348,7 +379,7 @@ void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(TiXmlNode* pParen
SET_FLOAT_VALUE(pParent, planeData,m_planeConstant);
m_collisionShapeData.push_back((btCollisionShapeData*)planeData);
m_pointerLookup.insert((void*)ptr,planeData);
m_pointerLookup.insert(cast.m_ptr,planeData);
}
@@ -364,8 +395,8 @@ void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(TiXmlNode* pParent)
{
int ptr=0;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr);
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btConvexInternalShapeData* convexShape = (btConvexInternalShapeData*) btAlignedAlloc(sizeof(btConvexInternalShapeData),16);
@@ -382,7 +413,7 @@ void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(TiXmlNode* pPa
SET_VECTOR4_VALUE(pParent,convexShape,m_implicitShapeDimensions)
m_collisionShapeData.push_back((btCollisionShapeData*)convexShape);
m_pointerLookup.insert((void*)ptr,convexShape);
m_pointerLookup.insert(cast.m_ptr,convexShape);
}
@@ -404,8 +435,8 @@ enum btTypedConstraintType
void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* pParent)
{
int ptr=0;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr);
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btGeneric6DofConstraintData2* dof6Data = (btGeneric6DofConstraintData2*)btAlignedAlloc(sizeof(btGeneric6DofConstraintData2),16);
@@ -439,13 +470,14 @@ void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* p
SET_INT_VALUE(pParent, dof6Data,m_useOffsetForConstraintFrame);
m_constraintData.push_back((btTypedConstraintData2*)dof6Data);
m_pointerLookup.insert((void*)ptr,dof6Data);
m_pointerLookup.insert(cast.m_ptr,dof6Data);
}
void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(TiXmlNode* pParent)
{
int ptr=0;
if (!get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr))
MyLocalCaster cast;
if (!get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int))
{
m_fileOk = false;
return;
@@ -506,7 +538,7 @@ void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(TiXmlNode* pParent)
m_rigidBodyData.push_back(rbData);
m_pointerLookup.insert((void*)ptr,rbData);
m_pointerLookup.insert(cast.m_ptr,rbData);
// rbData->m_collisionObjectData.m_collisionShape = (void*) (int)atof(txt);
}
@@ -641,8 +673,8 @@ void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pPa
// printf("child Name=%s\n", pChild->Value());
if (!strcmp(pChild->Value(),"btVector3FloatData"))
{
int ptr;
get_int_attribute_by_name(pChild->ToElement(),"pointer",&ptr);
MyLocalCaster cast;
get_int_attribute_by_name(pChild->ToElement(),"pointer",&cast.m_int);
btAlignedObjectArray<btVector3FloatData> v;
deSerializeVector3FloatData(pChild,v);
@@ -651,7 +683,7 @@ void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pPa
for (int i=0;i<numVectors;i++)
vectors[i] = v[i];
m_floatVertexArrays.push_back(vectors);
m_pointerLookup.insert((void*)ptr,vectors);
m_pointerLookup.insert(cast.m_ptr,vectors);
continue;
}
@@ -790,7 +822,7 @@ void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pPa
for (int i=0;i<m_constraintData.size();i++)
{
btTypedConstraintData2* tcd = m_constraintData[i];
bool isDoublePrecision = false;
// bool isDoublePrecision = false;
btRigidBody* rbA = 0;
btRigidBody* rbB = 0;
{

View File

@@ -20,12 +20,13 @@
#include "bDNA.h"
#include "bBlenderFile.h"
#include "btBulletFile.h"
#include "LinearMath/btSerializer.h"
#include "bCommon.h"
#include <map>
#include <vector>
#include <string.h>
bool isBulletFile = false;
bool isBulletFile = true;
using namespace bParse;
typedef std::string bString;
@@ -216,10 +217,12 @@ int main(int argc,char** argv)
using namespace bParse;
dump = fopen("dump.py", "w");
if (!dump) return 0;
fprintf(dump, "%s\n", data);
#if 0
char* filename = "../../../../data/r2d2_multibody.bullet";
if (argc==2)
@@ -269,9 +272,12 @@ int main(int argc,char** argv)
bBlenderFile f(memBuf,len);
swap = (f.getFlags() & FD_ENDIAN_SWAP)!=0;
}
#else
isBulletFile = true;
bool swap = false;
char* memBuf = sBulletDNAstr;
int len = sBulletDNAlen;
#endif
char *blenderData = memBuf;

View File

@@ -1,6 +1,9 @@
import sys
sys.path.append(".")
import dump
header = """/* Copyright (C) 2011 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied

View File

@@ -23,15 +23,29 @@ SET (INC_FILES
SET(SRC makesdna.cpp)
ADD_EXECUTABLE(makesdna ${SRC} ${INC_FILES})
# Output BulletDNA.c
ADD_CUSTOM_COMMAND(
OUTPUT ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp
COMMAND ${CMAKE_CFG_INTDIR}/makesdna ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/CommonSerialize/
DEPENDS makesdna
)
IF (CMAKE_CL_64)
# Output BulletDNA.c
ADD_CUSTOM_COMMAND(
OUTPUT ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer64.cpp
COMMAND ${CMAKE_CFG_INTDIR}/makesdna ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer64.cpp ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/CommonSerialize/
DEPENDS makesdna
)
SET(SRC ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer64.cpp)
ELSE()
# Output BulletDNA.c
ADD_CUSTOM_COMMAND(
OUTPUT ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp
COMMAND ${CMAKE_CFG_INTDIR}/makesdna ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/CommonSerialize/
DEPENDS makesdna
)
SET(SRC ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp)
ENDIF()
# Build bf_dna library
SET(SRC ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btSerializer.cpp)
ADD_LIBRARY(BulletDNA ${SRC} ${INC_FILES})
MESSAGE(STATUS "Configuring makesdna")

View File

@@ -0,0 +1,20 @@
SET(includes
.
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
${BULLET_PHYSICS_SOURCE_DIR}/src
)
LINK_LIBRARIES(
Bullet3Common
)
INCLUDE_DIRECTORIES(${includes})
ADD_EXECUTABLE(App_obj2sdf
obj2sdf.cpp
../../examples/Utils/b3ResourcePath.cpp
../../examples/Utils/b3ResourcePath.h
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
)

178
Extras/obj2sdf/obj2sdf.cpp Normal file
View File

@@ -0,0 +1,178 @@
/// obj2sdf will load a Wavefront .obj file that may contain many parts/materials
/// it will split into separate obj files for each part/material and
/// create an sdf file with visuals/collisions pointing to the new obj files
/// this will make it easier to load complex obj files into pybullet
/// see for example export in data/kitchens/fathirmutfak.sdf
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define ASSERT_EQ(a,b) assert((a)==(b));
#include"Wavefront/tiny_obj_loader.h"
#include <vector>
#include "Bullet3Common/b3FileUtils.h"
#include "../Utils/b3ResourcePath.h"
#include "Bullet3Common/b3CommandLineArgs.h"
#define MAX_PATH_LEN 1024
int main(int argc, char* argv[])
{
b3CommandLineArgs args(argc,argv);
char* fileName;
args.GetCmdLineArgument("fileName",fileName);
printf("fileName = %s\n", fileName);
if (fileName==0)
{
printf("Please use --fileName=\"pathToObj\".");
exit(0);
}
char fileNameWithPath[MAX_PATH_LEN];
bool fileFound = (b3ResourcePath::findResourcePath(fileName,fileNameWithPath,MAX_PATH_LEN))>0;
char materialPrefixPath[MAX_PATH_LEN];
b3FileUtils::extractPath(fileNameWithPath,materialPrefixPath,MAX_PATH_LEN);
std::vector<tinyobj::shape_t> shapes;
std::string err = tinyobj::LoadObj(shapes, fileNameWithPath, materialPrefixPath);
char sdfFileName[MAX_PATH_LEN];
sprintf(sdfFileName,"%s%s.sdf",materialPrefixPath,"newsdf");
FILE* sdfFile = fopen(sdfFileName,"w");
if (sdfFile==0)
{
printf("Fatal error: cannot create sdf file %s\n",sdfFileName);
exit(0);
}
fprintf(sdfFile, "<sdf version='1.6'>\n\t<world name='default'>\n\t<gravity>0 0 -9.8</gravity>\n");
for (int s=0;s<(int)shapes.size();s++)
{
tinyobj::shape_t& shape = shapes[s];
if (shape.name.length())
{
printf("object name = %s\n", shape.name.c_str());
}
char objFileName[MAX_PATH_LEN];
sprintf(objFileName,"%s/part%d.obj",materialPrefixPath,s);
FILE* f = fopen(objFileName,"w");
if (f==0)
{
printf("Fatal error: cannot create part obj file %s\n",objFileName);
exit(0);
}
fprintf(f,"# Exported using automatic converter by Erwin Coumans\n");
fprintf(f,"mtllib bedroom.mtl\n");
int faceCount = shape.mesh.indices.size();
int vertexCount = shape.mesh.positions.size();
tinyobj::material_t mat = shape.material;
if (shape.name.length())
{
const char* objName = shape.name.c_str();
printf("mat.name = %s\n", objName);
fprintf(f,"#object %s\n\n",objName);
}
for (int v=0;v<vertexCount/3;v++)
{
fprintf(f,"v %f %f %f\n",shape.mesh.positions[v*3+0],shape.mesh.positions[v*3+1],shape.mesh.positions[v*3+2]);
}
if (mat.name.length())
{
fprintf(f,"usemtl %s\n",mat.name.c_str());
} else
{
fprintf(f,"usemtl wire_028089177\n");
}
fprintf(f,"\n");
int numNormals = int(shape.mesh.normals.size());
for (int vn = 0;vn<numNormals/3;vn++)
{
fprintf(f,"vn %f %f %f\n",shape.mesh.normals[vn*3+0],shape.mesh.normals[vn*3+1],shape.mesh.normals[vn*3+2]);
}
fprintf(f,"\n");
int numTexCoords = int(shape.mesh.texcoords.size());
for (int vt = 0;vt<numTexCoords/2;vt++)
{
fprintf(f,"vt %f %f\n",shape.mesh.texcoords[vt*2+0],shape.mesh.texcoords[vt*2+1]);
}
fprintf(f,"s off\n");
for (int face=0;face<faceCount;face+=3)
{
if (face<0 && face>=int(shape.mesh.indices.size()))
{
continue;
}
fprintf(f,"f %d/%d/%d %d/%d/%d %d/%d/%d\n",
shape.mesh.indices[face]+1,shape.mesh.indices[face]+1,shape.mesh.indices[face]+1,
shape.mesh.indices[face+1]+1,shape.mesh.indices[face+1]+1,shape.mesh.indices[face+1]+1,
shape.mesh.indices[face+2]+1,shape.mesh.indices[face+2]+1,shape.mesh.indices[face+2]+1);
}
fclose(f);
float kdRed=mat.diffuse[0];
float kdGreen=mat.diffuse[1];
float kdBlue=mat.diffuse[2];
char objSdfPartFileName[MAX_PATH_LEN];
sprintf(objSdfPartFileName,"part%d.obj",s);
fprintf(sdfFile,"\t\t<model name='%s'>\n"
"\t\t\t<static>1</static>\n"
"\t\t\t<pose frame=''>0 0 0 0 0 0</pose>\n"
"\t\t\t<link name='link_d%d'>\n"
"\t\t\t<inertial>\n"
"\t\t\t<mass>0</mass>\n"
"\t\t\t<inertia>\n"
"\t\t\t<ixx>0.166667</ixx>\n"
"\t\t\t<ixy>0</ixy>\n"
"\t\t\t<ixz>0</ixz>\n"
"\t\t\t<iyy>0.166667</iyy>\n"
"\t\t\t<iyz>0</iyz>\n"
"\t\t\t<izz>0.166667</izz>\n"
"\t\t\t</inertia>\n"
"\t\t\t</inertial>\n"
"\t\t\t<collision name='collision_%d'>\n"
"\t\t\t<geometry>\n"
"\t\t\t<mesh>\n"
"\t\t\t<scale>1 1 1</scale>\n"
"\t\t\t\t<uri>%s</uri>\n"
"\t\t\t</mesh>\n"
"\t\t\t</geometry>\n"
"\t\t\t </collision>\n"
"\t\t\t<visual name='visual'>\n"
"\t\t\t\t<geometry>\n"
"\t\t\t\t<mesh>\n"
"\t\t\t\t\t<scale>1 1 1</scale>\n"
"\t\t\t\t\t<uri>%s</uri>\n"
"\t\t\t\t</mesh>\n"
"\t\t\t\t</geometry>\n"
"\t\t\t<material>\n"
"\t\t\t\t<ambient>1 0 0 1</ambient>\n"
"\t\t\t\t<diffuse>%f %f %f 1</diffuse>\n"
"\t\t\t\t<specular>0.1 0.1 0.1 1</specular>\n"
"\t\t\t\t<emissive>0 0 0 0</emissive>\n"
"\t\t\t </material>\n"
"\t\t\t </visual>\n"
"\t\t\t </link>\n"
"\t\t\t</model>\n",objSdfPartFileName,s,s,
objSdfPartFileName,objSdfPartFileName,
kdRed, kdGreen, kdBlue);
}
fprintf(sdfFile,"\t</world>\n</sdf>\n");
fclose(sdfFile);
return 0;
}

View File

@@ -0,0 +1,18 @@
project ("App_obj2sdf")
language "C++"
kind "ConsoleApp"
includedirs {"../../src",
"../../examples/ThirdPartyLibs"}
links{"Bullet3Common"}
files {
"obj2sdf.cpp",
"../../examples/Utils/b3ResourcePath.cpp",
"../../examples/Utils/b3ResourcePath.h",
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
}

View File

@@ -6,4 +6,4 @@ include "InverseDynamics"
include "Serialize/BulletFileLoader"
include "Serialize/BulletWorldImporter"
include "Serialize/BulletXmlWorldImporter"
include "obj2sdf"

16
MANIFEST.in Normal file
View File

@@ -0,0 +1,16 @@
include MANIFEST.in *.txt
recursive-include examples *.h
recursive-include examples *.hpp
recursive-include Extras *.h
recursive-include Extras *.hpp
recursive-include src *.h
recursive-include src *.hpp
include examples/ThirdPartyLibs/enet/unix.c
include examples/OpenGLWindow/X11OpenGLWindow.cpp
include examples/ThirdPartyLibs/Glew/glew.c
include examples/ThirdPartyLibs/enet/win32.c
include examples/OpenGLWindow/Win32Window.cpp
include examples/OpenGLWindow/Win32OpenGLWindow.cpp
include examples/ThirdPartyLibs/Glew/glew.c
include examples/OpenGLWindow/MacOpenGLWindow.cpp
include examples/OpenGLWindow/MacOpenGLWindowObjC.m

View File

@@ -49,36 +49,48 @@ All source code files are licensed under the permissive zlib license
**Windows**
Click on build_visual_studio.bat and open build3/vs2010/0MySolution.sln
Click on build_visual_studio_vr_pybullet_double.bat and open build3/vs2010/0MySolution.sln
When asked, convert the projects to a newer version of Visual Studio.
If you installed Python in the C:\ root directory, the batch file should find it automatically.
Otherwise, edit this batch file to choose where Python include/lib directories are located.
**Windows Virtual Reality sandbox for HTC Vive and Oculus Rift**
Click on build_visual_studio_vr_pybullet_double.bat and open build3/vs2010/0MySolution.sln
Edit this batch file to choose where Python include/lib directories are located.
Build and run the App_SharedMemoryPhysics_VR project, preferably in Release/optimized build.
You can connect from Python pybullet to the sandbox using:
```
import pybullet as p
p.connect(p.SHARED_MEMORY)
p.connect(p.SHARED_MEMORY) #or (p.TCP, "localhost", 6667) or (p.UDP, "192.168.86.10",1234)
```
**Linux and Mac OSX gnu make**
Make sure cmake is installed (sudo apt-get install cmake, brew install cmake, or https://cmake.org)
In a terminal type:
cd build3
./build_cmake_pybullet_double.sh
This script will invoke cmake and build in the build_cmake directory. You can find pybullet in Bullet/examples/pybullet.
The BulletExampleBrowser binary will be in Bullet/examples/ExampleBrowser.
You can also build Bullet using premake. There are premake executables in the build3 folder.
Depending on your system (Linux 32bit, 64bit or Mac OSX) use one of the following lines
./premake4_linux gmake
./premake4_linux64 gmake
./premake4_osx gmake
Using premake:
```
cd build3
./premake4_linux gmake --double
./premake4_linux64 gmake --double
./premake4_osx gmake --double --enable_pybullet
```
Then
```
cd gmake
make
```
Note that on Linux, you need to use cmake to build pybullet, since the compiler has issues of mixing shared and static libraries.
**Mac OSX Xcode**

View File

@@ -1 +1 @@
2.85
2.87

91
_clang-format Normal file
View File

@@ -0,0 +1,91 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
AccessModifierOffset: -4
Standard: Auto
TabWidth: 4
UseTab: ForContinuationAndIndentation
...

View File

@@ -0,0 +1,25 @@
# Note by Nikolaus Demmel 28.03.2014: My contributions are licensend under the
# same as CMake (BSD). My adaptations are in part based
# https://github.com/qgis/QGIS/tree/master/cmake which has the following
# copyright note:
# FindLibPython.py
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
import sys
import distutils.sysconfig
print("exec_prefix:%s" % sys.exec_prefix)
print("major_version:%s" % str(sys.version_info[0]))
print("minor_version:%s" % str(sys.version_info[1]))
print("patch_version:%s" % str(sys.version_info[2]))
print("short_version:%s" % '.'.join(map(lambda x:str(x), sys.version_info[0:2])))
print("long_version:%s" % '.'.join(map(lambda x:str(x), sys.version_info[0:3])))
print("py_inc_dir:%s" % distutils.sysconfig.get_python_inc())
print("site_packages_dir:%s" % distutils.sysconfig.get_python_lib(plat_specific=1))
for e in distutils.sysconfig.get_config_vars ('LIBDIR'):
if e != None:
print("py_lib_dir:%s" % e)
break

View File

@@ -1,41 +1,59 @@
# Find the Python NumPy package
# PYTHON_NUMPY_INCLUDE_DIR
# PYTHON_NUMPY_FOUND
# will be set by this script
# - Find the NumPy libraries
# This module finds if NumPy is installed, and sets the following variables
# indicating where it is.
#
# TODO: Update to provide the libraries and paths for linking npymath lib.
#
# PYTHON_NUMPY_FOUND - was NumPy found
# PYTHON_NUMPY_VERSION - the version of NumPy found as a string
# PYTHON_NUMPY_VERSION_MAJOR - the major version number of NumPy
# PYTHON_NUMPY_VERSION_MINOR - the minor version number of NumPy
# PYTHON_NUMPY_VERSION_PATCH - the patch version number of NumPy
# PYTHON_NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601
# PYTHON_NUMPY_INCLUDE_DIR - path to the NumPy include files
cmake_minimum_required(VERSION 2.6)
unset(PYTHON_NUMPY_VERSION)
unset(PYTHON_NUMPY_INCLUDE_DIR)
if(NOT PYTHON_EXECUTABLE)
if(NumPy_FIND_QUIETLY)
find_package(PythonInterp QUIET)
else()
find_package(PythonInterp)
set(__numpy_out 1)
if(PYTHONINTERP_FOUND)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import numpy as n; print(n.__version__); print(n.get_include());"
RESULT_VARIABLE __result
OUTPUT_VARIABLE __output
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(__result MATCHES 0)
string(REGEX REPLACE ";" "\\\\;" __values ${__output})
string(REGEX REPLACE "\r?\n" ";" __values ${__values})
list(GET __values 0 PYTHON_NUMPY_VERSION)
list(GET __values 1 PYTHON_NUMPY_INCLUDE_DIR)
string(REGEX MATCH "^([0-9])+\\.([0-9])+\\.([0-9])+" __ver_check "${PYTHON_NUMPY_VERSION}")
if(NOT "${__ver_check}" STREQUAL "")
set(PYTHON_NUMPY_VERSION_MAJOR ${CMAKE_MATCH_1})
set(PYTHON_NUMPY_VERSION_MINOR ${CMAKE_MATCH_2})
set(PYTHON_NUMPY_VERSION_PATCH ${CMAKE_MATCH_3})
math(EXPR PYTHON_NUMPY_VERSION_DECIMAL
"(${PYTHON_NUMPY_VERSION_MAJOR} * 10000) + (${PYTHON_NUMPY_VERSION_MINOR} * 100) + ${PYTHON_NUMPY_VERSION_PATCH}")
string(REGEX REPLACE "\\\\" "/" PYTHON_NUMPY_INCLUDE_DIR ${PYTHON_NUMPY_INCLUDE_DIR})
else()
unset(PYTHON_NUMPY_VERSION)
unset(PYTHON_NUMPY_INCLUDE_DIR)
message(STATUS "Requested NumPy version and include path, but got instead:\n${__output}\n")
endif()
endif()
else()
message(STATUS "To find NumPy Python interpretor is required to be found.")
endif()
if (PYTHON_EXECUTABLE)
# Find out the include path
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n"
OUTPUT_VARIABLE __numpy_path)
# And the version
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n"
OUTPUT_VARIABLE __numpy_version)
elseif(__numpy_out)
message(STATUS "Python executable not found.")
endif(PYTHON_EXECUTABLE)
find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h
HINTS "${__numpy_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH)
if(PYTHON_NUMPY_INCLUDE_DIR)
set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found")
endif(PYTHON_NUMPY_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NumPy REQUIRED_VARS PYTHON_NUMPY_INCLUDE_DIR
VERSION_VAR __numpy_version)
find_package_handle_standard_args(NumPy REQUIRED_VARS PYTHON_NUMPY_INCLUDE_DIR PYTHON_NUMPY_VERSION
VERSION_VAR PYTHON_NUMPY_VERSION)
if(NUMPY_FOUND)
set(PYTHON_NUMPY_FOUND TRUE)
message(STATUS "NumPy ver. ${PYTHON_NUMPY_VERSION} found (include: ${PYTHON_NUMPY_INCLUDE_DIR})")
endif()
# caffe_clear_vars(__result __output __error_value __values __ver_check __error_value)

View File

@@ -0,0 +1,353 @@
# - Find python libraries
# This module finds if Python is installed and determines where the
# include files and libraries are. It also determines what the name of
# the library is. This code sets the following variables:
#
# PYTHONLIBS_FOUND - have the Python libs been found
# PYTHON_LIBRARIES - path to the python library
# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
# PYTHON_INCLUDE_DIRS - path to where Python.h is found
# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated)
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
#
# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list of
# version numbers that should be taken into account when searching for Python.
# You need to set this variable before calling find_package(PythonLibs).
#
# If you'd like to specify the installation of Python to use, you should modify
# the following cache variables:
# PYTHON_LIBRARY - path to the python library
# PYTHON_INCLUDE_DIR - path to where Python.h is found
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Note by Nikolaus Demmel 28.03.2014: My contributions are licensend under the
# same as CMake (BSD). My adaptations are in part based
# https://github.com/qgis/QGIS/tree/master/cmake which has the following
# copyright note:
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(NOT DEFINED PYTHON_INCLUDE_DIR)
if(DEFINED PYTHON_INCLUDE_PATH)
# For backward compatibility, repect PYTHON_INCLUDE_PATH.
set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH
"Path to where Python.h is found" FORCE)
else()
set(PYTHON_INCLUDE_DIR "" CACHE PATH
"Path to where Python.h is found" FORCE)
endif()
endif()
if(EXISTS "${PYTHON_INCLUDE_DIR}" AND EXISTS "${PYTHON_LIBRARY}")
if(EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h")
file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" _PYTHON_VERSION_STR
REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
PYTHONLIBS_VERSION_STRING "${_PYTHON_VERSION_STR}")
unset(_PYTHON_VERSION_STR)
endif()
else()
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
set(_PYTHON3_VERSIONS 3.4 3.3 3.2 3.1 3.0)
unset(_PYTHON_FIND_OTHER_VERSIONS)
if(PythonLibs_FIND_VERSION)
if(PythonLibs_FIND_VERSION_COUNT GREATER 1)
set(_PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION_MAJOR}.${PythonLibs_FIND_VERSION_MINOR}")
if(NOT PythonLibs_FIND_VERSION_EXACT)
foreach(_PYTHON_V ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
if(NOT _PYTHON_V STREQUAL PythonLibs_FIND_VERSION)
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
endif()
endif()
endforeach()
endif()
unset(_PYTHON_FIND_MAJ_MIN)
else()
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
endif()
else()
# add an empty version to check the `python` executable first in case no version is requested
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
endif()
unset(_PYTHON1_VERSIONS)
unset(_PYTHON2_VERSIONS)
unset(_PYTHON3_VERSIONS)
# Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front.
# If FindPythonInterp has already found the major and minor version,
# insert that version between the user supplied versions and the stock
# version list.
# If no specific version is requested or suggested by PythonInterp, always look
# for "python" executable first
set(_PYTHON_VERSIONS ${PythonLibs_FIND_VERSION} ${PythonLibs_ADDITIONAL_VERSIONS} )
if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR)
list(APPEND _PYTHON_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
endif()
if (NOT _PYTHON_VERSIONS)
set(_PYTHON_VERSIONS ";") # empty entry at the front makeing sure we search for "python" first
endif()
list(APPEND _PYTHON_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
unset(_PYTHON_FIND_OTHER_VERSIONS)
message(STATUS "Looking for versions: ${_PYTHON_VERSIONS}")
FIND_FILE(_FIND_LIB_PYTHON_PY FindLibPython.py PATHS ${CMAKE_MODULE_PATH} ${CMAKE_ROOT}/Modules)
if(NOT _FIND_LIB_PYTHON_PY)
message(FATAL_ERROR "Could not find required file 'FindLibPython.py'")
endif()
unset(PYTHONLIBS_VERSION_STRING)
foreach(_CURRENT_VERSION IN LISTS _PYTHON_VERSIONS)
STRING(REGEX REPLACE "^([0-9]+).*$" "\\1" _VERSION_MAJOR "${_CURRENT_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+).*$" "\\1" _VERSION_MINOR "${_CURRENT_VERSION}")
set(_PYTHON_NAMES python)
if (_CURRENT_VERSION MATCHES "^[0-9]+.*$")
list(APPEND _PYTHON_NAMES "python${_VERSION_MAJOR}")
if (_CURRENT_VERSION MATCHES "^[0-9]+\\.[0-9].*$")
list(APPEND _PYTHON_NAMES "python${_VERSION_MAJOR}.${_VERSION_MINOR}")
endif()
endif()
message(STATUS "Looking for python version '${_CURRENT_VERSION}' by checking executables: ${_PYTHON_NAMES}.")
foreach(_CURRENT_PYTHON_NAME IN LISTS _PYTHON_NAMES)
unset(_PYTHON_EXECUTABLE CACHE)
find_program(_PYTHON_EXECUTABLE ${_CURRENT_PYTHON_NAME}
PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath])
if(_PYTHON_EXECUTABLE)
EXECUTE_PROCESS(
COMMAND ${_PYTHON_EXECUTABLE} "${_FIND_LIB_PYTHON_PY}"
OUTPUT_VARIABLE _PYTHON_CONFIG
RESULT_VARIABLE _PYTHON_CONFIG_RESULT
ERROR_QUIET)
if(NOT ${_PYTHON_CONFIG_RESULT} AND (NOT ${_PYTHON_CONFIG} STREQUAL ""))
STRING(REGEX REPLACE ".*\nmajor_version:([0-9]+).*$" "\\1" _PYTHON_MAJOR_VERSION ${_PYTHON_CONFIG})
STRING(REGEX REPLACE ".*\nminor_version:([0-9]+).*$" "\\1" _PYTHON_MINOR_VERSION ${_PYTHON_CONFIG})
STRING(REGEX REPLACE ".*\npatch_version:([0-9]+).*$" "\\1" _PYTHON_PATCH_VERSION ${_PYTHON_CONFIG})
STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" _PYTHON_SHORT_VERSION ${_PYTHON_CONFIG})
STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" _PYTHON_LONG_VERSION ${_PYTHON_CONFIG})
STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" _PYTHON_INCLUDE_DIR ${_PYTHON_CONFIG})
STRING(REGEX REPLACE ".*\npy_lib_dir:([^\n]+).*$" "\\1" _PYTHON_LIBRARY_DIR ${_PYTHON_CONFIG})
STRING(REGEX REPLACE ".*\nexec_prefix:(^\n+).*$" "\\1" _PYTHON_PREFIX ${_PYTHON_CONFIG})
if ("${_CURRENT_VERSION}" STREQUAL "" OR
"${_CURRENT_VERSION}" STREQUAL "${_PYTHON_MAJOR_VERSION}" OR
"${_CURRENT_VERSION}" STREQUAL "${_PYTHON_SHORT_VERSION}" OR
"${_CURRENT_VERSION}" STREQUAL "${_PYTHON_LONG_VERSION}")
message(STATUS "Found executable ${_PYTHON_EXECUTABLE} with suitable version ${_PYTHON_LONG_VERSION}")
if(NOT EXISTS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_INCLUDE_DIR "${_PYTHON_INCLUDE_DIR}")
endif()
if(NOT EXISTS "${PYTHON_LIBRARY}")
set(_PYTHON_SHORT_VERSION_NO_DOT "${_PYTHON_MAJOR_VERSION}${_PYTHON_MINOR_VERSION}")
set(_PYTHON_LIBRARY_NAMES python${_PYTHON_SHORT_VERSION} python${_PYTHON_SHORT_VERSION_NO_DOT})
FIND_LIBRARY(PYTHON_LIBRARY
NAMES ${_PYTHON_LIBRARY_NAMES}
PATH_SUFFIXES
python${_PYTHON_SHORT_VERSION}/config
python${_PYTHON_SHORT_VERSION_NO_DOT}/config
PATHS
${_PYTHON_LIBRARY_DIR}
${_PYTHON_PREFIX}/lib $
{_PYTHON_PREFIX}/libs
NO_DEFAULT_PATH)
if(WIN32)
find_library(PYTHON_DEBUG_LIBRARY
NAMES python${_PYTHON_SHORT_VERSION_NO_DOT}_d python
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
)
endif()
endif()
set(PYTHONLIBS_VERSION_STRING ${_PYTHON_LONG_VERSION})
if(_PYTHON_PATCH_VERSION STREQUAL "0")
# it's called "Python 2.7", not "2.7.0"
string(REGEX REPLACE "\\.0$" "" PYTHONLIBS_VERSION_STRING "${PYTHONLIBS_VERSION_STRING}")
endif()
break()
else()
message(STATUS "Found executable ${_PYTHON_EXECUTABLE} with UNsuitable version ${_PYTHON_LONG_VERSION}")
endif() # version ok
else()
message(WARNING "Found executable ${_PYTHON_EXECUTABLE}, but could not extract version info.")
endif() # could extract config
endif() # found executable
endforeach() # python names
if (PYTHONLIBS_VERSION_STRING)
break()
endif()
endforeach() # python versions
endif()
unset(_PYTHON_NAMES)
unset(_PYTHON_VERSIONS)
unset(_PYTHON_EXECUTABLE CACHE)
unset(_PYTHON_MAJOR_VERSION)
unset(_PYTHON_MINOR_VERSION)
unset(_PYTHON_PATCH_VERSION)
unset(_PYTHON_SHORT_VERSION)
unset(_PYTHON_LONG_VERSION)
unset(_PYTHON_LIBRARY_DIR)
unset(_PYTHON_INCLUDE_DIR)
unset(_PYTHON_PREFIX)
unset(_PYTHON_SHORT_VERSION_NO_DOT)
unset(_PYTHON_LIBRARY_NAMES)
# For backward compatibility, set PYTHON_INCLUDE_PATH.
set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}")
mark_as_advanced(
PYTHON_DEBUG_LIBRARY
PYTHON_LIBRARY
PYTHON_INCLUDE_DIR
)
# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the
# cache entries because they are meant to specify the location of a single
# library. We now set the variables listed by the documentation for this
# module.
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
# These variables have been historically named in this module different from
# what SELECT_LIBRARY_CONFIGURATIONS() expects.
set(PYTHON_LIBRARY_DEBUG "${PYTHON_DEBUG_LIBRARY}")
set(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}")
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
SELECT_LIBRARY_CONFIGURATIONS(PYTHON)
# SELECT_LIBRARY_CONFIGURATIONS() sets ${PREFIX}_FOUND if it has a library.
# Unset this, this prefix doesn't match the module prefix, they are different
# for historical reasons.
unset(PYTHON_FOUND)
# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs
REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS
VERSION_VAR PYTHONLIBS_VERSION_STRING)
# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
# in your sources to initialize the static python modules
function(PYTHON_ADD_MODULE _NAME )
get_property(_TARGET_SUPPORTS_SHARED_LIBS
GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
option(PYTHON_MODULE_${_NAME}_BUILD_SHARED
"Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
# Mark these options as advanced
mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME}
PYTHON_MODULE_${_NAME}_BUILD_SHARED)
if(PYTHON_ENABLE_MODULE_${_NAME})
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
set(PY_MODULE_TYPE MODULE)
else()
set(PY_MODULE_TYPE STATIC)
set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME})
endif()
set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME})
add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
# target_link_libraries(${_NAME} ${PYTHON_LIBRARIES})
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
if(WIN32 AND NOT CYGWIN)
set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd")
endif()
endif()
endif()
endfunction()
function(PYTHON_WRITE_MODULES_HEADER _filename)
get_property(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST)
get_filename_component(_name "${_filename}" NAME)
string(REPLACE "." "_" _name "${_name}")
string(TOUPPER ${_name} _nameUpper)
set(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename})
set(_filenameTmp "${_filename}.in")
file(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n")
file(APPEND ${_filenameTmp}
"#ifndef ${_nameUpper}
#define ${_nameUpper}
#include <Python.h>
#ifdef __cplusplus
extern \"C\" {
#endif /* __cplusplus */
")
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
file(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n")
endforeach()
file(APPEND ${_filenameTmp}
"#ifdef __cplusplus
}
#endif /* __cplusplus */
")
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
file(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n")
endforeach()
file(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n")
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
file(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n")
endforeach()
file(APPEND ${_filenameTmp} "}\n\n")
file(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
# with configure_file() cmake complains that you may not use a file created using file(WRITE) as input file for configure_file()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)
endfunction()

View File

@@ -0,0 +1,70 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# SelectLibraryConfigurations
# ---------------------------
#
#
#
# select_library_configurations( basename )
#
# This macro takes a library base name as an argument, and will choose
# good values for basename_LIBRARY, basename_LIBRARIES,
# basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what
# has been found and set. If only basename_LIBRARY_RELEASE is defined,
# basename_LIBRARY will be set to the release value, and
# basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND.
# If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will
# take the debug value, and basename_LIBRARY_RELEASE will be set to
# basename_LIBRARY_RELEASE-NOTFOUND.
#
# If the generator supports configuration types, then basename_LIBRARY
# and basename_LIBRARIES will be set with debug and optimized flags
# specifying the library to be used for the given configuration. If no
# build type has been set or the generator in use does not support
# configuration types, then basename_LIBRARY and basename_LIBRARIES will
# take only the release value, or the debug value if the release one is
# not set.
# This macro was adapted from the FindQt4 CMake module and is maintained by Will
# Dicharry <wdicharry@stellarscience.com>.
macro( select_library_configurations basename )
if(NOT ${basename}_LIBRARY_RELEASE)
set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.")
endif()
if(NOT ${basename}_LIBRARY_DEBUG)
set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.")
endif()
if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND
NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND
( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) )
# if the generator supports configuration types or CMAKE_BUILD_TYPE
# is set, then set optimized and debug options.
set( ${basename}_LIBRARY "" )
foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE )
list( APPEND ${basename}_LIBRARY optimized "${_libname}" )
endforeach()
foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG )
list( APPEND ${basename}_LIBRARY debug "${_libname}" )
endforeach()
elseif( ${basename}_LIBRARY_RELEASE )
set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} )
elseif( ${basename}_LIBRARY_DEBUG )
set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} )
else()
set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND")
endif()
set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" )
if( ${basename}_LIBRARY )
set( ${basename}_FOUND TRUE )
endif()
mark_as_advanced( ${basename}_LIBRARY_RELEASE
${basename}_LIBRARY_DEBUG
)
endmacro()

View File

@@ -71,10 +71,23 @@
description = "Don't build Extras"
}
newoption
{
trigger = "standalone-examples",
description = "Build standalone examples with reduced dependencies."
}
newoption
{
trigger = "no-clsocket",
description = "Disable clsocket and clsocket tests (used for optional TCP networking in pybullet and shared memory C-API)"
}
newoption
{
trigger = "no-enet",
description = "Disable enet and enet tests"
description = "Disable enet and enet tests (used for optional UDP networking in pybullet and shared memory C-API)"
}
newoption
@@ -145,11 +158,21 @@ end
description = "Double precision version of Bullet"
}
newoption
{
trigger = "serial",
description = "Enable serial, for testing the VR glove in C++"
}
newoption
{
trigger = "audio",
description = "Enable audio"
}
if _OPTIONS["double"] then
defines {"BT_USE_DOUBLE_PRECISION"}
end
configurations {"Release", "Debug"}
configuration "Release"
flags { "Optimize", "EnableSSE2","StaticRuntime", "NoMinimalRebuild", "FloatFast"}
@@ -238,20 +261,22 @@ end
language "C++"
if _OPTIONS["audio"] then
include "../examples/TinyAudio"
end
if _OPTIONS["serial"] then
include "../examples/ThirdPartyLibs/serial"
end
if not _OPTIONS["no-demos"] then
include "../examples/ExampleBrowser"
include "../examples/RobotSimulator"
include "../examples/OpenGLWindow"
include "../examples/ThirdPartyLibs/Gwen"
include "../examples/SimpleOpenGL3"
include "../examples/TinyRenderer"
include "../examples/HelloWorld"
include "../examples/BasicDemo"
include "../examples/InverseDynamics"
include "../examples/ExtendedTutorials"
include "../examples/SharedMemory"
include "../examples/ThirdPartyLibs/BussIK"
include "../examples/MultiThreading"
if _OPTIONS["lua"] then
include "../examples/ThirdPartyLibs/lua-5.2.3"
@@ -259,10 +284,19 @@ end
if _OPTIONS["enable_pybullet"] then
include "../examples/pybullet"
end
include "../examples/SimpleOpenGL3"
if _OPTIONS["standalone-examples"] then
include "../examples/TinyRenderer"
include "../examples/BasicDemo"
include "../examples/InverseDynamics"
include "../examples/ExtendedTutorials"
include "../examples/MultiThreading"
end
if not _OPTIONS["no-test"] then
include "../test/SharedMemory"
end
end
@@ -270,13 +304,20 @@ end
include "../examples/ThirdPartyLibs/midi"
end
if not _OPTIONS["no-clsocket"] then
defines {"BT_ENABLE_CLSOCKET"}
include "../examples/ThirdPartyLibs/clsocket"
include "../test/clsocket"
end
if not _OPTIONS["no-enet"] then
defines {"BT_ENABLE_ENET"}
include "../examples/ThirdPartyLibs/enet"
include "../test/enet/nat_punchthrough/client"
include "../test/enet/nat_punchthrough/server"
include "../test/enet/chat/client"
include "../test/enet/chat/server"
defines {"BT_ENABLE_ENET"}
end
if _OPTIONS["no-bullet3"] then

BIN
build3/premake4_arm64 Executable file

Binary file not shown.

View File

@@ -1,6 +0,0 @@
rem premake4 --with-pe vs2010
premake4 --bullet2gpu vs2010
mkdir vs2010\cache
pause

View File

@@ -1,7 +0,0 @@
#!/bin/sh
rm CMakeCache.txt
mkdir build_cmake
cd build_cmake
cmake -DBUILD_PYBULLET=OFF -DCMAKE_BUILD_TYPE=Release ..
make -j12
examples/ExampleBrowser/App_ExampleBrowser

View File

@@ -1,6 +0,0 @@
#!/bin/sh
rm CMakeCache.txt
mkdir build_cmake
cd build_cmake
cmake -DBUILD_PYBULLET=ON -DBUILD_PYBULLET_NUMPY=ON -DUSE_DOUBLE_PRECISION=ON -DCMAKE_BUILD_TYPE=Release ..
make -j12

View File

@@ -1,7 +0,0 @@
#!/bin/sh
cd build3
./premake4_linux64 gmake
./premake4_osx gmake
cd gmake
make -j12
../../bin/App_BulletExampleBrowser_gmake_x64_release

10
build_cmake_pybullet_double.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
rm CMakeCache.txt
mkdir build_cmake
cd build_cmake
cmake -DBUILD_PYBULLET=ON -DBUILD_PYBULLET_NUMPY=OFF -DUSE_DOUBLE_PRECISION=ON -DCMAKE_BUILD_TYPE=Release ..
make -j12
cd examples
cd pybullet
ln -s pybullet.dylib pybullet.so

View File

@@ -1,4 +0,0 @@
mkdir cm
cd cm
cmake -DBUILD_PYBULLET=ON -DCMAKE_BUILD_TYPE=Release -DPYTHON_INCLUDE_DIR=c:\python-3.5.2\include -DPYTHON_LIBRARY=c:\python-3.5.2\libs\python35.lib -DPYTHON_DEBUG_LIBRARY=c:\python-3.5.2\libs\python35_d.lib ..
start .

View File

@@ -1,5 +0,0 @@
cd build3
premake4 --targetdir="../bin" vs2010
start vs2010

View File

@@ -1,8 +1,9 @@
IF NOT EXIST bin mkdir bin
IF NOT EXIST bin\openvr_api.dll copy examples\ThirdPartyLibs\openvr\bin\win32\openvr_api.dll bin
IF NOT EXIST bin\openvr64pi.dll copy examples\ThirdPartyLibs\openvr\bin\win64\openvr_api.dll bin\openvr64pi.dll
#aargh, see https://github.com/ValveSoftware/openvr/issues/412
#optionally, hardcode the python path or
#SET myvar=c:\python-3.5.3
#find a python version (hopefully just 1) and use this
dir c:\python* /b /ad > tmp1234.txt
@@ -16,6 +17,9 @@ del tmp1234.txt
cd build3
premake4 --double --midi --enable_openvr --enable_pybullet --python_include_dir="%myvar%/include" --python_lib_dir="%myvar%/libs" --targetdir="../bin" vs2010
premake4 --double --midi --enable_openvr --enable_pybullet --python_include_dir="%myvar%/include" --python_lib_dir="%myvar%/libs" --targetdir="../bin" vs2010
#premake4 --serial --audio --double --midi --enable_openvr --enable_pybullet --python_include_dir="%myvar%/include" --python_lib_dir="%myvar%/libs" --targetdir="../bin" vs2010
start vs2010

View File

@@ -0,0 +1,4 @@
mkdir build_cmake
cd build_cmake
cmake -DBUILD_PYBULLET=ON -DUSE_DOUBLE_PRECISION=ON -DCMAKE_BUILD_TYPE=Release -DPYTHON_INCLUDE_DIR=c:\python-3.5.2\include -DPYTHON_LIBRARY=c:\python-3.5.2\libs\python35.lib -DPYTHON_DEBUG_LIBRARY=c:\python-3.5.2\libs\python35_d.lib -G "Visual Studio 14 2015" ..
start .

View File

@@ -0,0 +1,3 @@
cd build3
premake5 --targetdir="../bin" vs2010
start vs2010

19
data/MPL/LICENSE.txt Normal file
View File

@@ -0,0 +1,19 @@
<!--
This file and the .stl mesh files referenced from it have been derived by Roboti LLC from the model of the Modular Prosthetic Limb developed by The Johns Hopkins University / Applied Physics Laboratory. The modifications are as follows: the original meshes have been replaced with their convex hulls; the original URDF model has been converted to the MJCF format and a number of MJCF-specific fields have been added.
The Johns Hopkins University / Applied Physics Laboratory has given Roboti LLC permission to distribute the modified model under the following license:
=========================
(C) 2013 The Johns Hopkins University / Applied Physics Laboratory All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
========================
The modifications made by Roboti LLC are also licensed under the Apache License version 2.0.
-->

473
data/MPL/MPL.xml Normal file
View File

@@ -0,0 +1,473 @@
<mujoco model="MPL">
<!--
This file and the .stl mesh files referenced from it have been derived by Roboti LLC from the model of the Modular Prosthetic Limb developed by The Johns Hopkins University / Applied Physics Laboratory. The modifications are as follows: the original meshes have been replaced with their convex hulls; the original URDF model has been converted to the MJCF format and a number of MJCF-specific fields have been added.
The Johns Hopkins University / Applied Physics Laboratory has given Roboti LLC permission to distribute the modified model under the following license:
=========================
(C) 2013 The Johns Hopkins University / Applied Physics Laboratory All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
========================
The modifications made by Roboti LLC are also licensed under the Apache License version 2.0.
-->
<compiler angle="radian" meshdir="mesh/" texturedir="texture/"/>
<option timestep="0.002" iterations="50" apirate="50"/>
<size njmax="600" nconmax="150" nstack="300000"/>
<default>
<default class="MPL">
<geom material="MatMesh" contype="1" conaffinity="1" condim="4" margin="0.001"/>
<joint limited="true" damping="0.2" armature=".01"/>
<site material="MatTouch" type="ellipsoid" group="3"/>
<position ctrllimited="true" kp="10"/>
</default>
<default class="IMU">
<site material="MatIMU" type="box" group="4"/>
</default>
<default class="free">
<joint type="free" damping="0" armature="0" limited="false"/>
</default>
</default>
<statistic extent="1" center="0 -0.2 0.2"/>
<visual>
<quality shadowsize="2048"/>
<map fogstart="6" fogend="10"/>
<headlight diffuse=".6 .6 .6" specular="0 0 0"/>
</visual>
<asset>
<mesh name="index0" file="index0_collision.stl"/>
<mesh name="index1" file="index1_collision.stl"/>
<mesh name="index2" file="index2_collision.stl"/>
<mesh name="index3" file="index3_collision.stl"/>
<mesh name="middle0" file="middle0_collision.stl"/>
<mesh name="middle1" file="middle1_collision.stl"/>
<mesh name="middle2" file="middle2_collision.stl"/>
<mesh name="middle3" file="middle3_collision.stl"/>
<mesh name="palm" file="palm.stl"/>
<mesh name="pinky0" file="pinky0_collision.stl"/>
<mesh name="pinky1" file="pinky1_collision.stl"/>
<mesh name="pinky2" file="pinky2_collision.stl"/>
<mesh name="pinky3" file="pinky3_collision.stl"/>
<mesh name="ring0" file="ring0_collision.stl"/>
<mesh name="ring1" file="ring1_collision.stl"/>
<mesh name="ring2" file="ring2_collision.stl"/>
<mesh name="ring3" file="ring3_collision.stl"/>
<mesh name="thumb0" file="thumb0_collision.stl"/>
<mesh name="thumb1" file="thumb1_collision.stl"/>
<mesh name="thumb2" file="thumb2_collision.stl"/>
<mesh name="thumb3" file="thumb3_collision.stl"/>
<mesh name="wristx" file="wristx_collision.stl"/>
<mesh name="wristy" file="wristy_collision.stl"/>
<mesh name="wristz" file="wristz_collision.stl"/>
<texture type="skybox" builtin="gradient" rgb1=".4 .6 .8" rgb2="0 0 0"
width="100" height="100"/>
<texture name="groundplane" type="2d" builtin="checker" rgb1=".2 .3 .4" rgb2=".1 .2 .3"
width="100" height="100"/>
<texture name="skin" type="cube" file="skin.png"/>
<texture name="marble2d" type="2d" file="marble.png"/>
<texture name="marblecube" type="cube" file="marble.png"/>
<material name="groundplane" texture="groundplane" texrepeat="10 10"/>
<material name="table2d" texture="marble2d" reflectance="0.3" rgba=".8 .8 .8 1"/>
<material name="tablecube" texture="marblecube" rgba=".8 .8 .8 1"/>
<material name="MatTouch" rgba=".3 .9 .3 .3"/>
<material name="MatIMU" rgba=".1 .1 .9 1"/>
<material name="MatMesh" texture="skin"/>
</asset>
<contact>
<exclude body1="wristz" body2="wristy"/>
<exclude body1="wristx" body2="thumb0"/>
<exclude body1="palm" body2="thumb1"/>
<exclude body1="palm" body2="index1"/>
<exclude body1="palm" body2="middle1"/>
<exclude body1="palm" body2="ring1"/>
<exclude body1="palm" body2="pinky1"/>
</contact>
<worldbody>
<!-- ======= ROBOT ======= -->
<body childclass="MPL" name="forearm" pos="0 -0.35 0.2" axisangle="0 0 1 3.141592">
<geom type="cylinder" size="0.02 0.01" zaxis="0 1 0"/>
<body name="wristy" pos="0 0 0">
<inertial pos="-7.08369e-005 -0.0217787 -0.000286168" quat="0.707488 0.00581744 -0.0107421 0.70662" mass="0.0272932" diaginertia="2.46813e-005 1.77029e-005 1.71079e-005" />
<geom type="mesh" mesh="wristy"/>
<joint name="wrist_PRO" type="hinge" damping="0.4" pos="0 0 0" axis="0 1 0" range="-1.57 1.57"/>
<body name="wristx" pos="-3.36826e-005 -0.0476452 0.00203763">
<inertial pos="0.00139174 -0.00975189 -0.00252668" quat="-0.0729226 0.705959 0.0352732 0.703605" mass="0.010691" diaginertia="5.04455e-006 4.25035e-006 3.25677e-006" />
<joint name="wrist_UDEV" damping="0.4" type="hinge" pos="0 0 0" axis="0 0 -1" range="-0.261 0.785"/>
<geom type="mesh" mesh="wristx"/>
<body name="wristz" pos="0.0001872 -0.03 -0.002094">
<inertial pos="0.000579016 -0.00125952 0.000455968" quat="0.527723 0.475346 0.521597 0.472749" mass="0.00602247" diaginertia="1.58133e-006 1.43102e-006 1.26861e-006" />
<joint name="wrist_FLEX" damping="0.4" type="hinge" pos="0 0 0" axis="1 0 0" range="-1.04 1.04"/>
<geom type="mesh" mesh="wristz"/>
<!-- ======= PALM ======= -->
<body name="palm" pos="0.025625 0 0">
<inertial pos="-0.0217876 -0.0376147 0.00276997" quat="-0.146373 0.723094 0.0985561 0.66783" mass="0.119867" diaginertia="0.000123088 0.000100082 6.89467e-005" />
<geom type="mesh" mesh="palm"/>
<site name="palm_thumb" pos="-0.0052 -0.0438 -0.0182" size=".017 .03 .01"/>
<site name="palm_pinky" pos="-0.0358 -0.0401 -0.0183" size=".017 .03 .01"/>
<site name="palm_side" pos="-0.0604 -0.0329 -0.0048" size=".01 .03 .015"/>
<site name="palm_back" pos="-0.0246 -0.0446 0.018" size=".03 .035 .015"/>
<!-- ======= THUMB ======= -->
<body name="thumb0" pos="0.00835752 -0.0206978 -0.010093" quat="0.990237 0.0412644 -0.0209178 -0.13149">
<inertial pos="0.00863339 -0.000156884 -0.000945846" quat="0.408795 0.551643 0.541079 0.485602" mass="0.00336696" diaginertia="4.50769e-007 4.48758e-007 2.35017e-007" />
<joint name="thumb_ABD" type="hinge" pos="0 0 0" axis="0 1 0" range="0 2.07"/>
<geom type="mesh" mesh="thumb0"/>
<body name="thumb1" pos="0.0209172 -0.00084 0.0014476">
<inertial pos="0.019024 0.000361131 -0.000186763" quat="0.5208 0.469572 0.484571 0.522934" mass="0.00596213" diaginertia="9.88001e-007 9.45125e-007 5.32989e-007" />
<joint name="thumb_MCP" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 1.03"/>
<geom type="mesh" mesh="thumb1"/>
<site name="thumb_proximal" pos="0.0173 -0.008 0.0009" size=".015 .0075 .01"/>
<body name="thumb2" pos="0.0335 0 -0.0007426">
<inertial pos="0.0188965 0.000375725 0.00065381" quat="0.502274 0.484638 0.475673 0.535333" mass="0.00599792" diaginertia="9.96692e-007 9.64948e-007 5.14416e-007" />
<joint name="thumb_PIP" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 1.03"/>
<geom type="mesh" mesh="thumb2"/>
<site name="thumb_medial" pos="0.0182 -0.008 0.0015" size=".015 .0075 .01"/>
<body name="thumb3" pos="0.0335 0 0.0010854">
<inertial pos="0.0188965 0.000375725 0.00065381" quat="0.502274 0.484638 0.475673 0.535333" mass="0.00599792" diaginertia="9.96692e-007 9.64948e-007 5.14416e-007" />
<joint name="thumb_DIP" type="hinge" pos="0 0 0" axis="0 0 -1" range="-0.819 1.28"/>
<geom type="mesh" mesh="thumb3"/>
<site name="thumb_distal" pos="0.0156 -0.007 0.0003" size=".015 .0075 .01" axisangle="0 0 1 0.2"/>
<site class="IMU" name="thumb_IMU" pos="0.0099 -0.00052 0" quat=".5 .5 .5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= INDEX ======= -->
<body name="index0" pos="0.00986485 -0.0658 0.00101221" quat="0.996195 0 0.0871557 0">
<inertial pos="-0.000142572 -0.00548494 0.000206145" quat="0.699132 0.714861 -0.000723869 0.013694" mass="0.00295579" diaginertia="4.22462e-007 4.02281e-007 1.93868e-007" />
<joint name="index_ABD" type="hinge" pos="0 0 0" axis="0 0 1" range="0 0.345"/>
<geom type="mesh" mesh="index0"/>
<body name="index1" pos="6.26e-005 -0.018 0">
<inertial pos="0.000406487 -0.0213125 0.000655609" quat="0.698452 0.715642 -0.00415384 0.0023049" mass="0.00478235" diaginertia="8.18599e-007 7.95693e-007 3.06254e-007" />
<joint name="index_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="index1"/>
<site name="index_proximal" pos="0 -0.0235 -0.007" size=".009 .015 .0075"/>
<body name="index2" pos="0.001086 -0.0435 0.0005">
<inertial pos="-0.000841462 -0.012689 0.000572665" quat="0.734882 0.677481 -0.028511 0.0124827" mass="0.00344764" diaginertia="3.63962e-007 3.59059e-007 1.05304e-007" />
<joint name="index_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.72"/>
<geom type="mesh" mesh="index2"/>
<site name="index_medial" pos="0 -0.009 -0.0047" size=".0075 .01 .006"/>
<body name="index3" pos="-0.000635 -0.0245 0">
<inertial pos="4.32004e-005 -0.0125318 0.000903476" quat="0.516251 0.4829 -0.483241 0.516498" mass="0.00274415" diaginertia="1.19635e-007 1.09202e-007 7.77873e-008" />
<joint name="index_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="index3"/>
<site name="index_distal" pos="0 -0.0132 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="index_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= MIDDLE ======= -->
<body name="middle0" pos="-0.012814 -0.0779014 0.00544608" quat="-3.14 0.0436194 0 0">
<inertial pos="-0.000142567 -0.00548493 0.000206162" quat="0.699131 0.714862 -0.000723874 0.013694" mass="0.00295579" diaginertia="4.22461e-007 4.02281e-007 1.93868e-007" />
<!--<joint name="middle0" type="hinge" pos="0 0 0" range="-0.345 0" axis="0 0 -1" />-->
<geom type="mesh" mesh="middle0"/>
<body name="middle1" pos="6.26e-005 -0.018 0">
<inertial pos="0.000406411 -0.0213125 0.00065565" quat="0.698451 0.715642 -0.00415503 0.00230486" mass="0.00478229" diaginertia="8.18595e-007 7.9569e-007 3.06253e-007" />
<joint name="middle_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="middle1"/>
<site name="middle_proximal" pos="0 -0.025 -0.007" size=".009 .015 .0075"/>
<body name="middle2" pos="0.001086 -0.0435 0.0005">
<inertial pos="-0.000841444 -0.012689 0.00057266" quat="0.734883 0.677482 -0.0284727 0.0124412" mass="0.00344765" diaginertia="3.63962e-007 3.5906e-007 1.05304e-007" />
<joint name="middle_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.73"/>
<geom type="mesh" mesh="middle2"/>
<site name="middle_medial" pos="0 -0.0146 -0.0047" size=".0075 .01 .006"/>
<body name="middle3" pos="-0.000635 -0.0245 0">
<inertial pos="4.31236e-005 -0.0125318 0.000903446" quat="0.516263 0.482913 -0.483228 0.516487" mass="0.00274417" diaginertia="1.19635e-007 1.09202e-007 7.77884e-008" />
<joint name="middle_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="middle3"/>
<site name="middle_distal" pos="0 -0.0129 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="middle_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= RING ======= -->
<body name="ring0" pos="-0.0354928 -0.0666999 0.00151221" quat="0.996195 0 -0.0871557 0">
<inertial pos="-0.000142559 -0.00548494 0.000206147" quat="0.699132 0.714861 -0.000720946 0.013691" mass="0.00295579" diaginertia="4.22462e-007 4.02281e-007 1.93868e-007" />
<joint name="ring_ABD" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 0.345"/>
<geom type="mesh" mesh="ring0"/>
<body name="ring1" pos="6.26e-005 -0.018 0">
<inertial pos="0.000406447 -0.0213125 0.00065563" quat="0.698451 0.715642 -0.00415675 0.00230715" mass="0.00478232" diaginertia="8.18597e-007 7.95692e-007 3.06254e-007" />
<joint name="ring_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="ring1"/>
<site name="ring_proximal" pos="0 -0.0259 -0.007" size=".009 .015 .0075"/>
<body name="ring2" pos="0.001086 -0.0435 0.0005">
<inertial pos="-0.000841518 -0.012689 0.000572674" quat="0.73488 0.677478 -0.0285773 0.0125557" mass="0.00344767" diaginertia="3.63963e-007 3.59061e-007 1.05305e-007" />
<joint name="ring_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.72"/>
<geom type="mesh" mesh="ring2"/>
<site name="ring_medial" pos="0 -0.0137 -0.0047" size=".0075 .01 .006"/>
<body name="ring3" pos="-0.000635 -0.0245 0">
<inertial pos="4.31973e-005 -0.0125318 0.000903457" quat="0.516255 0.482902 -0.483238 0.516495" mass="0.00274416" diaginertia="1.19635e-007 1.09202e-007 7.77877e-008" />
<joint name="ring_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="ring3"/>
<site name="ring_distal" pos="0 -0.0117 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="ring_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= LITTLE ======= -->
<body name="pinky0" pos="-0.0562459 -0.0554001 -0.00563858" quat="0.996195 0 -0.0871557 0">
<inertial pos="-0.000142559 -0.00538484 0.000206147" quat="0.699132 0.714861 -0.000721037 0.0136911" mass="0.00295579" diaginertia="4.22462e-007 4.02281e-007 1.93868e-007" />
<joint name="pinky_ABD" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 0.345"/>
<geom type="mesh" mesh="pinky0"/>
<body name="pinky1" pos="6.26e-005 -0.0178999 0">
<inertial pos="0.000458624 -0.0160478 0.000924735" quat="0.685529 0.72723 0.021252 -0.0270914" mass="0.0034099" diaginertia="4.03391e-007 3.84061e-007 2.19866e-007" />
<joint name="pinky_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="pinky1"/>
<site name="pinky_proximal" pos="0 -0.021 -0.0066" size=".009 .013 .0075"/>
<body name="pinky2" pos="0.000578 -0.033 0.0005">
<inertial pos="-0.000270832 -0.00914628 0.000738493" quat="0.746786 0.664476 -4.11065e-005 -0.0279675" mass="0.00250622" diaginertia="1.79089e-007 1.75934e-007 7.44543e-008" />
<joint name="pinky_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.72"/>
<geom type="mesh" mesh="pinky2"/>
<site name="pinky_medial" pos="0 -0.0117 -0.0047" size=".0075 .01 .006"/>
<body name="pinky3" pos="-4.78e-005 -0.0175 0">
<inertial pos="3.85026e-005 -0.0125047 0.000912295" quat="0.516037 0.484447 -0.483043 0.515448" mass="0.00273265" diaginertia="1.19141e-007 1.08629e-007 7.77271e-008" />
<joint name="pinky_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="pinky3"/>
<site name="pinky_distal" pos="0 -0.0121 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="pinky_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
</body>
</body>
</body>
</body>
</body>
</worldbody>
<sensor>
<jointpos name="Sjp_wrist_PRO" joint="wrist_PRO"/>
<jointpos name="Sjp_wrist_UDEV" joint="wrist_UDEV"/>
<jointpos name="Sjp_wrist_FLEX" joint="wrist_FLEX"/>
<jointpos name="Sjp_thumb_ABD" joint="thumb_ABD"/>
<jointpos name="Sjp_thumb_MCP" joint="thumb_MCP"/>
<jointpos name="Sjp_thumb_PIP" joint="thumb_PIP"/>
<jointpos name="Sjp_thumb_DIP" joint="thumb_DIP"/>
<jointpos name="Sjp_index_ABD" joint="index_ABD"/>
<jointpos name="Sjp_index_MCP" joint="index_MCP"/>
<jointpos name="Sjp_index_PIP" joint="index_PIP"/>
<jointpos name="Sjp_index_DIP" joint="index_DIP"/>
<jointpos name="Sjp_middle_MCP" joint="middle_MCP"/>
<jointpos name="Sjp_middle_PIP" joint="middle_PIP"/>
<jointpos name="Sjp_middle_DIP" joint="middle_DIP"/>
<jointpos name="Sjp_ring_ABD" joint="ring_ABD"/>
<jointpos name="Sjp_ring_MCP" joint="ring_MCP"/>
<jointpos name="Sjp_ring_PIP" joint="ring_PIP"/>
<jointpos name="Sjp_ring_DIP" joint="ring_DIP"/>
<jointpos name="Sjp_pinky_ABD" joint="pinky_ABD"/>
<jointpos name="Sjp_pinky_MCP" joint="pinky_MCP"/>
<jointpos name="Sjp_pinky_PIP" joint="pinky_PIP"/>
<jointpos name="Sjp_pinky_DIP" joint="pinky_DIP"/>
<jointvel name="Sjv_wrist_PRO" joint="wrist_PRO"/>
<jointvel name="Sjv_wrist_UDEV" joint="wrist_UDEV"/>
<jointvel name="Sjv_wrist_FLEX" joint="wrist_FLEX"/>
<jointvel name="Sjv_thumb_ABD" joint="thumb_ABD"/>
<jointvel name="Sjv_thumb_MCP" joint="thumb_MCP"/>
<jointvel name="Sjv_thumb_PIP" joint="thumb_PIP"/>
<jointvel name="Sjv_thumb_DIP" joint="thumb_DIP"/>
<jointvel name="Sjv_index_ABD" joint="index_ABD"/>
<jointvel name="Sjv_index_MCP" joint="index_MCP"/>
<jointvel name="Sjv_index_PIP" joint="index_PIP"/>
<jointvel name="Sjv_index_DIP" joint="index_DIP"/>
<jointvel name="Sjv_middle_MCP" joint="middle_MCP"/>
<jointvel name="Sjv_middle_PIP" joint="middle_PIP"/>
<jointvel name="Sjv_middle_DIP" joint="middle_DIP"/>
<jointvel name="Sjv_ring_ABD" joint="ring_ABD"/>
<jointvel name="Sjv_ring_MCP" joint="ring_MCP"/>
<jointvel name="Sjv_ring_PIP" joint="ring_PIP"/>
<jointvel name="Sjv_ring_DIP" joint="ring_DIP"/>
<jointvel name="Sjv_pinky_ABD" joint="pinky_ABD"/>
<jointvel name="Sjv_pinky_MCP" joint="pinky_MCP"/>
<jointvel name="Sjv_pinky_PIP" joint="pinky_PIP"/>
<jointvel name="Sjv_pinky_DIP" joint="pinky_DIP"/>
<actuatorpos name="Sap_wrist_PRO" actuator="A_wrist_PRO" />
<actuatorpos name="Sap_wrist_UDEV" actuator="A_wrist_UDEV" />
<actuatorpos name="Sap_wrist_FLEX" actuator="A_wrist_FLEX" />
<actuatorpos name="Sap_thumb_ABD" actuator="A_thumb_ABD" />
<actuatorpos name="Sap_thumb_MCP" actuator="A_thumb_MCP" />
<actuatorpos name="Sap_thumb_PIP" actuator="A_thumb_PIP" />
<actuatorpos name="Sap_thumb_DIP" actuator="A_thumb_DIP" />
<actuatorpos name="Sap_index_ABD" actuator="A_index_ABD" />
<actuatorpos name="Sap_index_MCP" actuator="A_index_MCP" />
<actuatorpos name="Sap_middle_MCP" actuator="A_middle_MCP"/>
<actuatorpos name="Sap_ring_MCP" actuator="A_ring_MCP" />
<actuatorpos name="Sap_pinky_ABD" actuator="A_pinky_ABD" />
<actuatorpos name="Sap_pinky_MCP" actuator="A_pinky_MCP" />
<actuatorvel name="Sav_wrist_PRO" actuator="A_wrist_PRO" />
<actuatorvel name="Sav_wrist_UDEV" actuator="A_wrist_UDEV"/>
<actuatorvel name="Sav_wrist_FLEX" actuator="A_wrist_FLEX"/>
<actuatorvel name="Sav_thumb_ABD" actuator="A_thumb_ABD" />
<actuatorvel name="Sav_thumb_MCP" actuator="A_thumb_MCP" />
<actuatorvel name="Sav_thumb_PIP" actuator="A_thumb_PIP" />
<actuatorvel name="Sav_thumb_DIP" actuator="A_thumb_DIP" />
<actuatorvel name="Sav_index_ABD" actuator="A_index_ABD" />
<actuatorvel name="Sav_index_MCP" actuator="A_index_MCP" />
<actuatorvel name="Sav_middle_MCP" actuator="A_middle_MCP"/>
<actuatorvel name="Sav_ring_MCP" actuator="A_ring_MCP" />
<actuatorvel name="Sav_pinky_ABD" actuator="A_pinky_ABD" />
<actuatorvel name="Sav_pinky_MCP" actuator="A_pinky_MCP" />
<actuatorfrc name="Saf_wrist_PRO" actuator="A_wrist_PRO"/>
<actuatorfrc name="Saf_wrist_UDEV" actuator="A_wrist_UDEV"/>
<actuatorfrc name="Saf_wrist_FLEX" actuator="A_wrist_FLEX"/>
<actuatorfrc name="Saf_thumb_ABD" actuator="A_thumb_ABD"/>
<actuatorfrc name="Saf_thumb_MCP" actuator="A_thumb_MCP"/>
<actuatorfrc name="Saf_thumb_PIP" actuator="A_thumb_PIP"/>
<actuatorfrc name="Saf_thumb_DIP" actuator="A_thumb_DIP"/>
<actuatorfrc name="Saf_index_ABD" actuator="A_index_ABD"/>
<actuatorfrc name="Saf_index_MCP" actuator="A_index_MCP"/>
<actuatorfrc name="Saf_middle_MCP" actuator="A_middle_MCP"/>
<actuatorfrc name="Saf_ring_MCP" actuator="A_ring_MCP"/>
<actuatorfrc name="Saf_pinky_ABD" actuator="A_pinky_ABD"/>
<actuatorfrc name="Saf_pinky_MCP" actuator="A_pinky_MCP"/>
<accelerometer name="S_thumb_IMU" site="thumb_IMU"/>
<accelerometer name="S_index_IMU" site="index_IMU"/>
<accelerometer name="S_middle_IMU" site="middle_IMU"/>
<accelerometer name="S_ring_IMU" site="ring_IMU"/>
<accelerometer name="S_pinky_IMU" site="pinky_IMU"/>
<gyro site="thumb_IMU"/>
<gyro site="index_IMU"/>
<gyro site="middle_IMU"/>
<gyro site="ring_IMU"/>
<gyro site="pinky_IMU"/>
<touch name="S_palm_thumb" site="palm_thumb"/>
<touch name="S_palm_pinky" site="palm_pinky"/>
<touch name="S_palm_side" site="palm_side"/>
<touch name="S_palm_back" site="palm_back"/>
<touch name="S_thumb_proximal" site="thumb_proximal"/>
<touch name="S_thumb_medial" site="thumb_medial"/>
<touch name="S_thumb_distal" site="thumb_distal"/>
<touch name="S_index_proximal" site="index_proximal"/>
<touch name="S_index_medial" site="index_medial"/>
<touch name="S_index_distal" site="index_distal"/>
<touch name="S_middle_proximal" site="middle_proximal"/>
<touch name="S_middle_medial" site="middle_medial"/>
<touch name="S_middle_distal" site="middle_distal"/>
<touch name="S_ring_proximal" site="ring_proximal"/>
<touch name="S_ring_medial" site="ring_medial"/>
<touch name="S_ring_distal" site="ring_distal"/>
<touch name="S_pinky_proximal" site="pinky_proximal"/>
<touch name="S_pinky_medial" site="pinky_medial"/>
<touch name="S_pinky_distal" site="pinky_distal"/>
</sensor>
<tendon>
<!--Index coupler tendons-->
<fixed name="T_index32_cpl" range="0 1">
<joint joint="index_DIP" coef="0.00705"/>
<joint joint="index_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_index21_cpl" range="0 1">
<joint joint="index_PIP" coef="0.010"/>
<joint joint="index_MCP" coef="-0.010"/>
</fixed>
<!--Middle coupler tendons-->
<fixed name="T_middle32_cpl">
<joint joint="middle_DIP" coef="0.00705"/>
<joint joint="middle_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_middle21_cpl">
<joint joint="middle_PIP" coef="0.010"/>
<joint joint="middle_MCP" coef="-0.010"/>
</fixed>
<!--Ring coupler tendons-->
<fixed name="T_ring32_cpl">
<joint joint="ring_DIP" coef="0.00705"/>
<joint joint="ring_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_ring21_cpl">
<joint joint="ring_PIP" coef="0.010"/>
<joint joint="ring_MCP" coef="-0.010"/>
</fixed>
<!--Little coupler tendons-->
<fixed name="T_pinky32_cpl">
<joint joint="pinky_DIP" coef="0.00705"/>
<joint joint="pinky_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_pinky21_cpl">
<joint joint="pinky_PIP" coef="0.010"/>
<joint joint="pinky_MCP" coef="-0.010"/>
</fixed>
</tendon>
<equality>
<weld body1="mocap" body2="forearm" solref="0.01 1" solimp=".9 .9 0.01"/>
<!-- DIP-PIP-MCP Couplings -->
<tendon name="E_index32_cpl" tendon1="T_index32_cpl"/>
<tendon name="E_index21_cpl" tendon1="T_index21_cpl"/>
<tendon name="E_middle32_cpl" tendon1="T_middle32_cpl"/>
<tendon name="E_middle21_cpl" tendon1="T_middle21_cpl"/>
<tendon name="E_ring32_cpl" tendon1="T_ring32_cpl"/>
<tendon name="E_ring21_cpl" tendon1="T_ring21_cpl"/>
<tendon name="E_pinky32_cpl" tendon1="T_pinky32_cpl"/>
<tendon name="E_pinky21_cpl" tendon1="T_pinky21_cpl"/>
<!-- AD-AB Coupling -->
<joint name="ring_pinky_cpl" joint1="ring_ABD" joint2="pinky_ABD" polycoef="0 0.5 0 0 0"/>
</equality>
<actuator>
<!-- Wrist -->
<position name="A_wrist_PRO" class="MPL" joint="wrist_PRO" ctrlrange="-1.57 1.57"/>
<position name="A_wrist_UDEV" class="MPL" joint="wrist_UDEV" ctrlrange="-0.26 0.79"/>
<position name="A_wrist_FLEX" class="MPL" joint="wrist_FLEX" ctrlrange="-1 1"/>
<!-- Thumb -->
<position name="A_thumb_ABD" class="MPL" joint="thumb_ABD" ctrlrange="0 2.1"/>
<position name="A_thumb_MCP" class="MPL" joint="thumb_MCP" ctrlrange="0 1.0"/>
<position name="A_thumb_PIP" class="MPL" joint="thumb_PIP" ctrlrange="0 1.0"/>
<position name="A_thumb_DIP" class="MPL" joint="thumb_DIP" ctrlrange="-0.82 1.3"/>
<!-- Fingers -->
<position name="A_index_ABD" class="MPL" joint="index_ABD" ctrlrange="0 0.34"/>
<position name="A_index_MCP" class="MPL" joint="index_MCP" ctrlrange="0 1.6"/>
<position name="A_middle_MCP" class="MPL" joint="middle_MCP" ctrlrange="0 1.6"/>
<position name="A_ring_MCP" class="MPL" joint="ring_MCP" ctrlrange="0 1.6"/>
<position name="A_pinky_ABD" class="MPL" joint="pinky_ABD" ctrlrange="0 0.34"/>
<position name="A_pinky_MCP" class="MPL" joint="pinky_MCP" ctrlrange="0 1.6"/>
</actuator>
</mujoco>

BIN
data/MPL/mesh/index0.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/index1.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/index2.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/index3.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/middle0.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/middle1.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/middle2.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/middle3.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/palm.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/pinky0.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/pinky1.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/pinky2.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/pinky3.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/ring0.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/ring1.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/ring2.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/ring3.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/thumb0.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/thumb1.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/thumb2.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/thumb3.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/wristx.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/wristy.stl Normal file

Binary file not shown.

Binary file not shown.

BIN
data/MPL/mesh/wristz.stl Normal file

Binary file not shown.

Binary file not shown.

471
data/MPL/mpl2.xml Normal file
View File

@@ -0,0 +1,471 @@
<mujoco model="MPL">
<!--
This file and the .stl mesh files referenced from it have been derived by Roboti LLC from the model of the Modular Prosthetic Limb developed by The Johns Hopkins University / Applied Physics Laboratory. The modifications are as follows: the original meshes have been replaced with their convex hulls; the original URDF model has been converted to the MJCF format and a number of MJCF-specific fields have been added.
The Johns Hopkins University / Applied Physics Laboratory has given Roboti LLC permission to distribute the modified model under the following license:
=========================
(C) 2013 The Johns Hopkins University / Applied Physics Laboratory All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
========================
The modifications made by Roboti LLC are also licensed under the Apache License version 2.0.
-->
<compiler angle="radian" meshdir="mesh/" texturedir="texture/"/>
<option timestep="0.002" iterations="50" apirate="50"/>
<size njmax="600" nconmax="150" nstack="300000"/>
<default>
<default class="MPL">
<geom material="MatMesh" contype="1" conaffinity="1" condim="4" friction="1 .5 0.5" margin="0.001"/>
<joint limited="true" damping="0.2" armature=".01"/>
<site material="MatTouch" type="ellipsoid" group="3"/>
<position ctrllimited="true" kp="10"/>
</default>
<default class="IMU">
<site material="MatIMU" type="box" group="4"/>
</default>
<default class="free">
<joint type="free" damping="0" armature="0" limited="false"/>
</default>
</default>
<statistic extent="1" center="0 -0.2 0.2"/>
<visual>
<quality shadowsize="2048"/>
<map fogstart="6" fogend="10"/>
<headlight diffuse=".6 .6 .6" specular="0 0 0"/>
</visual>
<asset>
<mesh name="index0" file="index0_collision.stl"/>
<mesh name="index1" file="index1_collision.stl"/>
<mesh name="index2" file="index2_collision.stl"/>
<mesh name="index3" file="index3_collision.stl"/>
<mesh name="middle0" file="middle0_collision.stl"/>
<mesh name="middle1" file="middle1_collision.stl"/>
<mesh name="middle2" file="middle2_collision.stl"/>
<mesh name="middle3" file="middle3_collision.stl"/>
<mesh name="palm" file="palm_collision.stl"/>
<mesh name="pinky0" file="pinky0_collision.stl"/>
<mesh name="pinky1" file="pinky1_collision.stl"/>
<mesh name="pinky2" file="pinky2_collision.stl"/>
<mesh name="pinky3" file="pinky3_collision.stl"/>
<mesh name="ring0" file="ring0_collision.stl"/>
<mesh name="ring1" file="ring1_collision.stl"/>
<mesh name="ring2" file="ring2_collision.stl"/>
<mesh name="ring3" file="ring3_collision.stl"/>
<mesh name="thumb0" file="thumb0_collision.stl"/>
<mesh name="thumb1" file="thumb1_collision.stl"/>
<mesh name="thumb2" file="thumb2_collision.stl"/>
<mesh name="thumb3" file="thumb3_collision.stl"/>
<mesh name="wristx" file="wristx_collision.stl"/>
<mesh name="wristy" file="wristy_collision.stl"/>
<mesh name="wristz" file="wristz_collision.stl"/>
<texture type="skybox" builtin="gradient" rgb1=".4 .6 .8" rgb2="0 0 0"
width="100" height="100"/>
<texture name="groundplane" type="2d" builtin="checker" rgb1=".2 .3 .4" rgb2=".1 .2 .3"
width="100" height="100"/>
<texture name="skin" type="cube" file="skin.png"/>
<texture name="marble2d" type="2d" file="marble.png"/>
<texture name="marblecube" type="cube" file="marble.png"/>
<material name="groundplane" texture="groundplane" texrepeat="10 10"/>
<material name="table2d" texture="marble2d" reflectance="0.3" rgba=".8 .8 .8 1"/>
<material name="tablecube" texture="marblecube" rgba=".8 .8 .8 1"/>
<material name="MatTouch" rgba=".3 .9 .3 .3"/>
<material name="MatIMU" rgba=".1 .1 .9 1"/>
<material name="MatMesh" texture="skin"/>
</asset>
<contact>
<exclude body1="wristz" body2="wristy"/>
<exclude body1="wristx" body2="thumb0"/>
<exclude body1="palm" body2="thumb1"/>
<exclude body1="palm" body2="index1"/>
<exclude body1="palm" body2="middle1"/>
<exclude body1="palm" body2="ring1"/>
<exclude body1="palm" body2="pinky1"/>
</contact>
<worldbody>
<!-- ======= ROBOT ======= -->
<body childclass="MPL" name="wristy" pos="0 0 0">
<inertial pos="-7.08369e-005 -0.0217787 -0.000286168" quat="0.707488 0.00581744 -0.0107421 0.70662" mass="0.0272932" diaginertia="2.46813e-005 1.77029e-005 1.71079e-005" />
<geom type="mesh" mesh="wristy"/>
<joint type="free"/>
<body name="wristx" pos="-3.36826e-005 -0.0476452 0.00203763">
<inertial pos="0.00139174 -0.00975189 -0.00252668" quat="-0.0729226 0.705959 0.0352732 0.703605" mass="0.010691" diaginertia="5.04455e-006 4.25035e-006 3.25677e-006" />
<joint name="wrist_UDEV" damping="0.4" type="hinge" pos="0 0 0" axis="0 0 -1" range="-0.261 0.785"/>
<geom type="mesh" mesh="wristx"/>
<body name="wristz" pos="0.0001872 -0.03 -0.002094">
<inertial pos="0.000579016 -0.00125952 0.000455968" quat="0.527723 0.475346 0.521597 0.472749" mass="0.00602247" diaginertia="1.58133e-006 1.43102e-006 1.26861e-006" />
<joint name="wrist_FLEX" damping="0.4" type="hinge" pos="0 0 0" axis="1 0 0" range="-1.04 1.04"/>
<geom type="mesh" mesh="wristz"/>
<!-- ======= PALM ======= -->
<body name="palm" pos="0.025625 0 0">
<inertial pos="-0.0217876 -0.0376147 0.00276997" quat="-0.146373 0.723094 0.0985561 0.66783" mass="0.119867" diaginertia="0.000123088 0.000100082 6.89467e-005" />
<geom type="mesh" mesh="palm"/>
<site name="palm_thumb" pos="-0.0052 -0.0438 -0.0182" size=".017 .03 .01"/>
<site name="palm_pinky" pos="-0.0358 -0.0401 -0.0183" size=".017 .03 .01"/>
<site name="palm_side" pos="-0.0604 -0.0329 -0.0048" size=".01 .03 .015"/>
<site name="palm_back" pos="-0.0246 -0.0446 0.018" size=".03 .035 .015"/>
<!-- ======= THUMB ======= -->
<body name="thumb0" pos="0.00835752 -0.0206978 -0.010093" quat="0.990237 0.0412644 -0.0209178 -0.13149">
<inertial pos="0.00863339 -0.000156884 -0.000945846" quat="0.408795 0.551643 0.541079 0.485602" mass="0.00336696" diaginertia="4.50769e-007 4.48758e-007 2.35017e-007" />
<joint name="thumb_ABD" type="hinge" pos="0 0 0" axis="0 1 0" range="0 2.07"/>
<geom type="mesh" mesh="thumb0"/>
<body name="thumb1" pos="0.0209172 -0.00084 0.0014476">
<inertial pos="0.019024 0.000361131 -0.000186763" quat="0.5208 0.469572 0.484571 0.522934" mass="0.00596213" diaginertia="9.88001e-007 9.45125e-007 5.32989e-007" />
<joint name="thumb_MCP" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 1.03"/>
<geom type="mesh" mesh="thumb1"/>
<site name="thumb_proximal" pos="0.0173 -0.008 0.0009" size=".015 .0075 .01"/>
<body name="thumb2" pos="0.0335 0 -0.0007426">
<inertial pos="0.0188965 0.000375725 0.00065381" quat="0.502274 0.484638 0.475673 0.535333" mass="0.00599792" diaginertia="9.96692e-007 9.64948e-007 5.14416e-007" />
<joint name="thumb_PIP" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 1.03"/>
<geom type="mesh" mesh="thumb2"/>
<site name="thumb_medial" pos="0.0182 -0.008 0.0015" size=".015 .0075 .01"/>
<body name="thumb3" pos="0.0335 0 0.0010854">
<inertial pos="0.0188965 0.000375725 0.00065381" quat="0.502274 0.484638 0.475673 0.535333" mass="0.00599792" diaginertia="9.96692e-007 9.64948e-007 5.14416e-007" />
<joint name="thumb_DIP" type="hinge" pos="0 0 0" axis="0 0 -1" range="-0.819 1.28"/>
<geom type="mesh" mesh="thumb3"/>
<site name="thumb_distal" pos="0.0156 -0.007 0.0003" size=".015 .0075 .01" axisangle="0 0 1 0.2"/>
<site class="IMU" name="thumb_IMU" pos="0.0099 -0.00052 0" quat=".5 .5 .5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= INDEX ======= -->
<body name="index0" pos="0.00986485 -0.0658 0.00101221" quat="0.996195 0 0.0871557 0">
<inertial pos="-0.000142572 -0.00548494 0.000206145" quat="0.699132 0.714861 -0.000723869 0.013694" mass="0.00295579" diaginertia="4.22462e-007 4.02281e-007 1.93868e-007" />
<joint name="index_ABD" type="hinge" pos="0 0 0" axis="0 0 1" range="0 0.345"/>
<geom type="mesh" mesh="index0"/>
<body name="index1" pos="6.26e-005 -0.018 0">
<inertial pos="0.000406487 -0.0213125 0.000655609" quat="0.698452 0.715642 -0.00415384 0.0023049" mass="0.00478235" diaginertia="8.18599e-007 7.95693e-007 3.06254e-007" />
<joint name="index_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="index1"/>
<site name="index_proximal" pos="0 -0.0235 -0.007" size=".009 .015 .0075"/>
<body name="index2" pos="0.001086 -0.0435 0.0005">
<inertial pos="-0.000841462 -0.012689 0.000572665" quat="0.734882 0.677481 -0.028511 0.0124827" mass="0.00344764" diaginertia="3.63962e-007 3.59059e-007 1.05304e-007" />
<joint name="index_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.72"/>
<geom type="mesh" mesh="index2"/>
<site name="index_medial" pos="0 -0.009 -0.0047" size=".0075 .01 .006"/>
<body name="index3" pos="-0.000635 -0.0245 0">
<inertial pos="4.32004e-005 -0.0125318 0.000903476" quat="0.516251 0.4829 -0.483241 0.516498" mass="0.00274415" diaginertia="1.19635e-007 1.09202e-007 7.77873e-008" />
<joint name="index_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="index3"/>
<site name="index_distal" pos="0 -0.0132 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="index_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= MIDDLE ======= -->
<body name="middle0" pos="-0.012814 -0.0779014 0.00544608" quat="-3.14 0.0436194 0 0">
<inertial pos="-0.000142567 -0.00548493 0.000206162" quat="0.699131 0.714862 -0.000723874 0.013694" mass="0.00295579" diaginertia="4.22461e-007 4.02281e-007 1.93868e-007" />
<!--<joint name="middle0" type="hinge" pos="0 0 0" range="-0.345 0" axis="0 0 -1" />-->
<geom type="mesh" mesh="middle0"/>
<body name="middle1" pos="6.26e-005 -0.018 0">
<inertial pos="0.000406411 -0.0213125 0.00065565" quat="0.698451 0.715642 -0.00415503 0.00230486" mass="0.00478229" diaginertia="8.18595e-007 7.9569e-007 3.06253e-007" />
<joint name="middle_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="middle1"/>
<site name="middle_proximal" pos="0 -0.025 -0.007" size=".009 .015 .0075"/>
<body name="middle2" pos="0.001086 -0.0435 0.0005">
<inertial pos="-0.000841444 -0.012689 0.00057266" quat="0.734883 0.677482 -0.0284727 0.0124412" mass="0.00344765" diaginertia="3.63962e-007 3.5906e-007 1.05304e-007" />
<joint name="middle_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.73"/>
<geom type="mesh" mesh="middle2"/>
<site name="middle_medial" pos="0 -0.0146 -0.0047" size=".0075 .01 .006"/>
<body name="middle3" pos="-0.000635 -0.0245 0">
<inertial pos="4.31236e-005 -0.0125318 0.000903446" quat="0.516263 0.482913 -0.483228 0.516487" mass="0.00274417" diaginertia="1.19635e-007 1.09202e-007 7.77884e-008" />
<joint name="middle_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="middle3"/>
<site name="middle_distal" pos="0 -0.0129 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="middle_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= RING ======= -->
<body name="ring0" pos="-0.0354928 -0.0666999 0.00151221" quat="0.996195 0 -0.0871557 0">
<inertial pos="-0.000142559 -0.00548494 0.000206147" quat="0.699132 0.714861 -0.000720946 0.013691" mass="0.00295579" diaginertia="4.22462e-007 4.02281e-007 1.93868e-007" />
<joint name="ring_ABD" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 0.345"/>
<geom type="mesh" mesh="ring0"/>
<body name="ring1" pos="6.26e-005 -0.018 0">
<inertial pos="0.000406447 -0.0213125 0.00065563" quat="0.698451 0.715642 -0.00415675 0.00230715" mass="0.00478232" diaginertia="8.18597e-007 7.95692e-007 3.06254e-007" />
<joint name="ring_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="ring1"/>
<site name="ring_proximal" pos="0 -0.0259 -0.007" size=".009 .015 .0075"/>
<body name="ring2" pos="0.001086 -0.0435 0.0005">
<inertial pos="-0.000841518 -0.012689 0.000572674" quat="0.73488 0.677478 -0.0285773 0.0125557" mass="0.00344767" diaginertia="3.63963e-007 3.59061e-007 1.05305e-007" />
<joint name="ring_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.72"/>
<geom type="mesh" mesh="ring2"/>
<site name="ring_medial" pos="0 -0.0137 -0.0047" size=".0075 .01 .006"/>
<body name="ring3" pos="-0.000635 -0.0245 0">
<inertial pos="4.31973e-005 -0.0125318 0.000903457" quat="0.516255 0.482902 -0.483238 0.516495" mass="0.00274416" diaginertia="1.19635e-007 1.09202e-007 7.77877e-008" />
<joint name="ring_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="ring3"/>
<site name="ring_distal" pos="0 -0.0117 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="ring_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
<!-- ======= LITTLE ======= -->
<body name="pinky0" pos="-0.0562459 -0.0554001 -0.00563858" quat="0.996195 0 -0.0871557 0">
<inertial pos="-0.000142559 -0.00538484 0.000206147" quat="0.699132 0.714861 -0.000721037 0.0136911" mass="0.00295579" diaginertia="4.22462e-007 4.02281e-007 1.93868e-007" />
<joint name="pinky_ABD" type="hinge" pos="0 0 0" axis="0 0 -1" range="0 0.345"/>
<geom type="mesh" mesh="pinky0"/>
<body name="pinky1" pos="6.26e-005 -0.0178999 0">
<inertial pos="0.000458624 -0.0160478 0.000924735" quat="0.685529 0.72723 0.021252 -0.0270914" mass="0.0034099" diaginertia="4.03391e-007 3.84061e-007 2.19866e-007" />
<joint name="pinky_MCP" type="hinge" pos="0 0 0" axis="1 0 0" range="-0.785 1.57"/>
<geom type="mesh" mesh="pinky1"/>
<site name="pinky_proximal" pos="0 -0.021 -0.0066" size=".009 .013 .0075"/>
<body name="pinky2" pos="0.000578 -0.033 0.0005">
<inertial pos="-0.000270832 -0.00914628 0.000738493" quat="0.746786 0.664476 -4.11065e-005 -0.0279675" mass="0.00250622" diaginertia="1.79089e-007 1.75934e-007 7.44543e-008" />
<joint name="pinky_PIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.72"/>
<geom type="mesh" mesh="pinky2"/>
<site name="pinky_medial" pos="0 -0.0117 -0.0047" size=".0075 .01 .006"/>
<body name="pinky3" pos="-4.78e-005 -0.0175 0">
<inertial pos="3.85026e-005 -0.0125047 0.000912295" quat="0.516037 0.484447 -0.483043 0.515448" mass="0.00273265" diaginertia="1.19141e-007 1.08629e-007 7.77271e-008" />
<joint name="pinky_DIP" type="hinge" pos="0 0 0" axis="1 0 0" range="0 1.38"/>
<geom type="mesh" mesh="pinky3"/>
<site name="pinky_distal" pos="0 -0.0121 -0.0038" size=".0075 .01 .006"/>
<site class="IMU" name="pinky_IMU" pos="0 -0.0093 0.00063" quat=".5 .5 -.5 .5" size=".003 .003 .003"/>
</body>
</body>
</body>
</body>
</body>
</body>
</body>
</body>
</worldbody>
<sensor>
<jointpos name="Sjp_wrist_PRO" joint="wrist_PRO"/>
<jointpos name="Sjp_wrist_UDEV" joint="wrist_UDEV"/>
<jointpos name="Sjp_wrist_FLEX" joint="wrist_FLEX"/>
<jointpos name="Sjp_thumb_ABD" joint="thumb_ABD"/>
<jointpos name="Sjp_thumb_MCP" joint="thumb_MCP"/>
<jointpos name="Sjp_thumb_PIP" joint="thumb_PIP"/>
<jointpos name="Sjp_thumb_DIP" joint="thumb_DIP"/>
<jointpos name="Sjp_index_ABD" joint="index_ABD"/>
<jointpos name="Sjp_index_MCP" joint="index_MCP"/>
<jointpos name="Sjp_index_PIP" joint="index_PIP"/>
<jointpos name="Sjp_index_DIP" joint="index_DIP"/>
<jointpos name="Sjp_middle_MCP" joint="middle_MCP"/>
<jointpos name="Sjp_middle_PIP" joint="middle_PIP"/>
<jointpos name="Sjp_middle_DIP" joint="middle_DIP"/>
<jointpos name="Sjp_ring_ABD" joint="ring_ABD"/>
<jointpos name="Sjp_ring_MCP" joint="ring_MCP"/>
<jointpos name="Sjp_ring_PIP" joint="ring_PIP"/>
<jointpos name="Sjp_ring_DIP" joint="ring_DIP"/>
<jointpos name="Sjp_pinky_ABD" joint="pinky_ABD"/>
<jointpos name="Sjp_pinky_MCP" joint="pinky_MCP"/>
<jointpos name="Sjp_pinky_PIP" joint="pinky_PIP"/>
<jointpos name="Sjp_pinky_DIP" joint="pinky_DIP"/>
<jointvel name="Sjv_wrist_PRO" joint="wrist_PRO"/>
<jointvel name="Sjv_wrist_UDEV" joint="wrist_UDEV"/>
<jointvel name="Sjv_wrist_FLEX" joint="wrist_FLEX"/>
<jointvel name="Sjv_thumb_ABD" joint="thumb_ABD"/>
<jointvel name="Sjv_thumb_MCP" joint="thumb_MCP"/>
<jointvel name="Sjv_thumb_PIP" joint="thumb_PIP"/>
<jointvel name="Sjv_thumb_DIP" joint="thumb_DIP"/>
<jointvel name="Sjv_index_ABD" joint="index_ABD"/>
<jointvel name="Sjv_index_MCP" joint="index_MCP"/>
<jointvel name="Sjv_index_PIP" joint="index_PIP"/>
<jointvel name="Sjv_index_DIP" joint="index_DIP"/>
<jointvel name="Sjv_middle_MCP" joint="middle_MCP"/>
<jointvel name="Sjv_middle_PIP" joint="middle_PIP"/>
<jointvel name="Sjv_middle_DIP" joint="middle_DIP"/>
<jointvel name="Sjv_ring_ABD" joint="ring_ABD"/>
<jointvel name="Sjv_ring_MCP" joint="ring_MCP"/>
<jointvel name="Sjv_ring_PIP" joint="ring_PIP"/>
<jointvel name="Sjv_ring_DIP" joint="ring_DIP"/>
<jointvel name="Sjv_pinky_ABD" joint="pinky_ABD"/>
<jointvel name="Sjv_pinky_MCP" joint="pinky_MCP"/>
<jointvel name="Sjv_pinky_PIP" joint="pinky_PIP"/>
<jointvel name="Sjv_pinky_DIP" joint="pinky_DIP"/>
<actuatorpos name="Sap_wrist_PRO" actuator="A_wrist_PRO" />
<actuatorpos name="Sap_wrist_UDEV" actuator="A_wrist_UDEV" />
<actuatorpos name="Sap_wrist_FLEX" actuator="A_wrist_FLEX" />
<actuatorpos name="Sap_thumb_ABD" actuator="A_thumb_ABD" />
<actuatorpos name="Sap_thumb_MCP" actuator="A_thumb_MCP" />
<actuatorpos name="Sap_thumb_PIP" actuator="A_thumb_PIP" />
<actuatorpos name="Sap_thumb_DIP" actuator="A_thumb_DIP" />
<actuatorpos name="Sap_index_ABD" actuator="A_index_ABD" />
<actuatorpos name="Sap_index_MCP" actuator="A_index_MCP" />
<actuatorpos name="Sap_middle_MCP" actuator="A_middle_MCP"/>
<actuatorpos name="Sap_ring_MCP" actuator="A_ring_MCP" />
<actuatorpos name="Sap_pinky_ABD" actuator="A_pinky_ABD" />
<actuatorpos name="Sap_pinky_MCP" actuator="A_pinky_MCP" />
<actuatorvel name="Sav_wrist_PRO" actuator="A_wrist_PRO" />
<actuatorvel name="Sav_wrist_UDEV" actuator="A_wrist_UDEV"/>
<actuatorvel name="Sav_wrist_FLEX" actuator="A_wrist_FLEX"/>
<actuatorvel name="Sav_thumb_ABD" actuator="A_thumb_ABD" />
<actuatorvel name="Sav_thumb_MCP" actuator="A_thumb_MCP" />
<actuatorvel name="Sav_thumb_PIP" actuator="A_thumb_PIP" />
<actuatorvel name="Sav_thumb_DIP" actuator="A_thumb_DIP" />
<actuatorvel name="Sav_index_ABD" actuator="A_index_ABD" />
<actuatorvel name="Sav_index_MCP" actuator="A_index_MCP" />
<actuatorvel name="Sav_middle_MCP" actuator="A_middle_MCP"/>
<actuatorvel name="Sav_ring_MCP" actuator="A_ring_MCP" />
<actuatorvel name="Sav_pinky_ABD" actuator="A_pinky_ABD" />
<actuatorvel name="Sav_pinky_MCP" actuator="A_pinky_MCP" />
<actuatorfrc name="Saf_wrist_PRO" actuator="A_wrist_PRO"/>
<actuatorfrc name="Saf_wrist_UDEV" actuator="A_wrist_UDEV"/>
<actuatorfrc name="Saf_wrist_FLEX" actuator="A_wrist_FLEX"/>
<actuatorfrc name="Saf_thumb_ABD" actuator="A_thumb_ABD"/>
<actuatorfrc name="Saf_thumb_MCP" actuator="A_thumb_MCP"/>
<actuatorfrc name="Saf_thumb_PIP" actuator="A_thumb_PIP"/>
<actuatorfrc name="Saf_thumb_DIP" actuator="A_thumb_DIP"/>
<actuatorfrc name="Saf_index_ABD" actuator="A_index_ABD"/>
<actuatorfrc name="Saf_index_MCP" actuator="A_index_MCP"/>
<actuatorfrc name="Saf_middle_MCP" actuator="A_middle_MCP"/>
<actuatorfrc name="Saf_ring_MCP" actuator="A_ring_MCP"/>
<actuatorfrc name="Saf_pinky_ABD" actuator="A_pinky_ABD"/>
<actuatorfrc name="Saf_pinky_MCP" actuator="A_pinky_MCP"/>
<accelerometer name="S_thumb_IMU" site="thumb_IMU"/>
<accelerometer name="S_index_IMU" site="index_IMU"/>
<accelerometer name="S_middle_IMU" site="middle_IMU"/>
<accelerometer name="S_ring_IMU" site="ring_IMU"/>
<accelerometer name="S_pinky_IMU" site="pinky_IMU"/>
<gyro site="thumb_IMU"/>
<gyro site="index_IMU"/>
<gyro site="middle_IMU"/>
<gyro site="ring_IMU"/>
<gyro site="pinky_IMU"/>
<touch name="S_palm_thumb" site="palm_thumb"/>
<touch name="S_palm_pinky" site="palm_pinky"/>
<touch name="S_palm_side" site="palm_side"/>
<touch name="S_palm_back" site="palm_back"/>
<touch name="S_thumb_proximal" site="thumb_proximal"/>
<touch name="S_thumb_medial" site="thumb_medial"/>
<touch name="S_thumb_distal" site="thumb_distal"/>
<touch name="S_index_proximal" site="index_proximal"/>
<touch name="S_index_medial" site="index_medial"/>
<touch name="S_index_distal" site="index_distal"/>
<touch name="S_middle_proximal" site="middle_proximal"/>
<touch name="S_middle_medial" site="middle_medial"/>
<touch name="S_middle_distal" site="middle_distal"/>
<touch name="S_ring_proximal" site="ring_proximal"/>
<touch name="S_ring_medial" site="ring_medial"/>
<touch name="S_ring_distal" site="ring_distal"/>
<touch name="S_pinky_proximal" site="pinky_proximal"/>
<touch name="S_pinky_medial" site="pinky_medial"/>
<touch name="S_pinky_distal" site="pinky_distal"/>
</sensor>
<tendon>
<!--Index coupler tendons-->
<fixed name="T_index32_cpl" range="0 1">
<joint joint="index_DIP" coef="0.00705"/>
<joint joint="index_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_index21_cpl" range="0 1">
<joint joint="index_PIP" coef="0.010"/>
<joint joint="index_MCP" coef="-0.010"/>
</fixed>
<!--Middle coupler tendons-->
<fixed name="T_middle32_cpl">
<joint joint="middle_DIP" coef="0.00705"/>
<joint joint="middle_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_middle21_cpl">
<joint joint="middle_PIP" coef="0.010"/>
<joint joint="middle_MCP" coef="-0.010"/>
</fixed>
<!--Ring coupler tendons-->
<fixed name="T_ring32_cpl">
<joint joint="ring_DIP" coef="0.00705"/>
<joint joint="ring_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_ring21_cpl">
<joint joint="ring_PIP" coef="0.010"/>
<joint joint="ring_MCP" coef="-0.010"/>
</fixed>
<!--Little coupler tendons-->
<fixed name="T_pinky32_cpl">
<joint joint="pinky_DIP" coef="0.00705"/>
<joint joint="pinky_PIP" coef="-0.00805"/>
</fixed>
<fixed name="T_pinky21_cpl">
<joint joint="pinky_PIP" coef="0.010"/>
<joint joint="pinky_MCP" coef="-0.010"/>
</fixed>
</tendon>
<equality>
<weld body1="mocap" body2="forearm" solref="0.01 1" solimp=".9 .9 0.01"/>
<!-- DIP-PIP-MCP Couplings -->
<tendon name="E_index32_cpl" tendon1="T_index32_cpl"/>
<tendon name="E_index21_cpl" tendon1="T_index21_cpl"/>
<tendon name="E_middle32_cpl" tendon1="T_middle32_cpl"/>
<tendon name="E_middle21_cpl" tendon1="T_middle21_cpl"/>
<tendon name="E_ring32_cpl" tendon1="T_ring32_cpl"/>
<tendon name="E_ring21_cpl" tendon1="T_ring21_cpl"/>
<tendon name="E_pinky32_cpl" tendon1="T_pinky32_cpl"/>
<tendon name="E_pinky21_cpl" tendon1="T_pinky21_cpl"/>
<!-- AD-AB Coupling -->
<joint name="ring_pinky_cpl" joint1="ring_ABD" joint2="pinky_ABD" polycoef="0 0.5 0 0 0"/>
</equality>
<actuator>
<!-- Wrist -->
<position name="A_wrist_PRO" class="MPL" joint="wrist_PRO" ctrlrange="-1.57 1.57"/>
<position name="A_wrist_UDEV" class="MPL" joint="wrist_UDEV" ctrlrange="-0.26 0.79"/>
<position name="A_wrist_FLEX" class="MPL" joint="wrist_FLEX" ctrlrange="-1 1"/>
<!-- Thumb -->
<position name="A_thumb_ABD" class="MPL" joint="thumb_ABD" ctrlrange="0 2.1"/>
<position name="A_thumb_MCP" class="MPL" joint="thumb_MCP" ctrlrange="0 1.0"/>
<position name="A_thumb_PIP" class="MPL" joint="thumb_PIP" ctrlrange="0 1.0"/>
<position name="A_thumb_DIP" class="MPL" joint="thumb_DIP" ctrlrange="-0.82 1.3"/>
<!-- Fingers -->
<position name="A_index_ABD" class="MPL" joint="index_ABD" ctrlrange="0 0.34"/>
<position name="A_index_MCP" class="MPL" joint="index_MCP" ctrlrange="0 1.6"/>
<position name="A_middle_MCP" class="MPL" joint="middle_MCP" ctrlrange="0 1.6"/>
<position name="A_ring_MCP" class="MPL" joint="ring_MCP" ctrlrange="0 1.6"/>
<position name="A_pinky_ABD" class="MPL" joint="pinky_ABD" ctrlrange="0 0.34"/>
<position name="A_pinky_MCP" class="MPL" joint="pinky_MCP" ctrlrange="0 1.6"/>
</actuator>
</mujoco>

32
data/block.urdf Normal file
View File

@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<robot name="block_2">
<link name="block_2_base_link">
<contact>
<lateral_friction value="1.0"/>
<rolling_friction value="0.0"/>
<inertia_scaling value="3.0"/>
<contact_cfm value="0.0"/>
<contact_erp value="1.0"/>
</contact>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0.02"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0.0 0.0 0.0"/>
<geometry>
<box size="0.10 0.018 0.018"/>
</geometry>
<material name="blockmat">
<color rgba="0.1 0.7 0.1 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0.0 0.0 0.0"/>
<geometry>
<box size="0.10 0.018 0.018"/>
</geometry>
</collision>
</link>
</robot>

BIN
data/block_grasp_log.bin Normal file

Binary file not shown.

23
data/capsule.urdf Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="0.0" ?>
<robot name="urdf_robot">
<link name="base_link">
<contact>
<rolling_friction value="0.001"/>
<spinning_friction value="0.001"/>
</contact>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value=".1"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<capsule length="0.1" radius="0.02"/>
</geometry>
</collision>
</link>
</robot>

74
data/cartpole.urdf Normal file
View File

@@ -0,0 +1,74 @@
<?xml version="1.0"?>
<robot name="physics">
<link name="slideBar">
<visual>
<geometry>
<box size="30 0.05 0.05"/>
</geometry>
<origin xyz="0 0 0"/>
<material name="green">
<color rgba="0 0.8 .8 1"/>
</material>
</visual>
<inertial>
<mass value="0"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<link name="cart">
<visual>
<geometry>
<box size="0.5 0.5 0.2"/>
</geometry>
<origin xyz="0 0 0"/>
<material name="blue">
<color rgba="0 0 .8 1"/>
</material>
</visual>
<collision>
<geometry>
<box size="0.5 0.5 0.2"/>
</geometry>
<origin xyz="0 0 0"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<joint name="slider_to_cart" type="prismatic">
<axis xyz="1 0 0"/>
<origin xyz="0.0 0.0 0.0"/>
<parent link="slideBar"/>
<child link="cart"/>
<limit effort="1000.0" lower="-15" upper="15" velocity="5"/>
</joint>
<link name="pole">
<visual>
<geometry>
<box size="0.05 0.05 1.0"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0.5"/>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
<inertial>
<origin xyz="0 0 0.5"/>
<mass value="10"/>
<inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
</inertial>
</link>
<joint name="cart_to_pole" type="continuous">
<axis xyz="0 1 0"/>
<origin xyz="0.0 0.0 0"/>
<parent link="cart"/>
<child link="pole"/>
</joint>
</robot>

View File

@@ -1,5 +1,5 @@
<?xml version="0.0" ?>
<robot name="cube.urdf">
<robot name="cube">
<link name="baseLink">
<contact>
<lateral_friction value="1.0"/>

View File

@@ -2,7 +2,8 @@
<robot name="cube.urdf">
<link name="baseLink">
<contact>
<lateral_friction value="1.0"/>
<friction_anchor/>
<lateral_friction value="1.3"/>
<rolling_friction value="0.0"/>
<stiffness value="300"/>
<damping value="10"/>

View File

@@ -0,0 +1,21 @@
newmtl porcelain
Ka 0.000000 0.000000 0.000000
Kd 1.000000 1.000000 1.000000
Ks 0.200000 0.200000 0.200000
d 1.000000
illum 2
Ns 0.000000
newmtl solid_color
Ka 0.000000 0.000000 0.000000
Kd 1.000000 1.000000 1.000000
Ks 0.200000 0.200000 0.200000
d 1.000000
illum 2
Ns 0.000000
newmtl pan_tefal
Ka 0.000000 0.000000 0.000000
Kd 0.609804 0.494118 0.486275
Ks 0.330000 0.330000 0.330000
map_Kd pan_tefal.jpg

252
data/dinnerware/generate.py Normal file
View File

@@ -0,0 +1,252 @@
from __future__ import print_function
import numpy as np
class Obj:
def __init__(self, fn):
self.ind_v = 0
self.ind_vt = 0
self.ind_vn = 0
self.fn = fn
self.out = open(fn + ".tmp", "w")
self.out.write("mtllib dinnerware.mtl\n")
def __del__(self):
self.out.close()
import shutil
shutil.move(self.fn + ".tmp", self.fn)
def push_v(self, v):
self.out.write("v %f %f %f\n" % (v[0],v[1],v[2]))
self.ind_v += 1
return self.ind_v
def push_vt(self, vt):
self.out.write("vt %f %f\n" % (vt[0],vt[1]))
self.ind_vt += 1
return self.ind_vt
def push_vn(self, vn):
vn /= np.linalg.norm(vn)
self.out.write("vn %f %f %f\n" % (vn[0],vn[1],vn[2]))
self.ind_vn += 1
return self.ind_vn
def convex_hull(points, vind, nind, tind, obj):
"super ineffective"
cnt = len(points)
for a in range(cnt):
for b in range(a+1,cnt):
for c in range(b+1,cnt):
vec1 = points[a] - points[b]
vec2 = points[a] - points[c]
n = np.cross(vec1, vec2)
n /= np.linalg.norm(n)
C = np.dot(n, points[a])
inner = np.inner(n, points)
pos = (inner <= C+0.0001).all()
neg = (inner >= C-0.0001).all()
if not pos and not neg: continue
obj.out.write("f %i//%i %i//%i %i//%i\n" % (
(vind[a], nind[a], vind[b], nind[b], vind[c], nind[c])
if (inner - C).sum() < 0 else
(vind[a], nind[a], vind[c], nind[c], vind[b], nind[b]) ) )
#obj.out.write("f %i/%i/%i %i/%i/%i %i/%i/%i\n" % (
# (vind[a], tind[a], nind[a], vind[b], tind[b], nind[b], vind[c], tind[c], nind[c])
# if (inner - C).sum() < 0 else
# (vind[a], tind[a], nind[a], vind[c], tind[c], nind[c], vind[b], tind[b], nind[b]) ) )
def test_convex_hull():
obj = Obj("convex_test.obj")
vlist = np.random.uniform( low=-0.1, high=+0.1, size=(100,3) )
nlist = vlist.copy()
tlist = np.random.uniform( low=0, high=+1, size=(100,2) )
vind = [obj.push_v(xyz) for xyz in vlist]
nind = [obj.push_vn(xyz) for xyz in nlist]
tind = [obj.push_vt(uv) for uv in tlist]
convex_hull(vlist, vind, nind, tind, obj)
class Contour:
def __init__(self):
self.vprev_vind = None
def f(self, obj, vlist_vind, vlist_tind, vlist_nind):
cnt = len(vlist_vind)
for i1 in range(cnt):
i2 = i1-1
obj.out.write("f %i/%i/%i %i/%i/%i %i/%i/%i\n" % (
vlist_vind[i2], vlist_tind[i2], vlist_nind[i2],
vlist_vind[i1], vlist_tind[i1], vlist_nind[i1],
self.vprev_vind[i1], self.vprev_tind[i1], self.vprev_nind[i1],
) )
obj.out.write("f %i/%i/%i %i/%i/%i %i/%i/%i\n" % (
vlist_vind[i2], vlist_tind[i2], vlist_nind[i2],
self.vprev_vind[i1], self.vprev_tind[i1], self.vprev_nind[i1],
self.vprev_vind[i2], self.vprev_tind[i2], self.vprev_nind[i2],
) )
def belt(self, obj, vlist, nlist, tlist):
vlist_vind = [obj.push_v(xyz) for xyz in vlist]
vlist_tind = [obj.push_vt(xyz) for xyz in tlist]
vlist_nind = [obj.push_vn(xyz) for xyz in nlist]
if self.vprev_vind:
self.f(obj, vlist_vind, vlist_tind, vlist_nind)
else:
self.first_vind = vlist_vind
self.first_tind = vlist_tind
self.first_nind = vlist_nind
self.vprev_vind = vlist_vind
self.vprev_tind = vlist_tind
self.vprev_nind = vlist_nind
def finish(self, obj):
self.f(obj, self.first_vind, self.first_tind, self.first_nind)
def test_contour():
RAD1 = 2.0
RAD2 = 1.5
obj = Obj("torus.obj")
obj.out.write("usemtl porcelain\n")
contour = Contour()
for step in range(100):
angle = step/100.0*2*np.pi
belt_v = []
belt_n = []
belt_t = []
for b in range(50):
beta = b/50.0*2*np.pi
r = RAD2*np.cos(beta) + RAD1
z = RAD2*np.sin(beta)
belt_v.append( np.array( [
np.cos(angle)*r,
np.sin(angle)*r,
z] ) )
belt_n.append( np.array( [
np.cos(angle)*np.cos(beta),
np.sin(angle)*np.cos(beta),
np.sin(beta)] ) )
belt_t.append( (0,0) )
contour.belt(obj, belt_v, belt_n, belt_t)
contour.finish(obj)
#test_convex_hull()
#test_contour()
class RotationFigureParams:
pass
def generate_plate(p, obj, collision_prefix):
contour = Contour()
belt_vlist_3d_prev = None
for step in range(p.N_VIZ+1):
angle = step/float(p.N_VIZ)*2*np.pi
if step % p.COLLISION_EVERY == 0:
vlist_3d = []
for x,y in p.belt_simple:
vlist_3d.append( [
np.cos(angle)*x*1.06,
np.sin(angle)*x*1.06,
y
] )
if belt_vlist_3d_prev:
obj2 = Obj(collision_prefix % (step / p.COLLISION_EVERY))
obj2.out.write("usemtl pan_tefal\n")
vlist = np.array( vlist_3d + belt_vlist_3d_prev )
vlist[len(vlist_3d):] *= 1.01 # break points on one plane
vlist[0,0:2] += 0.01*vlist[len(vlist_3d),0:2]
vlist[len(vlist_3d),0:2] += 0.01*vlist[0,0:2]
nlist = np.random.uniform( low=-1, high=+1, size=vlist.shape )
tlist = np.random.uniform( low=0, high=+1, size=(len(vlist),2) )
vind = [obj2.push_v(xyz) for xyz in vlist]
nind = [obj2.push_vn(xyz) for xyz in nlist]
convex_hull(vlist, vind, nind, None, obj2)
belt_vlist_3d_prev = vlist_3d
if step==p.N_VIZ: break
belt_v = []
belt_n = []
belt_t = []
for x,y,nx,ny in p.belt:
belt_v.append( np.array( [
np.cos(angle)*x,
np.sin(angle)*x,
y
] ) )
belt_n.append( np.array( [
np.cos(angle)*nx,
np.sin(angle)*nx,
ny
] ) )
if ny-nx >= 0:
belt_t.append( (
127.0/512 + np.cos(angle)*x/p.RAD_HIGH*105/512,
(512-135.0)/512 + np.sin(angle)*x/p.RAD_HIGH*105/512) )
else:
belt_t.append( (
382.0/512 + np.cos(angle)*x/p.RAD_HIGH*125/512,
(512-380.0)/512 + np.sin(angle)*x/p.RAD_HIGH*125/512) )
contour.belt(obj, belt_v, belt_n, belt_t)
contour.finish(obj)
def tefal():
p = RotationFigureParams()
p.RAD_LOW = 0.240/2
p.RAD_HIGH = 0.255/2
p.H = 0.075
p.THICK = 0.005
p.N_VIZ = 30
p.COLLISION_EVERY = 5
p.belt = [
(p.RAD_HIGH-p.THICK, p.H, -1,0), # x y norm
(p.RAD_HIGH , p.H, 0,1),
(p.RAD_HIGH+p.THICK, p.H, +1,0),
(p.RAD_LOW+p.THICK, p.THICK, +1,0),
(p.RAD_LOW , 0, 0,-1),
( 0, 0, 0,-1),
( 0, p.THICK, 0,1),
(p.RAD_LOW-p.THICK, p.THICK, 0,1),
(p.RAD_LOW-p.THICK, 3*p.THICK,-1,0),
]
p.belt.reverse()
p.belt_simple = [
(p.RAD_HIGH-p.THICK, p.H),
(p.RAD_HIGH+p.THICK, p.H),
(p.RAD_LOW , 0),
(p.RAD_LOW-p.THICK , 0)
]
obj = Obj("pan_tefal.obj")
obj.out.write("usemtl pan_tefal\n")
generate_plate(p, obj, "pan_tefal-collision%02i.obj")
def plate():
p = RotationFigureParams()
p.RAD_LOW = 0.110/2
p.RAD_HIGH = 0.190/2
p.H = 0.060
p.THICK = 0.003
p.N_VIZ = 30
p.COLLISION_EVERY = 5
p.belt = [
(p.RAD_HIGH-p.THICK, p.H, -0.9,0.5), # x y norm
(p.RAD_HIGH , p.H, 0,1),
(p.RAD_HIGH+p.THICK, p.H, +1,0),
(p.RAD_LOW+p.THICK, p.THICK, +1,0),
(p.RAD_LOW , 0, 0,-1),
( 0, 0, 0,-1),
( 0, p.THICK, 0,1),
(p.RAD_LOW-3*p.THICK, p.THICK, 0,1),
(p.RAD_LOW-p.THICK, 3*p.THICK,-0.5,1.0),
]
p.belt.reverse()
p.belt_simple = [
(p.RAD_HIGH-p.THICK, p.H),
(p.RAD_HIGH+p.THICK, p.H),
(p.RAD_LOW , 0),
(p.RAD_LOW-p.THICK , 0)
]
obj = Obj("plate.obj")
obj.out.write("usemtl solid_color\n")
generate_plate(p, obj, "plate-collision%02i.obj")
plate()

View File

@@ -0,0 +1,36 @@
mtllib dinnerware.mtl
usemtl pan_tefal
v 0.066236 0.112453 0.075000
v 0.070225 0.121633 0.075000
v 0.063600 0.110158 0.000000
v 0.060950 0.105568 0.000000
v 0.131811 0.001125 0.075750
v 0.141855 0.000000 0.075750
v 0.128472 0.000000 0.000000
v 0.123119 0.000000 0.000000
vn 0.166577 -0.705775 0.688573
vn -0.727212 0.200240 0.656556
vn 0.637357 -0.756451 -0.146827
vn -0.340753 -0.711716 0.614286
vn 0.122979 0.860640 0.494141
vn 0.770289 -0.238643 0.591358
vn -0.635571 -0.120420 0.762594
vn -0.070367 0.649517 -0.757084
f 1//1 2//2 4//4
f 1//1 5//5 2//2
f 1//1 6//6 2//2
f 1//1 4//4 5//5
f 1//1 4//4 8//8
f 1//1 5//5 6//6
f 1//1 8//8 5//5
f 2//2 3//3 4//4
f 2//2 7//7 3//3
f 2//2 5//5 6//6
f 2//2 6//6 7//7
f 3//3 7//7 4//4
f 3//3 8//8 4//4
f 3//3 7//7 8//8
f 4//4 8//8 5//5
f 4//4 7//7 8//8
f 5//5 8//8 6//6
f 6//6 8//8 7//7

Some files were not shown because too many files have changed in this diff Show More