#include "MatlabDataArray.hpp"
#include "MatlabEngine.hpp"
void client(matlab::engine::MATLABEngine* matlabPtr) {
// Create MATLAB data array factory
matlab::data::ArrayFactory factory;
// Define the input arguments
matlab::data::TypedArray<double> weedUV = factory.createArray<double>(
{ 1, 2 }, { 117.0, 91.0 }); //weedUV[0], weedUV[1]
matlab::data::TypedArray<double> orientation = factory.createArray<double>(
{ 1, 4 }, { 0.1445, 0.784, 0.712, 0.456 }); //orientation.w, orientation.x, orientation.y, orientation.z
matlab::data::TypedArray<double> robotPosition = factory.createArray<double>(
{ 1, 2 }, { 5.947123, 2.1457 }); // robotPosition[0], robotPosition[1]
matlab::data::CharArray cameraFrame = factory.createScalar("right_camera");
//Define the projection Matrix
matlab::data::TypedArray<double> const projectionMatrix = factory.createArray<double>(
245.6983, 0.0, 318.6139, 0.0,
0.0, 253.3011, 243.9297, 0.0,
// Pass vector containing 2 scalar args in vector
std::vector<matlab::data::Array> args({
// Call the MATLAB function
std::cout << "calling the api function" << std::endl;
matlab::data::TypedArray<double> points = matlabPtr->feval(u"api", args);
std::cout << "x: " << x << ", y: " << y << std::endl;
using namespace matlab::engine;
// Start MATLAB engine synchronously
std::unique_ptr<matlab::engine::MATLABEngine> matlabPtr = matlab::engine::startMATLAB();
matlabPtr->eval(u"rosshutdown;");
matlabPtr->eval(u"rosinit;");
// Call the client function with the MATLAB engine pointer
matlabPtr->eval(u"rosshutdown;");