|
MocoExtendProblem: Interface Between OpenSim and MATLAB for Rapidly Developing Direct Collocation Goals in Moco 1.1.0
add custom Moco goals to existing matlab scripts
|
#include <mex.h>#include <map>#include <memory>#include <string>

Go to the source code of this file.
Classes | |
| class | Operation |
| Abstract operation class. More... | |
| class | OperationCreator |
| Base class for operation creators. More... | |
| class | OperationCreatorImpl< OperationClass > |
| Implementation of the operation creator to be used as composition in an Operator class. More... | |
| class | OperationFactory |
| Factory class for operations. More... | |
| class | Session< T > |
| Key-value storage to make a stateful MEX function. More... | |
Namespaces | |
| namespace | mexplus |
| MEX function arguments helper library. | |
Macros | |
| #define | MEXPLUS_AT_EXIT |
| MEX dispatch library. | |
| #define | MEXPLUS_AT_INIT |
| #define | MEXPLUS_AT_ERROR(name) |
| #define | MEX_DEFINE(name) |
| Define a MEX API function. | |
| #define | MEX_DEFINE2(name, admitter) |
| Define a MEX API function using a private admitter. | |
| #define | MEX_DISPATCH |
| Insert a function dispatching code. | |
Typedefs | |
| typedef bool | OperationNameAdmitter(const std::string &name) |
Functions | |
| void | CreateOperation (OperationNameAdmitter *admitter, OperationCreator *creator) |
| Register a new creator in OperationFactory. | |
| #define MEX_DEFINE | ( | name | ) |
Define a MEX API function.
Example:
MEX_DEFINE(myfunc) (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if (nrhs != 1 || nlhs > 1) mexErrMsgTxt("Wrong number of arguments."); ... }
| #define MEX_DEFINE2 | ( | name, | |
| admitter ) |
Define a MEX API function using a private admitter.
Example:
static bool myfunc_admitter(std::string& name) { return name == "myfunc"; }
MEX_DEFINE2(myfunc, myfunc_admitter) (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if (nrhs != 1 || nlhs > 1) mexErrMsgTxt("Wrong number of arguments."); ... }
| #define MEX_DISPATCH |
Insert a function dispatching code.
Use once per MEX binary.
| #define MEXPLUS_AT_ERROR | ( | name | ) |
| #define MEXPLUS_AT_EXIT |
MEX dispatch library.
Copyright 2014 Kota Yamaguchi.
This helper contains MEX_DEFINE() macro to help create a dispatchable MEX file. Two files are required to create a new mex function. Suppose you are creating two MEX functions myfunc and myfunc2. Then, make the following files.
myfunc.m
function output_args = myfunc(varargin)
%MYFUNC Description of the function.
%
% Details go here.
%
output_args = mylibrary(mfilename, varargin{:})
end
myfunc2.m
function output_args = myfunc(varargin)
%MYFUNC Description of the function.
%
% Details go here.
%
output_args = mylibrary(mfilename, varargin{:})
end
These files contains help documentation and a line to invoke the mex function.
mylibrary.cc
#include <mexplus/dispatch.h>
MEX_DEFINE(myfunc) (int nlhs, mxArray* plhs[],
int nrhs, const mxArray* prhs[]) {
...
}
MEX_DEFINE(myfunc2) (int nlhs, mxArray* plhs[],
int nrhs, const mxArray* prhs[]) {
...
}
MEX_DISPATCH
This file is the implementation of the mex function. The MEX_DEFINE macro defines an entry point of the function. MEX_DISPATCH macro at the end inserts necessary codes to dispatch function calls to an appropriate function.
Similarly, you can write another pair of .m (and C++) file to add to your library. You may split MEX_DEFINE macros in multiple C++ files. In that case, have MEX_DISPATCH macro in one of the files.
| #define MEXPLUS_AT_INIT |