remove 'Custom' multi body demo, it has no point on its own
This commit is contained in:
@@ -121,7 +121,6 @@
|
||||
|
||||
include "../examples/HelloWorld"
|
||||
include "../examples/BasicDemo"
|
||||
include "../examples/MultiBody"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,8 +74,6 @@ SET(App_ExampleBrowser_SRCS
|
||||
../MultiBody/TestJointTorqueSetup.h
|
||||
../MultiBody/MultiDofDemo.cpp
|
||||
../MultiBody/MultiDofDemo.h
|
||||
../MultiBody/MultiBodyCustomURDFDemo.cpp
|
||||
../MultiBody/MultiBodyCustomURDFDemo.h
|
||||
../Constraints/ConstraintDemo.cpp
|
||||
../Constraints/ConstraintDemo.h
|
||||
../Constraints/Dof6Spring2Setup.cpp
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "../Constraints/ConstraintPhysicsSetup.h"
|
||||
#include "../MultiBody/TestJointTorqueSetup.h"
|
||||
#include "../MultiBody/MultiDofDemo.h"
|
||||
#include "../MultiBody/MultiBodyCustomURDFDemo.h"
|
||||
#include "../VoronoiFracture/VoronoiFractureDemo.h"
|
||||
#include "../SoftDemo/SoftDemo.h"
|
||||
#include "../Constraints/ConstraintDemo.h"
|
||||
@@ -68,7 +67,6 @@ static ExampleEntry gDefaultExamples[]=
|
||||
ExampleEntry(0,"MultiBody"),
|
||||
ExampleEntry(1,"MultiDofCreateFunc","Create a basic btMultiBody.", MultiDofCreateFunc),
|
||||
ExampleEntry(1,"TestJointTorque","Apply a torque to a btMultiBody.", TestJointTorqueCreateFunc),
|
||||
ExampleEntry(1,"Custom URDF","Load a URDF file to allow creation of custom data structures.", MultiBodyCustomURDFDemoCreateFunc),
|
||||
|
||||
|
||||
#ifdef INCLUDE_CLOTH_DEMOS
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
"../SoftDemo/*",
|
||||
"../Constraints/*",
|
||||
"../Vehicles/*",
|
||||
"../MultiBody/MultiBodyCustomURDFDemo.cpp",
|
||||
"../MultiBody/MultiDofDemo.cpp",
|
||||
"../MultiBody/TestJointTorqueSetup.cpp",
|
||||
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.*",
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/* Copyright (C) 2015 Google
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CUSTOM_MULTIBODY_CALLBACK_H
|
||||
#define CUSTOM_MULTIBODY_CALLBACK_H
|
||||
|
||||
#ifdef USE_EIGEN
|
||||
typedef Eigen::Quaternion<double> QuaternionType;
|
||||
typedef Eigen::Vector3d<double> Vector3dType;
|
||||
typedef double ScalarType;
|
||||
#else
|
||||
typedef btQuaternion QuaternionType;
|
||||
typedef btVector3 Vector3dType;
|
||||
typedef btScalar ScalarType;
|
||||
#endif
|
||||
|
||||
class CustomMultiBodyCreationCallback
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~CustomMultiBodyCreationCallback() {}
|
||||
|
||||
enum {
|
||||
RevoluteJoint=1,
|
||||
PrismaticJoint,
|
||||
FixedJoint,
|
||||
};
|
||||
|
||||
virtual int allocateMultiBodyBase(int urdfLinkIndex, int totalNumJoints,ScalarType baseMass, const Vector3dType& localInertiaDiagonal, bool isFixedBase) const =0;
|
||||
|
||||
virtual void addLinkAndJoint(int jointType, int linkIndex, // 0 to num_links-1
|
||||
int parentIndex,
|
||||
double mass,
|
||||
const Vector3dType& inertia,
|
||||
const QuaternionType &rotParentFrameToLinkFrame, // rotate points in parent frame to this frame, when q = 0
|
||||
const Vector3dType& jointAxisInLinkFrame, // in Link frame
|
||||
const Vector3dType& parentComToThisJointOffset, // vector from parent COM to joint frame, in Parent frame
|
||||
const Vector3dType& thisJointToThisComOffset) = 0; // vector from joint frame to my COM, in Link frame);
|
||||
|
||||
// @todo: Decide if we need this link mapping?
|
||||
// virtual void addLinkMapping(int urdfLinkIndex, int mbLinkIndex) const = 0;
|
||||
};
|
||||
|
||||
#endif //CUSTOM_MULTIBODY_CALLBACK_H
|
||||
@@ -1,148 +0,0 @@
|
||||
/* Copyright (C) 2015 Google
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "MultiBodyCustomURDFDemo.h"
|
||||
|
||||
#include "BulletDynamics/Featherstone/btMultiBodyLinkCollider.h"
|
||||
|
||||
#include "../CommonInterfaces/CommonMultiBodyBase.h"
|
||||
|
||||
#include "../Importers/ImportURDFDemo/URDF2Bullet.h"
|
||||
#include "../Importers/ImportURDFDemo/MyURDFImporter.h"
|
||||
#include "../Importers/ImportURDFDemo/MyMultiBodyCreator.h"
|
||||
|
||||
#include "CustomMultiBodyCreationCallback.h"
|
||||
|
||||
|
||||
struct MultiBodyCustomURDFDemo : public CommonMultiBodyBase
|
||||
{
|
||||
btMultiBody* m_multiBody;
|
||||
|
||||
public:
|
||||
|
||||
MultiBodyCustomURDFDemo(struct GUIHelperInterface* helper);
|
||||
virtual ~MultiBodyCustomURDFDemo();
|
||||
|
||||
virtual void initPhysics();
|
||||
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
};
|
||||
|
||||
MultiBodyCustomURDFDemo::MultiBodyCustomURDFDemo(struct GUIHelperInterface* helper)
|
||||
:CommonMultiBodyBase(helper)
|
||||
{
|
||||
}
|
||||
|
||||
MultiBodyCustomURDFDemo::~MultiBodyCustomURDFDemo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void myPrintTree(const URDFImporterInterface& u2b, int linkIndex, int indentationLevel)
|
||||
{
|
||||
btAlignedObjectArray<int> childIndices;
|
||||
u2b.getLinkChildIndices(linkIndex,childIndices);
|
||||
|
||||
int numChildren = childIndices.size();
|
||||
|
||||
indentationLevel+=2;
|
||||
int count = 0;
|
||||
for (int i=0;i<numChildren;i++)
|
||||
{
|
||||
int childLinkIndex = childIndices[i];
|
||||
std::string name = u2b.getLinkName(childLinkIndex);
|
||||
for(int j=0;j<indentationLevel;j++) printf(" "); //indent
|
||||
printf("child(%d).name=%s with childIndex=%d\n",(count++)+1, name.c_str(),childLinkIndex);
|
||||
// first grandchild
|
||||
printTree(u2b,childLinkIndex,indentationLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class TestMultiBodyCreationCallback : public CustomMultiBodyCreationCallback
|
||||
{
|
||||
virtual int allocateMultiBodyBase(int urdfLinkIndex, int totalNumJoints,ScalarType baseMass, const Vector3dType& localInertiaDiagonal, bool isFixedBase)
|
||||
{
|
||||
printf("added base\n");
|
||||
}
|
||||
|
||||
virtual void addLinkAndJoint(int jointType, int linkIndex, // 0 to num_links-1
|
||||
int parentIndex,
|
||||
double mass,
|
||||
const Vector3dType& inertia,
|
||||
const QuaternionType &rotParentFrameToLinkFrame, // rotate points in parent frame to this frame, when q = 0
|
||||
const Vector3dType& jointAxisInLinkFrame, // in Link frame
|
||||
const Vector3dType& parentComToThisJointOffset, // vector from parent COM to joint frame, in Parent frame
|
||||
const Vector3dType& thisJointToThisComOffset) // vector from joint frame to my COM, in Link frame);
|
||||
{
|
||||
printf("added link\n");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void MultiBodyCustomURDFDemo::initPhysics()
|
||||
{
|
||||
int upAxis = 2;
|
||||
m_guiHelper->setUpAxis(upAxis);
|
||||
createEmptyDynamicsWorld();
|
||||
btVector3 grav(0,0,0);
|
||||
//grav[upAxis] = -10.f;
|
||||
|
||||
m_dynamicsWorld->setGravity(grav);
|
||||
|
||||
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||
|
||||
|
||||
|
||||
MyURDFImporter u2b(m_guiHelper);
|
||||
bool loadOk = u2b.loadURDF("r2d2.urdf");
|
||||
|
||||
if (loadOk)
|
||||
{
|
||||
u2b.printTree();
|
||||
int urdfRootLinkIndex = u2b.getRootLinkIndex();
|
||||
myPrintTree(u2b,urdfRootLinkIndex,0);
|
||||
|
||||
btTransform identityTrans;
|
||||
identityTrans.setIdentity();
|
||||
|
||||
btMultiBody* mb = 0;
|
||||
|
||||
|
||||
//todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user
|
||||
int rootLinkIndex = u2b.getRootLinkIndex();
|
||||
printf("urdf root link index = %d\n",rootLinkIndex);
|
||||
MyMultiBodyCreator creation(m_guiHelper);
|
||||
|
||||
bool useMultiBody = true;
|
||||
|
||||
ConvertURDF2Bullet(u2b,creation, identityTrans,m_dynamicsWorld,useMultiBody,u2b.getPathPrefix());
|
||||
mb = creation.getBulletMultiBody();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MultiBodyCustomURDFDemo::stepSimulation(float deltaTime)
|
||||
{
|
||||
m_dynamicsWorld->stepSimulation(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
class CommonExampleInterface* MultiBodyCustomURDFDemoCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
{
|
||||
return new MultiBodyCustomURDFDemo(helper);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/* Copyright (C) 2015 Google
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MULTI_DOF_CUSTOM_URDF_DEMO_H
|
||||
#define MULTI_DOF_CUSTOM_URDF_DEMO_H
|
||||
|
||||
class CommonExampleInterface* MultiBodyCustomURDFDemoCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
|
||||
#endif //MULTI_DOF_CUSTOM_URDF_DEMO_H
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2015 Google Inc. http://bulletphysics.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "MultiBodyCustomURDFDemo.h"
|
||||
|
||||
#include "../CommonInterfaces/CommonExampleInterface.h"
|
||||
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
struct PhysicsInterface* pint = 0;
|
||||
|
||||
DummyGUIHelper noGfx;
|
||||
|
||||
int option = 0;
|
||||
|
||||
CommonExampleInterface* example = MultiBodyCustomURDFDemoCreateFunc(pint, &noGfx, option);
|
||||
|
||||
example->initPhysics();
|
||||
example->stepSimulation(1.f/60.f);
|
||||
example->exitPhysics();
|
||||
|
||||
delete example;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
|
||||
project "App_CustomMultiBodyCreation"
|
||||
|
||||
if _OPTIONS["ios"] then
|
||||
kind "WindowedApp"
|
||||
else
|
||||
kind "ConsoleApp"
|
||||
end
|
||||
|
||||
includedirs {".", "../../src", "../ThirdPartyLibs"}
|
||||
|
||||
links {
|
||||
"Bullet3Common", "BulletDynamics","BulletCollision", "LinearMath"
|
||||
}
|
||||
|
||||
language "C++"
|
||||
|
||||
files {
|
||||
"MultiBodyCustomURDFDemo.cpp",
|
||||
"main.cpp",
|
||||
"../Importers/ImportURDFDemo/URDF2Bullet.cpp",
|
||||
"../Importers/ImportURDFDemo/MyURDFImporter.cpp",
|
||||
"../Importers/ImportURDFDemo/MyMultiBodyCreator.cpp",
|
||||
"../Importers/ImportObjDemo/LoadMeshFromObj.cpp",
|
||||
"../Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
|
||||
"../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
|
||||
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
|
||||
"../ThirdPartyLibs/tinyxml/tinystr.cpp",
|
||||
"../ThirdPartyLibs/tinyxml/tinyxml.cpp",
|
||||
"../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
|
||||
"../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
|
||||
"../ThirdPartyLibs/urdf/boost_replacement/printf_console.cpp",
|
||||
"../ThirdPartyLibs/urdf/boost_replacement/string_split.cpp",
|
||||
"../ThirdPartyLibs/urdf/urdfdom/urdf_parser/src/pose.cpp",
|
||||
"../ThirdPartyLibs/urdf/urdfdom/urdf_parser/src/model.cpp",
|
||||
"../ThirdPartyLibs/urdf/urdfdom/urdf_parser/src/link.cpp",
|
||||
"../ThirdPartyLibs/urdf/urdfdom/urdf_parser/src/joint.cpp",
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user