Skip to content

Commit

Permalink
Merge pull request RobotLocomotion#575 from tkoolen/win-compatibility
Browse files Browse the repository at this point in the history
DrakeGradientUtil, DrakeGeometryUtil, DrakeJoint, and RigidBodyManipulator.geometricJacobian on Windows
  • Loading branch information
RussTedrake committed Nov 26, 2014
2 parents 59473fe + eae8ba6 commit a49c5e7
Show file tree
Hide file tree
Showing 34 changed files with 437 additions and 381 deletions.
9 changes: 1 addition & 8 deletions systems/plants/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ if (eigen3_FOUND)
# todo: check eigen version. 3.1.0 didn't work for clang. 3.2.0 did.
add_library(drakeRBM SHARED RigidBodyManipulator.cpp RigidBody.cpp)
target_link_libraries(drakeRBM drakeCollision)
if (NOT WIN32)
include_directories( joints )
target_link_libraries(drakeRBM drakeJoints)
endif(NOT WIN32)

pods_install_libraries(drakeRBM)
pods_install_headers(RigidBodyManipulator.h RigidBody.h RigidBodyFrame.h KinematicPath.h DESTINATION drake)
Expand All @@ -30,10 +28,7 @@ endif(NOT WIN32)

add_subdirectory(collision)
add_subdirectory(constraint)

if (NOT WIN32)
add_subdirectory(joints)
endif(NOT WIN32)

if (Boost_FOUND)
add_library(drakeRBMurdf URDFRigidBodyManipulator.cpp)
Expand Down Expand Up @@ -66,9 +61,7 @@ endif(NOT WIN32)
add_rbm_mex(allCollisionsmex)
add_rbm_mex(getCMMmex)
add_rbm_mex(findKinematicPathmex)
if (NOT MSVC)
add_rbm_mex(geometricJacobianmex) # todo: pull this out
endif()
add_rbm_mex(geometricJacobianmex)

add_library(drakeIKoptions SHARED IKoptions.cpp)
target_link_libraries(drakeIKoptions drakeRBM drakeUtil)
Expand Down
5 changes: 4 additions & 1 deletion systems/plants/IKoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#include <Eigen/Dense>
using namespace Eigen;

#undef drakeIKoptions_DLLEXPORT
#if defined(WIN32) || defined(WIN64)
#if defined(drakeIKoptions_EXPORTS)
#define drakeIKoptions_DLLEXPORT __declspec( dllexport )
#elif defined(drakeIK_EXPORTS) // because this gets built in both the drakeIKoptions target and the drakeIK target...
#define drakeIKoptions_DLLEXPORT __declspec( dllexport )
#else
#define drakeIKoptions_DLLEXPORT __declspec( dllimport )
#endif
#endif
#else
#define drakeIKoptions_DLLEXPORT
#endif
Expand Down
3 changes: 0 additions & 3 deletions systems/plants/KinematicPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include <vector>
#include <memory>

class DrakeJoint;
class RigidBody;

struct KinematicPath
{
std::vector<int> joint_path;
Expand Down
3 changes: 0 additions & 3 deletions systems/plants/RigidBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ void RigidBody::setN(int n) {
}


#if !defined(_WIN32) && !defined(_WIN64)

void RigidBody::setJoint(std::unique_ptr<DrakeJoint> joint)
{
this->joint = move(joint);
Expand All @@ -42,7 +40,6 @@ const DrakeJoint& RigidBody::getJoint() const
throw runtime_error("Joint is not initialized");
}
}
#endif

void RigidBody::computeAncestorDOFs(RigidBodyManipulator* model)
{
Expand Down
9 changes: 3 additions & 6 deletions systems/plants/RigidBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include <set>
#include <Eigen/StdVector>
#include <memory>
#include "DrakeJoint.h"

class DLLEXPORT IndexRange {
class DLLEXPORT_RBM IndexRange {
public:
int start;
int length;
Expand All @@ -21,22 +22,18 @@ class RigidBodyManipulator;

using namespace Eigen;

class DLLEXPORT RigidBody {
#if !defined(_WIN32) && !defined(_WIN64)
class DLLEXPORT_RBM RigidBody {
private:
std::unique_ptr<DrakeJoint> joint;
#endif

public:
RigidBody();

void setN(int n);
void computeAncestorDOFs(RigidBodyManipulator* model);

#if !defined(_WIN32) && !defined(_WIN64)
void setJoint(std::unique_ptr<DrakeJoint> joint);
const DrakeJoint& getJoint() const;
#endif

public:
std::string linkname;
Expand Down
2 changes: 1 addition & 1 deletion systems/plants/RigidBodyFrame.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _RIGIDBODYFRAME_H_
#define _RIGIDBODYFRAME_H_

class DLLEXPORT RigidBodyFrame {
class DLLEXPORT_RBM RigidBodyFrame {
public:
std::string name;
int body_ind;
Expand Down
93 changes: 45 additions & 48 deletions systems/plants/RigidBodyManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//#include "mex.h"
#include "drakeGeometryUtil.h"
#include "RigidBodyManipulator.h"
#include "DrakeJoint.h"

#include <algorithm>
#include <string>
Expand Down Expand Up @@ -1292,7 +1293,6 @@ void RigidBodyManipulator::bodyKin(const int body_or_frame_id, const MatrixBase<

}

#if !defined(WIN32) && !defined(WIN64)
template<typename DerivedA>
void RigidBodyManipulator::geometricJacobian(int base_body_or_frame_ind, int end_effector_body_or_frame_ind, int expressed_in_body_or_frame_ind, PlainObjectBase<DerivedA>& J, std::vector<int>* v_indices)
{
Expand Down Expand Up @@ -1342,7 +1342,6 @@ void RigidBodyManipulator::geometricJacobian(int base_body_or_frame_ind, int end
}
J = transformSpatialMotion(Isometry3d(T_world_to_frame), J);
}
#endif

template <typename DerivedA, typename DerivedB>
void RigidBodyManipulator::forwardJac(const int body_or_frame_id, const MatrixBase<DerivedA> &pts, const int rotation_type, MatrixBase<DerivedB> &J)
Expand Down Expand Up @@ -1748,50 +1747,48 @@ std::string RigidBodyManipulator::getBodyOrFrameName(int body_or_frame_id)


// explicit instantiations (required for linking):
template DLLEXPORT void RigidBodyManipulator::getCMM(double * const, double * const, MatrixBase< Map<MatrixXd> > &, MatrixBase< Map<MatrixXd> > &);
template DLLEXPORT void RigidBodyManipulator::getCMM(double * const, double * const, MatrixBase< MatrixXd > &, MatrixBase< MatrixXd > &);
template DLLEXPORT void RigidBodyManipulator::getCOM(MatrixBase< Map<Vector3d> > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOM(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOMJac(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOMdJac(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOMJacDot(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOM(MatrixBase< Vector3d > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOM(MatrixBase< MatrixXd > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOMJac(MatrixBase< MatrixXd > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOMdJac(MatrixBase< MatrixXd > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getCOMJacDot(MatrixBase< MatrixXd > &,const set<int> &);

template DLLEXPORT void RigidBodyManipulator::getContactPositions(MatrixBase <MatrixXd > &, const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getContactPositionsJac(MatrixBase <MatrixXd > &,const set<int> &);
template DLLEXPORT void RigidBodyManipulator::getContactPositionsJacDot(MatrixBase <MatrixXd > &,const set<int> &);

template DLLEXPORT void RigidBodyManipulator::forwardKin(const int, const MatrixBase< MatrixXd >&, const int, MatrixBase< Map<MatrixXd> > &);
template DLLEXPORT void RigidBodyManipulator::forwardKin(const int, const MatrixBase< MatrixXd >&, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT void RigidBodyManipulator::forwardKin(const int, MatrixBase< Vector4d > const&, const int, MatrixBase< Vector3d > &);
template DLLEXPORT void RigidBodyManipulator::forwardKin(const int, MatrixBase< Vector4d > const&, const int, MatrixBase< Matrix<double,6,1> > &);
template DLLEXPORT void RigidBodyManipulator::forwardKin(const int, MatrixBase< Vector4d > const&, const int, MatrixBase< Matrix<double,7,1> > &);
template DLLEXPORT void RigidBodyManipulator::forwardKin(const int, MatrixBase< Map<MatrixXd> > const&, const int, MatrixBase< MatrixXd > &);
//template DLLEXPORT void RigidBodyManipulator::forwardKin(const int, const MatrixBase< Vector4d >&, const int, MatrixBase< Vector3d > &);
template DLLEXPORT void RigidBodyManipulator::forwardJac(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< Map<MatrixXd> > &);
//template DLLEXPORT void RigidBodyManipulator::forwardJac(const int, MatrixBase< Map<MatrixXd> > const&, const int, MatrixBase< MatrixXd > &);
//template DLLEXPORT void RigidBodyManipulator::forwardJac(const int, MatrixBase< MatrixXd > const&, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT void RigidBodyManipulator::forwardJac(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT void RigidBodyManipulator::forwardJac(const int, const MatrixBase< Vector4d > &, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT void RigidBodyManipulator::forwarddJac(const int, const MatrixBase< MatrixXd > &, MatrixBase< Map<MatrixXd> >&);
template DLLEXPORT void RigidBodyManipulator::forwarddJac(const int, const MatrixBase< MatrixXd > &, MatrixBase< MatrixXd >&);
//template DLLEXPORT void RigidBodyManipulator::forwarddJac(const int, const MatrixBase< Vector4d > &, MatrixBase< MatrixXd >&);
template DLLEXPORT void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< Map<MatrixXd> >&);
template DLLEXPORT void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< MatrixXd >&);
template DLLEXPORT void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< Vector4d > &, const int, MatrixBase< MatrixXd >&);
//template DLLEXPORT void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< Vector4d > &, MatrixBase< MatrixXd >&);
template DLLEXPORT void RigidBodyManipulator::bodyKin(const int, const MatrixBase< MatrixXd >&, MatrixBase< Map<MatrixXd> > &, MatrixBase< Map<MatrixXd> > *, MatrixBase< Map<MatrixXd> > *);
template DLLEXPORT void RigidBodyManipulator::bodyKin(const int, const MatrixBase< MatrixXd >&, MatrixBase< MatrixXd > &, MatrixBase< MatrixXd > *, MatrixBase< MatrixXd > *);

#if !defined(WIN32) && !defined(WIN64)
template DLLEXPORT void RigidBodyManipulator::geometricJacobian(int, int, int, PlainObjectBase< Matrix<double, 6, Dynamic> >&, std::vector<int>*);
template DLLEXPORT void RigidBodyManipulator::geometricJacobian(int, int, int, PlainObjectBase< MatrixXd >&, std::vector<int>*);
#endif

template DLLEXPORT void RigidBodyManipulator::HandC(double* const, double * const, MatrixBase< Map<MatrixXd> > * const, MatrixBase< Map<MatrixXd> > &, MatrixBase< Map<VectorXd> > &, MatrixBase< Map<MatrixXd> > *, MatrixBase< Map<MatrixXd> > *, MatrixBase< Map<MatrixXd> > * const);
template DLLEXPORT void RigidBodyManipulator::HandC(double* const, double * const, MatrixBase< MatrixXd > * const, MatrixBase< MatrixXd > &, MatrixBase< VectorXd > &, MatrixBase< MatrixXd > *, MatrixBase< MatrixXd > *, MatrixBase< MatrixXd > * const);
template DLLEXPORT_RBM void RigidBodyManipulator::getCMM(double * const, double * const, MatrixBase< Map<MatrixXd> > &, MatrixBase< Map<MatrixXd> > &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCMM(double * const, double * const, MatrixBase< MatrixXd > &, MatrixBase< MatrixXd > &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOM(MatrixBase< Map<Vector3d> > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOM(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOMJac(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOMdJac(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOMJacDot(MatrixBase< Map<MatrixXd> > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOM(MatrixBase< Vector3d > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOM(MatrixBase< MatrixXd > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOMJac(MatrixBase< MatrixXd > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOMdJac(MatrixBase< MatrixXd > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getCOMJacDot(MatrixBase< MatrixXd > &,const set<int> &);

template DLLEXPORT_RBM void RigidBodyManipulator::getContactPositions(MatrixBase <MatrixXd > &, const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getContactPositionsJac(MatrixBase <MatrixXd > &,const set<int> &);
template DLLEXPORT_RBM void RigidBodyManipulator::getContactPositionsJacDot(MatrixBase <MatrixXd > &,const set<int> &);

template DLLEXPORT_RBM void RigidBodyManipulator::forwardKin(const int, const MatrixBase< MatrixXd >&, const int, MatrixBase< Map<MatrixXd> > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardKin(const int, const MatrixBase< MatrixXd >&, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardKin(const int, MatrixBase< Vector4d > const&, const int, MatrixBase< Vector3d > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardKin(const int, MatrixBase< Vector4d > const&, const int, MatrixBase< Matrix<double,6,1> > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardKin(const int, MatrixBase< Vector4d > const&, const int, MatrixBase< Matrix<double,7,1> > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardKin(const int, MatrixBase< Map<MatrixXd> > const&, const int, MatrixBase< MatrixXd > &);
//template DLLEXPORT_RBM void RigidBodyManipulator::forwardKin(const int, const MatrixBase< Vector4d >&, const int, MatrixBase< Vector3d > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardJac(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< Map<MatrixXd> > &);
//template DLLEXPORT_RBM void RigidBodyManipulator::forwardJac(const int, MatrixBase< Map<MatrixXd> > const&, const int, MatrixBase< MatrixXd > &);
//template DLLEXPORT_RBM void RigidBodyManipulator::forwardJac(const int, MatrixBase< MatrixXd > const&, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardJac(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardJac(const int, const MatrixBase< Vector4d > &, const int, MatrixBase< MatrixXd > &);
template DLLEXPORT_RBM void RigidBodyManipulator::forwarddJac(const int, const MatrixBase< MatrixXd > &, MatrixBase< Map<MatrixXd> >&);
template DLLEXPORT_RBM void RigidBodyManipulator::forwarddJac(const int, const MatrixBase< MatrixXd > &, MatrixBase< MatrixXd >&);
//template DLLEXPORT_RBM void RigidBodyManipulator::forwarddJac(const int, const MatrixBase< Vector4d > &, MatrixBase< MatrixXd >&);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< Map<MatrixXd> >&);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< MatrixXd > &, const int, MatrixBase< MatrixXd >&);
template DLLEXPORT_RBM void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< Vector4d > &, const int, MatrixBase< MatrixXd >&);
//template DLLEXPORT_RBM void RigidBodyManipulator::forwardJacDot(const int, const MatrixBase< Vector4d > &, MatrixBase< MatrixXd >&);
template DLLEXPORT_RBM void RigidBodyManipulator::bodyKin(const int, const MatrixBase< MatrixXd >&, MatrixBase< Map<MatrixXd> > &, MatrixBase< Map<MatrixXd> > *, MatrixBase< Map<MatrixXd> > *);
template DLLEXPORT_RBM void RigidBodyManipulator::bodyKin(const int, const MatrixBase< MatrixXd >&, MatrixBase< MatrixXd > &, MatrixBase< MatrixXd > *, MatrixBase< MatrixXd > *);

template DLLEXPORT_RBM void RigidBodyManipulator::geometricJacobian(int, int, int, PlainObjectBase< Matrix<double, 6, Dynamic> >&, std::vector<int>*);
template DLLEXPORT_RBM void RigidBodyManipulator::geometricJacobian(int, int, int, PlainObjectBase< MatrixXd >&, std::vector<int>*);

template DLLEXPORT_RBM void RigidBodyManipulator::HandC(double* const, double * const, MatrixBase< Map<MatrixXd> > * const, MatrixBase< Map<MatrixXd> > &, MatrixBase< Map<VectorXd> > &, MatrixBase< Map<MatrixXd> > *, MatrixBase< Map<MatrixXd> > *, MatrixBase< Map<MatrixXd> > * const);
template DLLEXPORT_RBM void RigidBodyManipulator::HandC(double* const, double * const, MatrixBase< MatrixXd > * const, MatrixBase< MatrixXd > &, MatrixBase< VectorXd > &, MatrixBase< MatrixXd > *, MatrixBase< MatrixXd > *, MatrixBase< MatrixXd > * const);

18 changes: 6 additions & 12 deletions systems/plants/RigidBodyManipulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,17 @@
#include "collision/DrakeCollision.h"
#include "KinematicPath.h"

#undef DLLEXPORT
#undef DLLEXPORT_RBM
#if defined(WIN32) || defined(WIN64)
#if defined(drakeRBM_EXPORTS)
#define DLLEXPORT __declspec( dllexport )
#define DLLEXPORT_RBM __declspec( dllexport )
#else
#define DLLEXPORT __declspec( dllimport )
#define DLLEXPORT_RBM __declspec( dllimport )
#endif
#else
#define DLLEXPORT
#define DLLEXPORT_RBM
#endif

#if defined(WIN32) || defined(WIN64)
#else
#include "DrakeJoint.h" // todo: move this out of here
#endif

#include "RigidBody.h"
#include "RigidBodyFrame.h"
Expand All @@ -34,7 +30,7 @@ using namespace Eigen;

//extern std::set<int> emptyIntSet; // was const std:set<int> emptyIntSet, but valgrind said I was leaking memory

class DLLEXPORT RigidBodyManipulator
class DLLEXPORT_RBM RigidBodyManipulator
{
public:
RigidBodyManipulator(int num_dof, int num_featherstone_bodies=-1, int num_rigid_body_objects=-1, int num_rigid_body_frames=0);
Expand Down Expand Up @@ -90,10 +86,8 @@ class DLLEXPORT RigidBodyManipulator
template <typename DerivedA, typename DerivedB, typename DerivedC, typename DerivedD>
void bodyKin(const int body_ind, const MatrixBase<DerivedA>& pts, MatrixBase<DerivedB> &x, MatrixBase<DerivedC> *J=NULL, MatrixBase<DerivedD> *P=NULL);

#if !defined(WIN32) && !defined(WIN64)
template<typename DerivedA>
void geometricJacobian(int base_body_or_frame_ind, int end_effector_body_or_frame_ind, int expressed_in_body_or_frame_ind, PlainObjectBase<DerivedA>& J, std::vector<int>* v_indices);
#endif

template <typename DerivedA, typename DerivedB, typename DerivedC, typename DerivedD, typename DerivedE, typename DerivedF>
void HandC(double* const q, double * const qd, MatrixBase<DerivedA> * const f_ext, MatrixBase<DerivedB> &H, MatrixBase<DerivedC> &C, MatrixBase<DerivedD> *dH=NULL, MatrixBase<DerivedE> *dC=NULL, MatrixBase<DerivedF> * const df_ext=NULL);
Expand Down Expand Up @@ -256,7 +250,7 @@ class DLLEXPORT RigidBodyManipulator
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

// The following was required for building w/ DLLEXPORT on windows (due to the unique_ptrs). See
// The following was required for building w/ DLLEXPORT_RBM on windows (due to the unique_ptrs). See
// http://stackoverflow.com/questions/8716824/cannot-access-private-member-error-only-when-class-has-export-linkage
private:
RigidBodyManipulator(const RigidBodyManipulator&) {}
Expand Down
6 changes: 1 addition & 5 deletions systems/plants/constructModelmex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include "RigidBodyManipulator.h"
#include <stdexcept>

#if !defined(WIN32) && !defined(WIN64)
#include "joints/drakeJointUtil.h"
#endif
#include "joints/drakeJointUtil.h"

using namespace Eigen;
using namespace std;
Expand Down Expand Up @@ -146,10 +144,8 @@ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )

double pitch = mxGetScalar(mxGetProperty(pBodies, i, "pitch"));

#if !defined(WIN32) && !defined(WIN64)
model->bodies[i]->setJoint(createJoint(jointname, Ttree, floating, joint_axis, pitch));
// mexPrintf((model->bodies[i]->getJoint().getName() + "\n").c_str());
#endif
}
{
pm = mxGetProperty(pBodies,i,"jointname");
Expand Down
12 changes: 6 additions & 6 deletions systems/plants/geometricJacobianmex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ using namespace std;
*/

// TODO: stop copying these functions everywhere and find a good place for them
template<int RowsAtCompileTime, int ColsAtCompileTime>
mxArray* eigenToMatlab(Eigen::Matrix<double, RowsAtCompileTime, ColsAtCompileTime> &m)
template <typename DerivedA>
mxArray* eigenToMatlab(const DerivedA &m)
{
mxArray* pm = mxCreateDoubleMatrix(m.rows(), m.cols(), mxREAL);
if (m.rows() * m.cols() > 0)
memcpy(mxGetPr(pm), m.data(), sizeof(double) * m.rows() * m.cols());
return pm;
mxArray* pm = mxCreateDoubleMatrix(static_cast<int>(m.rows()),static_cast<int>(m.cols()),mxREAL);
if (m.rows()*m.cols()>0)
memcpy(mxGetPr(pm),m.data(),sizeof(double)*m.rows()*m.cols());
return pm;
}

mxArray* stdVectorToMatlab(const std::vector<int>& vec) {
Expand Down
Loading

0 comments on commit a49c5e7

Please sign in to comment.