-
Notifications
You must be signed in to change notification settings - Fork 632
MatlabBindings
Jesús Briales edited this page Feb 24, 2015
·
8 revisions
Firstly, BUILD_MATLAB option in Cmake should be activated in order to add all MRPT-Matlab functionalities and access different options.
Once BUILD_MATLAB is activated, a new group of options MATLAB will appear. Currently the Cmake script is automated to look for MATLAB installation in its usual folder and take the latest version. If some problem happens the necessary paths should be given by hand.
The different available MEX applications to build are given with the prefix BUILD_MEX_
- mex-grabber A wrapper for usual rawlog-grabber app which allows to initialize any device supported by MRPT and take reads from Matlab.
- In the class_name header file:
- Add DECLARE_MEX_CONVERSION macro inside class definition to declare writeToMatlab virtual method.
- Add DECLARE_MEXPLUS_FROM(class_name) outside class definition to specialize mexplus::from template function with a customized version (to write in the implementation file of class_name).
- In the class_name implementation file (and always with
#if MRPT_HAS_MATLAB
directive!):
- Add IMPLEMENTS_MEXPLUS_FROM(class_name) to set a call to the class method writeToMatlab when the function mexplus::from is called with class_name argument.
- Write custom implementation for writeToMatlab method. Here there is an example of typical implementation:
#if MRPT_HAS_MATLAB
IMPLEMENTS_MEXPLUS_FROM( mrpt::obs::CObservationImage )
mxArray* CObservationImage::writeToMatlab() const
{
const char* fields[] = {"ts","sensorLabel","image","pose","params"};
mexplus::MxArray obs_struct( mexplus::MxArray::Struct(sizeof(fields)/sizeof(fields[0]),fields) );
obs_struct.set("ts", this->timestamp);
obs_struct.set("sensorLabel", this->sensorLabel);
obs_struct.set("image", this->image);
obs_struct.set("pose", this->cameraPose);
obs_struct.set("params", this->cameraParams);
return obs_struct.release();
}
#endif