/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2013 Erwin Coumans 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. */ ///original version written by Erwin Coumans, October 2013 #ifndef BT_PATH_SOLVER_H #define BT_PATH_SOLVER_H //#define BT_USE_PATH #ifdef BT_USE_PATH extern "C" { #include "PATH/SimpleLCP.h" #include "PATH/License.h" #include "PATH/Error_Interface.h" }; void __stdcall MyError(Void *data, Char *msg) { printf("Path Error: %s\n",msg); } void __stdcall MyWarning(Void *data, Char *msg) { printf("Path Warning: %s\n",msg); } Error_Interface e; #include "btMLCPSolverInterface.h" #include "Dantzig/lcp.h" class btPathSolver : public btMLCPSolverInterface { public: btPathSolver() { License_SetString("2069810742&Courtesy_License&&&USR&2013&14_12_2011&1000&PATH&GEN&31_12_2013&0_0_0&0&0_0"); e.error_data = 0; e.warning = MyWarning; e.error = MyError; Error_SetInterface(&e); } virtual bool solveMLCP(const btMatrixXu & A, const btVectorXu & b, btVectorXu& x, const btVectorXu & lo,const btVectorXu & hi,const btAlignedObjectArray& limitDependency, int numIterations, bool useSparsity = true) { MCP_Termination status; int numVariables = b.rows(); if (0==numVariables) return true; /* - variables - the number of variables in the problem - m_nnz - the number of nonzeros in the M matrix - m_i - a vector of size m_nnz containing the row indices for M - m_j - a vector of size m_nnz containing the column indices for M - m_ij - a vector of size m_nnz containing the data for M - q - a vector of size variables - lb - a vector of size variables containing the lower bounds on x - ub - a vector of size variables containing the upper bounds on x */ btAlignedObjectArray values; btAlignedObjectArray rowIndices; btAlignedObjectArray colIndices; for (int i=0;i zResult; zResult.resize(numVariables); btAlignedObjectArray rhs; btAlignedObjectArray upperBounds; btAlignedObjectArray lowerBounds; for (int i=0;i