ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi,

I got it working with MathGL 1.11, which can be installed from the 12.04 Ubuntu repository. If additionally the GNU Scientific Library (GSL) is to be used, you find it in the repository (don't forget to install the SDK also).

First:

Install MathGl and additionally the development package libmgl-dev. The include path the is in /usr/include/mgl

Second:

Add in the CMakeLists.txt the following entries:

{

for adding the GNU Scientific Library

  • find_package( PkgConfig REQUIRED)
  • pkg_check_modules( gsl REQUIRED gsl )

}

  • add_executable( ... mathgl_example.cpp ## find the example in appendix )
  • arget_link_libraries(ros_function_safety_trajectoryplanning_conti_node ${catkin_LIBRARIES}

    ${gsl_LIBRARIES} ## if you want to add the GNU Scientific Library also mgl mgl-fltk

    roscpp roslib rostime roscpp_serialization rosconsole pthread rt )

Third:

Include mathgl_example.cpp / .h in your project and

evoke it from eg. main()

// ====> MATHGL mglGraphFLTK mathglHnd; static pthread_t mathglThread; CMATHGL_EXAMPLE* mathgl=new CMATHGL_EXAMPLE(&mathglHnd, &mathglThread); // ===========

Hi,

I got it working with MathGL 1.11, which can be installed from the 12.04 Ubuntu repository. If additionally the GNU Scientific Library (GSL) is to be used, you find it in the repository (don't forget to install the SDK also).

First:

Install MathGl and additionally the development package libmgl-dev. The include path the is in /usr/include/mgl

Second:

Add in the CMakeLists.txt the following entries:

{

for adding the GNU Scientific Library

  • find_package( PkgConfig REQUIRED)
  • pkg_check_modules( gsl REQUIRED gsl )

}

  • add_executable( ... mathgl_example.cpp ## find the example in appendix )
  • arget_link_libraries(ros_function_safety_trajectoryplanning_conti_node target_link_libraries(ros_function_safety_trajectoryplanning_conti_node ${catkin_LIBRARIES}

    ${gsl_LIBRARIES} ## if you want to add the GNU Scientific Library also mgl mgl-fltk

    roscpp roslib rostime roscpp_serialization rosconsole pthread rt )

Third:

Include mathgl_example.cpp / .h in your project and

evoke it from eg. main()

// ====> MATHGL mglGraphFLTK mathglHnd; static pthread_t mathglThread; CMATHGL_EXAMPLE* mathgl=new CMATHGL_EXAMPLE(&mathglHnd, &mathglThread); // ===========

mathgl_example.h:

include <mgl mgl_fltk.h="">

include <pthread.h>

ifndef MATHGL_EXAMPLE_H_

define MATHGL_EXAMPLE_H_

class CMATHGL_EXAMPLE { public: CMATHGL_EXAMPLE(mglGraphFLTK* mathglHnd, pthread_t* mathglThread); ~CMATHGL_EXAMPLE();

};

endif /* MATHGL_EXAMPLE_H_ */

=======mathgl_example.cpp

int sample(mglGraph gr, void *) { mglData a(50,15),d(50),d1(50),d2(50); d.Modify("0.7sin(2pix) + 0.5cos(3pix) + 0.2sin(pix)"); d1.Modify("cos(2pix)"); d2.Modify("sin(2pix)"); a.Modify("pow(x,4y)");

gr->NewFrame();
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Simple plot of one curve");
gr->Plot(d);
gr->EndFrame();

gr->NewFrame();
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Three curves with manual styles");
gr->Plot(d,"b");
gr->Plot(d1,"ri");
gr->Plot(d2,"m|^");
gr->Plot(d,"l o");
gr->EndFrame();

gr->NewFrame();
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Three curves with automatic styles");
gr->Plot(d);
gr->Plot(d1);
gr->Plot(d2);
gr->EndFrame();

gr->NewFrame();
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Curves from matrix");
gr->Plot(a);
gr->EndFrame();

gr->NewFrame();
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Parametrical curves in 2D");
gr->Plot(d1,d2,"b");
gr->Plot(d1,d,"ri");
gr->EndFrame();

gr->NewFrame();
gr->Text(mglPoint(0,1.2,1),"Parametrical curves in 3D");
gr->Rotate(60,40);
gr->Box();  gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y"); gr->Label('z',"z");
gr->Plot(d1,d2,d,"b");
gr->EndFrame();

gr->NewFrame();
gr->SubPlot(2,2,0);
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Area plot");
gr->Area(d);
gr->SubPlot(2,2,1);
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Step plot");
gr->Step(d);
gr->SubPlot(2,2,2);
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Stem plot");
gr->Stem(d);
gr->SubPlot(2,2,3);
gr->Box();  gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y");
gr->Text(mglPoint(0,1.2,1),"Bars plot");
gr->Bars(d);
gr->EndFrame();

gr->NewFrame();
gr->SubPlot(2,2,0);
gr->Text(mglPoint(0,1.2,1),"Area plot in 3D");
gr->Rotate(60,40);
gr->Box();  gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y");
gr->Area(d1,d2,d);
gr->SubPlot(2,2,1);
gr->Text(mglPoint(0,1.2,1),"Step plot in 3D");
gr->Rotate(60,40);
gr->Box();  gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y");
gr->Step(d1,d2,d);
gr->SubPlot(2,2,2);
gr->Text(mglPoint(0,1.2,1),"Stem plot in 3D");
gr->Rotate(60,40);
gr->Box();  gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y");
gr->Stem(d1,d2,d);
gr->SubPlot(2,2,3);
gr->Text(mglPoint(0,1.2,1),"Bars plot in 3D");
gr->Rotate(60,40);
gr->Box();  gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y");
gr->Bars(d1,d2,d);
gr->EndFrame();
return gr->GetNumFrame();

}

void *mgl_fltk_tmp(void *) { mglFlRun(); return 0; }

CMATHGL_EXAMPLE::CMATHGL_EXAMPLE(mglGraphFLTK* mathglHnd, pthread_t* mathglThread) { mathglHnd->Window(0,0,sample,"Test"); pthread_create(mathglThread, 0, mgl_fltk_tmp, 0); };

CMATHGL_EXAMPLE::~CMATHGL_EXAMPLE() { };