constraint_app
/home/jbrooksh/drc/software/perception/constraint_app/src/matlab_mex/cam_getObservations.cpp
Go to the documentation of this file.
00001 #include "mex.h"
00002 #include "ConstraintApp.h"
00003 
00018 void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
00019 {
00020   if ( nrhs != 1 ) {
00021     mexErrMsgTxt("requires exactly 1 parameters"); 
00022   }
00023 
00024   ConstraintApp* app(*(ConstraintApp**)mxGetData(prhs[0]));
00025 
00026   if ( nlhs != 3 ) {
00027     mexErrMsgTxt("returns exactly 3 parameters");
00028   }
00029 
00030   std::vector<double> actualObservations;
00031   std::vector<std::string> observationIds;
00032   bool res = app->GetObservations(actualObservations, observationIds);
00033 
00034   plhs[0] = mxCreateLogicalScalar(res);
00035   plhs[1] = mxCreateDoubleMatrix(1, actualObservations.size(), mxREAL);
00036   mwSize dims[1] = { observationIds.size() };
00037   plhs[2] = mxCreateCellArray(1, dims);
00038 
00039   for ( int i = 0; i < observationIds.size(); i++ ) {
00040     mxArray* str = mxCreateString(observationIds[i].c_str());
00041     mxSetCell(plhs[2], i, str);
00042   }
00043 
00044   double* ao((double*)mxGetData(plhs[1]));
00045   std::copy(actualObservations.begin(), actualObservations.end(), ao);
00046 }
 All Classes Files Functions Variables Typedefs