From: <hsu...@us...> - 2010-12-01 00:05:11
|
Revision: 1771 http://opende.svn.sourceforge.net/opende/?rev=1771&view=rev Author: hsujohnhsu Date: 2010-11-30 23:45:40 +0000 (Tue, 30 Nov 2010) Log Message: ----------- merging from trunk, includes libccd for cylinder to cylinder collision. should resolve https://code.ros.org/trac/ros-pkg/ticket/2501. Modified Paths: -------------- branches/wg/CHANGELOG.txt branches/wg/Makefile.am branches/wg/OPCODE/Opcode.h branches/wg/autogen.sh branches/wg/build/premake4.lua branches/wg/configure.in branches/wg/include/ode/collision.h branches/wg/include/ode/odeconfig.h branches/wg/include/ode/odeinit.h branches/wg/ode/src/Makefile.am branches/wg/ode/src/collision_kernel.cpp branches/wg/ode/src/collision_transform.cpp branches/wg/tests/joints/hinge.cpp Added Paths: ----------- branches/wg/libccd/ branches/wg/libccd/src/ branches/wg/libccd/src/ccd/ branches/wg/libccd/src/testsuites/ branches/wg/libccd/src/testsuites/cu/ branches/wg/libccd/src/testsuites/regressions/ branches/wg/ode/src/collision_libccd.cpp branches/wg/ode/src/collision_libccd.h Removed Paths: ------------- branches/wg/libccd/src/ branches/wg/libccd/src/ccd/ branches/wg/libccd/src/testsuites/ branches/wg/libccd/src/testsuites/cu/ branches/wg/libccd/src/testsuites/regressions/ Property Changed: ---------------- branches/wg/ Property changes on: branches/wg ___________________________________________________________________ Added: svn:mergeinfo + /trunk:1741-1770 Modified: branches/wg/CHANGELOG.txt =================================================================== --- branches/wg/CHANGELOG.txt 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/CHANGELOG.txt 2010-11-30 23:45:40 UTC (rev 1771) @@ -8,11 +8,15 @@ * keep the format consistent (79 char width, M/D/Y date format). ------------------------------------------------------------------------------ +11/08/10 Daniel K. O. + * Applied patches from Daniel Fiser to incorporate libccd for + Cylinder-Cylinder collision tests. + 08/21/10 Oleh Derevenko - * Fix applied to dxReallocateTemporayWorldProcessContext() to remove typo - which caused segmentation fault (by Kyle McKay). - dTestSolveLCP() fixed to avoid exceeding allocated memory pool - (by Kyle McKay). + * Fix applied to dxReallocateTemporayWorldProcessContext() to remove typo + which caused segmentation fault (by Kyle McKay). + dTestSolveLCP() fixed to avoid exceeding allocated memory pool + (by Kyle McKay). 07/19/10 Oleh Derevenko * Patch applied (#3030783) to fix drawstuff dimensions being ignored in OSX GLUT port (by Danny Price). Modified: branches/wg/Makefile.am =================================================================== --- branches/wg/Makefile.am 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/Makefile.am 2010-11-30 23:45:40 UTC (rev 1771) @@ -2,6 +2,10 @@ OU_DIR = ou endif +if LIBCCD +LIBCCD_DIR = libccd +endif + if ENABLE_DEMOS DRAWSTUFF_DIR = drawstuff endif @@ -19,6 +23,7 @@ $(GIMPACT_DIR) \ $(OPCODE_DIR) \ $(OU_DIR) \ + $(LIBCCD_DIR) \ ode \ tests Modified: branches/wg/OPCODE/Opcode.h =================================================================== --- branches/wg/OPCODE/Opcode.h 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/OPCODE/Opcode.h 2010-11-30 23:45:40 UTC (rev 1771) @@ -20,6 +20,10 @@ #ifndef __OPCODE_H__ #define __OPCODE_H__ +// stdarg.h must be included before Opcode headers as it later +// may not compile being not able to find std::va_list +#include <stdarg.h> + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Things to help us compile on non-windows platforms Modified: branches/wg/autogen.sh =================================================================== --- branches/wg/autogen.sh 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/autogen.sh 2010-11-30 23:45:40 UTC (rev 1771) @@ -49,4 +49,9 @@ #./configure $* +if [ -d libccd ]; then + echo "Running bootstrap in libccd directory" + (cd libccd && ./bootstrap) +fi; + echo "Now you are ready to run ./configure" Modified: branches/wg/build/premake4.lua =================================================================== --- branches/wg/build/premake4.lua 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/build/premake4.lua 2010-11-30 23:45:40 UTC (rev 1771) @@ -77,6 +77,11 @@ } newoption { + trigger = "with-libccd", + description = "Uses libccd for handling some collision tests absent in ODE." + } + + newoption { trigger = "no-dif", description = "Exclude DIF (Dynamics Interchange Format) exports" } @@ -192,10 +197,10 @@ flags { "OptimizeSpeed", "NoFramePointer" } configuration { "only-single or *Single*" } - defines { "dSINGLE" } + defines { "dSINGLE", "CCD_SINGLE" } configuration { "only-double or *Double*" } - defines { "dDOUBLE" } + defines { "dDOUBLE", "CCD_DOUBLE" } configuration { "Windows" } defines { "WIN32" } @@ -262,7 +267,8 @@ "../ode/src/joints", "../OPCODE", "../GIMPACT/include", - "../ou/include" + "../ou/include", + "../libccd/src" } files { @@ -307,6 +313,14 @@ files { "../ou/**.h", "../ou/**.cpp" } defines { "_OU_NAMESPACE=odeou" } + configuration { "with-libccd" } + files { "../libccd/src/ccd/*.h", "../libccd/src/*.c", + "../ode/src/collision_libccd.cpp", "../ode/src/collision_libccd.h" } + defines { "dLIBCCD_ENABLED", "dLIBCCD_CYL_CYL" } + + configuration { "not with-libccd" } + excludes { "../ode/src/collision_libccd.cpp", "../ode/src/collision_libccd.h" } + configuration { "windows" } links { "user32" } Modified: branches/wg/configure.in =================================================================== --- branches/wg/configure.in 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/configure.in 2010-11-30 23:45:40 UTC (rev 1771) @@ -342,6 +342,19 @@ AM_CONDITIONAL(ENABLE_OU, test x$use_ou = xyes) + +libccd=no +AC_ARG_WITH(libccd, AS_HELP_STRING([--with-libccd=[cyl-cyl|no]], + [use the libccd library for specified collision detection @<:@default=no@:>@]), + libccd=$withval,libccd=no +) +AC_CONFIG_SUBDIRS([libccd]) + +AM_CONDITIONAL(LIBCCD, test x$libccd != xno) +AM_CONDITIONAL(LIBCCD_CYL_CYL, test x$libccd = xcyl-cyl) + + + AC_ARG_ENABLE([asserts], AS_HELP_STRING([--disable-asserts], [disables debug error checking]), @@ -434,6 +447,7 @@ echo " Demos enabled: $enable_demos" echo " Use OPCODE: $opcode" echo " Use GIMPACT: $gimpact" +echo " Use libccd: $libccd" echo " Is target a Pentium: $pentium" echo " Is target x86-64: $cpu64" echo " Use old opcode trimesh collider: $old_trimesh" Modified: branches/wg/include/ode/collision.h =================================================================== --- branches/wg/include/ode/collision.h 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/include/ode/collision.h 2010-11-30 23:45:40 UTC (rev 1771) @@ -411,7 +411,7 @@ enum { dGeomCommonControlClass = 0, - dGeomColliderControlClass = 1, + dGeomColliderControlClass = 1 }; enum @@ -419,7 +419,7 @@ dGeomCommonAnyControlCode = 0, dGeomColliderSetMergeSphereContactsControlCode = 1, - dGeomColliderGetMergeSphereContactsControlCode = 2, + dGeomColliderGetMergeSphereContactsControlCode = 2 }; enum @@ -427,7 +427,7 @@ dGeomColliderMergeContactsValue__Default = 0, // Used with Set... to restore default value dGeomColliderMergeContactsValue_None = 1, dGeomColliderMergeContactsValue_Normals = 2, - dGeomColliderMergeContactsValue_Full = 3, + dGeomColliderMergeContactsValue_Full = 3 }; /** Modified: branches/wg/include/ode/odeconfig.h =================================================================== --- branches/wg/include/ode/odeconfig.h 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/include/ode/odeconfig.h 2010-11-30 23:45:40 UTC (rev 1771) @@ -41,14 +41,14 @@ typedef unsigned int uint32; typedef short int16; typedef unsigned short uint16; - typedef char int8; + typedef signed char int8; typedef unsigned char uint8; #else typedef int int32; typedef unsigned int uint32; typedef short int16; typedef unsigned short uint16; - typedef char int8; + typedef signed char int8; typedef unsigned char uint8; #endif Modified: branches/wg/include/ode/odeinit.h =================================================================== --- branches/wg/include/ode/odeinit.h 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/include/ode/odeinit.h 2010-11-30 23:45:40 UTC (rev 1771) @@ -74,7 +74,7 @@ * @ingroup init */ enum dInitODEFlags { - dInitFlagManualThreadCleanup = 0x00000001, //@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call + dInitFlagManualThreadCleanup = 0x00000001 //@< Thread local data is to be cleared explicitly on @c dCleanupODEAllDataForThread function call }; /** @@ -148,7 +148,7 @@ dAllocateFlagCollisionData = 0x00000001, //@< Allocate data for collision detection - dAllocateMaskAll = ~0U, //@< Allocate all the possible data that is currently defined or will be defined in the future. + dAllocateMaskAll = ~0U //@< Allocate all the possible data that is currently defined or will be defined in the future. }; /** @@ -229,7 +229,7 @@ #ifdef __cplusplus -}; // extern "C" +} // extern "C" #endif Modified: branches/wg/ode/src/Makefile.am =================================================================== --- branches/wg/ode/src/Makefile.am 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/ode/src/Makefile.am 2010-11-30 23:45:40 UTC (rev 1771) @@ -139,4 +139,14 @@ #libode_la_LDFLAGS += $(BOOST_THREAD_LDFLAGS) #libode_la_LIBS += $(BOOST_THREAD_LIBS) +if LIBCCD +AM_CPPFLAGS += -I$(top_srcdir)/libccd/src -I$(top_builddir)/libccd/src -DdLIBCCD_ENABLED +libode_la_LIBADD += $(top_builddir)/libccd/src/libccd.la +libode_la_SOURCES += collision_libccd.cpp collision_libccd.h + +if LIBCCD_CYL_CYL +AM_CPPFLAGS += -DdLIBCCD_CYL_CYL +endif + +endif Modified: branches/wg/ode/src/collision_kernel.cpp =================================================================== --- branches/wg/ode/src/collision_kernel.cpp 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/ode/src/collision_kernel.cpp 2010-11-30 23:45:40 UTC (rev 1771) @@ -41,7 +41,11 @@ #include "collision_space_internal.h" #include "odeou.h" +#ifdef dLIBCCD_ENABLED +# include "collision_libccd.h" +#endif /* dLIBCCD_ENABLED */ + #ifdef _MSC_VER #pragma warning(disable:4291) // for VC++, no complaints about "no matching operator delete found" #endif @@ -202,8 +206,11 @@ setCollider (dCylinderClass,dBoxClass,&dCollideCylinderBox); setCollider (dCylinderClass,dSphereClass,&dCollideCylinderSphere); setCollider (dCylinderClass,dPlaneClass,&dCollideCylinderPlane); - //setCollider (dCylinderClass,dCylinderClass,&dCollideCylinderCylinder); +#ifdef dLIBCCD_CYL_CYL + setCollider (dCylinderClass, dCylinderClass, &dCollideCylinderCylinder); +#endif + //--> Convex Collision setCollider (dConvexClass,dPlaneClass,&dCollideConvexPlane); setCollider (dSphereClass,dConvexClass,&dCollideSphereConvex); Copied: branches/wg/ode/src/collision_libccd.cpp (from rev 1770, trunk/ode/src/collision_libccd.cpp) =================================================================== --- branches/wg/ode/src/collision_libccd.cpp (rev 0) +++ branches/wg/ode/src/collision_libccd.cpp 2010-11-30 23:45:40 UTC (rev 1771) @@ -0,0 +1,108 @@ +#include <ode/collision.h> +#include <ode/odemath.h> +#include <ccd/ccd.h> +#include <ccd/quat.h> +#include "collision_libccd.h" + +struct _cyl_t { + ccd_real_t radius, height; + ccd_vec3_t pos; + ccd_quat_t rot, rot_inv; +}; +typedef struct _cyl_t cyl_t; + +static void geomToCyl(const dGeomID geom, cyl_t *cyl) +{ + const dReal *ode_pos; + dQuaternion ode_rot; + + dGeomCylinderGetParams(geom, &cyl->radius, &cyl->height); + ode_pos = dGeomGetPosition(geom); + dGeomGetQuaternion(geom, ode_rot); + + ccdVec3Set(&cyl->pos, ode_pos[0], ode_pos[1], ode_pos[2]); + ccdQuatSet(&cyl->rot, ode_rot[1], ode_rot[2], ode_rot[3], ode_rot[0]); + + ccdQuatInvert2(&cyl->rot_inv, &cyl->rot); +} + +static void supportCyl(const void *obj, const ccd_vec3_t *_dir, + ccd_vec3_t *v) +{ + const cyl_t *cyl = (const cyl_t *)obj; + ccd_vec3_t dir; + double zdist, rad; + + ccdVec3Copy(&dir, _dir); + ccdQuatRotVec(&dir, &cyl->rot_inv); + + zdist = dir.v[0] * dir.v[0] + dir.v[1] * dir.v[1]; + zdist = sqrt(zdist); + if (ccdIsZero(zdist)){ + ccdVec3Set(v, 0., 0., ccdSign(ccdVec3Z(&dir)) * cyl->height * 0.5); + }else{ + rad = cyl->radius / zdist; + + ccdVec3Set(v, rad * ccdVec3X(&dir), + rad * ccdVec3Y(&dir), + ccdSign(ccdVec3Z(&dir)) * cyl->height * 0.5); + } + + // transform support vertex + ccdQuatRotVec(v, &cyl->rot); + ccdVec3Add(v, &cyl->pos); +} + +static void centerCyl(const void *obj1, ccd_vec3_t *center) +{ + const cyl_t *cyl = (const cyl_t *)obj1; + ccdVec3Copy(center, &cyl->pos); +} + + +int dCollideCylinderCylinder(dxGeom *o1, dxGeom *o2, int flags, + dContactGeom *contact, int skip) +{ + ccd_t ccd; + int res; + ccd_real_t depth; + ccd_vec3_t dir, pos; + int max_contacts = (flags & 0xffff); + cyl_t cyl1, cyl2; + + if (max_contacts < 1) + return 0; + + CCD_INIT(&ccd); + ccd.support1 = supportCyl; + ccd.support2 = supportCyl; + ccd.center1 = centerCyl; + ccd.center2 = centerCyl; + ccd.mpr_tolerance = 1E-6; + + geomToCyl((dGeomID)o1, &cyl1); + geomToCyl((dGeomID)o2, &cyl2); + + res = ccdMPRPenetration(&cyl1, &cyl2, &ccd, &depth, &dir, &pos); + if (res == 0){ + contact->g1 = o1; + contact->g2 = o2; + + contact->side1 = contact->side2 = -1; + + contact->depth = depth; + + contact->pos[0] = ccdVec3X(&pos); + contact->pos[1] = ccdVec3Y(&pos); + contact->pos[2] = ccdVec3Z(&pos); + + ccdVec3Scale(&dir, -1.); + contact->normal[0] = ccdVec3X(&dir); + contact->normal[1] = ccdVec3Y(&dir); + contact->normal[2] = ccdVec3Z(&dir); + + return 1; + } + + return 0; +} Copied: branches/wg/ode/src/collision_libccd.h (from rev 1770, trunk/ode/src/collision_libccd.h) =================================================================== --- branches/wg/ode/src/collision_libccd.h (rev 0) +++ branches/wg/ode/src/collision_libccd.h 2010-11-30 23:45:40 UTC (rev 1771) @@ -0,0 +1,7 @@ +#ifndef _LIBCCD_COLLISION_H_ +#define _LIBCCD_COLLISION_H_ + +int dCollideCylinderCylinder(dxGeom *o1, dxGeom *o2, int flags, + dContactGeom *contact, int skip); + +#endif /* _LIBCCD_COLLISION_H_ */ Modified: branches/wg/ode/src/collision_transform.cpp =================================================================== --- branches/wg/ode/src/collision_transform.cpp 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/ode/src/collision_transform.cpp 2010-11-30 23:45:40 UTC (rev 1771) @@ -231,3 +231,4 @@ dxGeomTransform *tr = (dxGeomTransform*) g; return tr->infomode; } + Modified: branches/wg/tests/joints/hinge.cpp =================================================================== --- branches/wg/tests/joints/hinge.cpp 2010-11-11 09:18:38 UTC (rev 1770) +++ branches/wg/tests/joints/hinge.cpp 2010-11-30 23:45:40 UTC (rev 1771) @@ -894,7 +894,34 @@ } } + + TEST_FIXTURE(dxJointHinge_Fixture_B1_and_B2_At_Zero_Axis_Along_X, + test_Hinge_dParamVel) + { + const dReal targetvel = 100; + const dReal tolerance = targetvel * +#ifdef dSINGLE + 1e-2 +#else + 1e-6 +#endif + ; + dJointSetHingeParam(jId, dParamFMax, dInfinity); + dJointSetHingeParam(jId, dParamVel, targetvel); + + dWorldStep(wId, 0.001); + + const dReal *v1 = dBodyGetAngularVel(bId1); + const dReal *v2 = dBodyGetAngularVel(bId2); + dVector3 rvel = { v1[0]-v2[0], v1[1]-v2[1], v1[2]-v2[2] }; + CHECK_CLOSE(rvel[0], targetvel, tolerance); + CHECK_CLOSE(rvel[1], 0, tolerance); + CHECK_CLOSE(rvel[2], 0, tolerance); + } + + + } // End of SUITE TestdxJointHinge This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |