Quantcast

Create standalone Matlab mex-file for Inverse Kinematics

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Create standalone Matlab mex-file for Inverse Kinematics

AndersonWayne
Hi Rosen,

I am working with a 7-DoF manipulator and I am a beginner with openrave. I generated the manipulator's ik.cpp file and I used the solver with ROS/Moveit/rviz just to check that everything is ok. But that's not my main objetive.

What I really want to do is use this inverse kinematics solver in a Simulink Real Time Workshop. In a try of doing this, I want to compile my ik.cpp in a mex file in such a way I could use it as a standalone application or a standalone matlab function.

First question: Is that or something similar possible?

I am using Matlab 2014a on ubuntu trusty 64bits and openrave 0.9.

So here is my attemp:

1. After setting up gcc and g++ compilers for this version of Matlab on trusty (trusty uses by default gcc-4.8, but Matlab2014a only supports gcc/g++<4.7.x)  I put ikfast.h at the same folder.

2. Then I add #include "mex.h" to both *.cpp and *.h files.

3. And I compile using mex and linking lapack and blas libraries:

mex ik.cpp -L../lib/lapack -llapack  -L../lib/BLAS -lblas
Building with 'g++'.
MEX completed successfully.


4. I obtain a ik.mex64 file. "Cool", I thought. Then I have tried test this function in a similar way I could do on a linux terminal (./ik r00 r01 r02 t0 r10 r11 r12 t1 r20 r21 r22 t2 free0 ...), that is, something like this:

ik(r00, r01, r02, t0, r10, r11, r12, t1, r20, r21, r22, t2, free0)

And finally here is it my awesome matlab error:

ik(0.9721, -0.1918, -0.1347, -0.0355, 0.1844, 0.9806, -0.0659, -0.0537, 0.1447, 0.0393, 0.9887, 0.7011, 0.122)
Mex file entry point is missing.  Please check the (case-sensitive)
spelling of mexFunction (for C MEX-files), or the (case-insensitive)
spelling of MEXFUNCTION (for FORTRAN MEX-files).
Invalid MEX-file '/home/ivan/Matlab_IKfast/ik.mexa64'

Second question:  I'm just being silly?

Thanks in advance for any help! And congratulations for your great job.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create standalone Matlab mex-file for Inverse Kinematics

Rosen Diankov
Administrator
Dear Anderson,

I think you'll have to wrap the IK call inside a mexFunction (in C++).
I recommend you leave the ikfast files unchanged and add any matlab logic in a separate c++ file.
Since ikfast has a header file (ikfast.h), this is possible.
In your own C++ file, you would create the mexFunction (and other mex entry points) and then call ikfast's ComputeIk function

best,
rosen,


2014-12-17 0:41 GMT+09:00 AndersonWayne <[hidden email]>:
Hi Rosen,

I am working with a 7-DoF manipulator and I am a beginner with openrave. I
generated the manipulator's /ik.cpp /file and I used the solver with
ROS/Moveit/rviz just to check that everything is ok. But that's not my main
objetive.

What I really want to do is use this inverse kinematics solver in a Simulink
Real Time Workshop. In a try of doing this, I want to compile my /ik.cpp/ in
a mex file in such a way I could use it as a standalone application or a
standalone matlab function.

First question: Is that or something similar possible?

I am using Matlab 2014a on ubuntu trusty 64bits and openrave 0.9.

So here is my attemp:

1. After setting up gcc and g++ compilers for this version of Matlab on
trusty (trusty uses by default gcc-4.8, but Matlab2014a only supports
gcc/g++<4.7.x)  I put /ikfast.h/ at the same folder.

2. Then I add /#include "mex.h"/ to both *.cpp and *.h files.

3. And I compile using mex and linking lapack and blas libraries:

/mex ik.cpp -L../lib/lapack -llapack  -L../lib/BLAS -lblas
Building with 'g++'.
MEX completed successfully./

4. I obtain a /ik.mex64 file/. "Cool", I thought. Then I have tried test
this function in a similar way I could do on a linux terminal (./ik r00 r01
r02 t0 r10 r11 r12 t1 r20 r21 r22 t2 free0 ...), that is, something like
this:

ik(r00, r01, r02, t0, r10, r11, r12, t1, r20, r21, r22, t2, free0)

And finally here is it my awesome matlab error:

ik(0.9721, -0.1918, -0.1347, -0.0355, 0.1844, 0.9806, -0.0659, -0.0537,
0.1447, 0.0393, 0.9887, 0.7011, 0.122)
Mex file entry point is missing.  Please check the (case-sensitive)
spelling of mexFunction (for C MEX-files), or the (case-insensitive)
spelling of MEXFUNCTION (for FORTRAN MEX-files).
Invalid MEX-file '/home/ivan/Matlab_IKfast/ik.mexa64'

Second question:  I'm just being silly?

Thanks in advance for any help! And congratulations for your great job.




--
View this message in context: http://openrave-users-list.185357.n3.nabble.com/Create-standalone-Matlab-mex-file-for-Inverse-Kinematics-tp4027183.html
Sent from the OpenRAVE Users List mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Loading...