/************************************************************************** * Source File: linkdist6.c * * Description: Compute distance to obstacle with many shapes, for link * * class with any number of shapes per link, and output a matrix: * * with each row a vector from each obstacle to each shape in robot, * * then the near point on the robot, then the robot link number. * * Author: Juanita Albro (standing on the shoulders of giants) * * Modifications: * * University of California at Irvine, 2002, 2005 * * Questions/comments: juanita@eng.uci.edu * **************************************************************************/ #include "mex.h" #include #include #include "mattoc.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if (nrhs !=5){ mexErrMsgTxt("five input arguments required: l,pos,g,tot_obs,vec_shapes"); }else if (nlhs > 1){ mexErrMsgTxt("Only one output argument allowed."); } // feeble attempt at error checking the input arguments if (!mxIsStruct(prhs[0]) || !mxIsStruct(prhs[2])){ mexErrMsgTxt("Error with input arguments."); } Vector pos,vel,acc,tau,apmap; unsigned int n = mxGetN(prhs[0]); pos.Resize(n); vel.Resize(n); acc.Resize(n); tau.Resize(n); apmap.Resize(n); vel.Zero(); acc.Zero(); tau.Zero(); pos = mattocvector(prhs[1]); Link *l1; l1 = mattoclink(prhs[0],pos,vel,acc,tau,apmap); Geometry g; g = mattocgeometry(prhs[2]); //JVC mod Vector vecshapes; vecshapes.Resize(n); vecshapes = mattocvector(prhs[4]); double *obsno = mxGetPr(prhs[3]); int totobs = (int) *obsno; //printf("tot obs = %d\n",totobs); //JVC mod end DistanceCollection d; l1->Distance(g,d); //l1->DistanceDerivative(g,d); //JVC mod //for now, just see what's in DistanceCollection n = d.NumPoints(); printf("n is %d\n",n); for (int i = 0; iReorderDistanceToMatlab(min,totobs,vecshapes); mout = l1->WhatDoICallThisFunction(min,totobs,vecshapes); //plhs[0] = mxCreateDoubleMatrix(2*n,3,mxREAL); plhs[0] = mxCreateDoubleMatrix(n,7,mxREAL); double *xout; xout = mxGetPr(plhs[0]); ctomatmatrix(mout,xout); delete l1; }