From 332017ff23008b11c31604f6ff094396b501ceb3 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 2 Dec 2015 17:49:25 -0800 Subject: [PATCH] remove dependency on gflags, C++11 from test_invdyn_bullet.cpp add support for premake for test_invdyn_bullet --- test/InverseDynamics/premake4.lua | 73 +++++++++++++++++++++ test/InverseDynamics/test_invdyn_bullet.cpp | 19 +++--- 2 files changed, 82 insertions(+), 10 deletions(-) diff --git a/test/InverseDynamics/premake4.lua b/test/InverseDynamics/premake4.lua index 73730b0ab..b16efbaae 100644 --- a/test/InverseDynamics/premake4.lua +++ b/test/InverseDynamics/premake4.lua @@ -32,3 +32,76 @@ if os.is("Linux") then links {"pthread"} end + + + + + + project "Test_InverseForwardDynamics" + + kind "ConsoleApp" + +-- defines { } + + + + includedirs + { + ".", + "../../src", + "../../examples/InverseDynamics", + "../../examples/ThirdPartyLibs", + "../../Extras/InverseDynamics", + "../gtest-1.7.0/include" + + } + + + if os.is("Windows") then + --see http://stackoverflow.com/questions/12558327/google-test-in-visual-studio-2012 + defines {"_VARIADIC_MAX=10"} + end + + links {"BulletDynamics", "BulletCollision","BulletInverseDynamicsUtils", "BulletInverseDynamics","Bullet3Common","LinearMath", "gtest"} + + files { + "test_invdyn_bullet.cpp", + "../../examples/Utils/b3ResourcePath.cpp", + "../../examples/Importers/ImportURDFDemo/ConvertRigidBodies2MultiBody.h", + "../../examples/Importers/ImportURDFDemo/MultiBodyCreationInterface.h", + "../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp", + "../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.h", + "../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp", + "../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.h", + "../../examples/Importers/ImportURDFDemo/UrdfParser.cpp", + "../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp", + "../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.h", + "../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp", + "../../examples/Importers/ImportURDFDemo/UrdfParser.cpp", + "../../examples/Importers/ImportURDFDemo/UrdfParser.h", + "../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp", + "../../examples/Importers/ImportURDFDemo/URDF2Bullet.h", + "../../examples/Utils/b3Clock.cpp", + "../../Extras/Serialize/BulletWorldImporter/*", + "../../Extras/Serialize/BulletFileLoader/*", + "../../examples/Importers/ImportURDFDemo/URDFImporterInterface.h", + "../../examples/Importers/ImportURDFDemo/URDFJointTypes.h", + "../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp", + "../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp", + "../../examples/Importers/ImportSTLDemo/ImportSTLSetup.h", + "../../examples/Importers/ImportSTLDemo/LoadMeshFromSTL.h", + "../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp", + "../../examples/Importers/ImportColladaDemo/ColladaGraphicsInstance.h", + "../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", + "../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp", + "../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp", + "../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp", + "../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp", + "../../examples/ThirdPartyLibs/urdf/boost_replacement/lexical_cast.h", + + } + + if os.is("Linux") then + links {"pthread"} + end + diff --git a/test/InverseDynamics/test_invdyn_bullet.cpp b/test/InverseDynamics/test_invdyn_bullet.cpp index ab7578a48..328a2c239 100644 --- a/test/InverseDynamics/test_invdyn_bullet.cpp +++ b/test/InverseDynamics/test_invdyn_bullet.cpp @@ -18,7 +18,6 @@ #include #include #include <../CommonInterfaces/CommonGUIHelperInterface.h> -#include #include #include <../Importers/ImportURDFDemo/BulletUrdfImporter.h> #include <../Importers/ImportURDFDemo/URDF2Bullet.h> @@ -29,10 +28,12 @@ #include #include #include +#include "Bullet3Common/b3CommandLineArgs.h" +#include "Bullet3Common/b3Random.h" using namespace btInverseDynamics; -DEFINE_bool(verbose, false, "print extra info"); +bool FLAGS_verbose=false; static btVector3 gravity(0, 0, -10); static const bool kBaseFixed = false; @@ -67,15 +68,13 @@ TEST(InvDynCompare, bulletUrdfR2D2) { double max_pos_error = 0; double max_acc_error = 0; - std::default_random_engine generator; - std::uniform_real_distribution distribution(-M_PI, M_PI); - auto rnd = std::bind(distribution, generator); + b3Srand(0); for (int loop = 0; loop < kNLoops; loop++) { for (int i = 0; i < q.size(); i++) { - q(i) = rnd(); - u(i) = rnd(); - dot_u(i) = rnd(); + q(i) = b3RandRange(-B3_PI, B3_PI); + u(i) = b3RandRange(-B3_PI, B3_PI); + dot_u(i) = b3RandRange(-B3_PI, B3_PI); } double pos_error; @@ -108,8 +107,8 @@ TEST(InvDynCompare, bulletUrdfR2D2) { } int main(int argc, char **argv) { - gflags::SetUsageMessage("Usage: invdyn_from_btmultibody -verbose = true/false"); - gflags::ParseCommandLineFlags(&argc, &argv, false); + b3CommandLineArgs myArgs(argc,argv); + FLAGS_verbose = myArgs.CheckCmdLineFlag("verbose"); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }