|
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 <algorithm>#include <cstdint>#include <set>#include <string>#include <typeinfo>#include <vector>#include "mexplus/mxtypes.h"

Go to the source code of this file.
Classes | |
| class | MxArray |
| mxArray object wrapper for data conversion and manipulation. More... | |
Namespaces | |
| namespace | mexplus |
| MEX function arguments helper library. | |
Macros | |
| #define | MEXPLUS_CHECK_NOTNULL(pointer) |
| MxArray data conversion library. | |
| #define | MEXPLUS_ERROR(...) mexErrMsgIdAndTxt("mexplus:error", __VA_ARGS__) |
| #define | MEXPLUS_WARNING(...) mexWarnMsgIdAndTxt("mexplus:warning", __VA_ARGS__) |
| #define | MEXPLUS_ASSERT(condition, ...) if (!(condition)) mexErrMsgIdAndTxt("mexplus:error", __VA_ARGS__) |
| #define | NOEXCEPT |
| #define MEXPLUS_ASSERT | ( | condition, | |
| ... ) if (!(condition)) mexErrMsgIdAndTxt("mexplus:error", __VA_ARGS__) |
| #define MEXPLUS_CHECK_NOTNULL | ( | pointer | ) |
MxArray data conversion library.
Copyright 2014 Kota Yamaguchi.
The library provides mexplus::MxArray class for data conversion between mxArray* and C++ types. The static API's are the core of the high-level conversions.
int value = MxArray::to<int>(prhs[0]); string value = MxArray::to<string>(prhs[0]); vector<double> value = MxArray::to<vector<double> >(prhs[0]);
plhs[0] = MxArray::from(20); plhs[0] = MxArray::from("text value."); plhs[0] = MxArray::from(vector<double>(20, 0));
Additionally, object API's are there to wrap around a complicated data access.
MxArray cell(prhs[0]); // Assumes cell array in prhs[0]. int x = cell.at<int>(0); vector<double> y = cell.at<vector<double> >(1);
MxArray numeric(prhs[0]); // Assumes numeric array in prhs[0]. double x = numeric.at<double>(0); int y = numeric.at<int>(1);
MxArray cell(MxArray::Cell(1, 3)); cell.set(0, 12); cell.set(1, "text value."); cell.set(2, vector<double>(4, 0)); plhs[0] = cell.release();
MxArray numeric(MxArray::Numeric<double>(2, 2)); numeric.set(0, 0, 1); numeric.set(0, 1, 2); numeric.set(1, 0, 3); numeric.set(1, 1, 4); plhs[0] = numeric.release();
To add your own data conversion, define in namespace mexplus a template specialization of MxArray::from() and MxArray::to(). Macro definitions.
| #define MEXPLUS_ERROR | ( | ... | ) | mexErrMsgIdAndTxt("mexplus:error", __VA_ARGS__) |
| #define MEXPLUS_WARNING | ( | ... | ) | mexWarnMsgIdAndTxt("mexplus:warning", __VA_ARGS__) |
| #define NOEXCEPT |