Ask Your Question
0

mathgl binding with CMake

asked 2014-04-14 22:31:37 -0500

MartinHummel gravatar image

updated 2016-10-24 08:37:00 -0500

ngrennan gravatar image

(ROS GROOVY) Hi,

has anybody the plotting library MathGl included into the CMake process? Under https://groups.google.com/forum/#!top... I found a FindMathGL.cmake which I evoked in cmakelist.txt:

##MH Include a custom cmake file for MathGl list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) find_package(MathGL REQUIRED)

It stops with: CMake Error at function/safety_trajectoryplanning_conti/ros/cmake/FindMathGL.cmake:67 (MESSAGE): Cannot determine MathGL version: mgl2/config.h parse error -- Configuring incomplete, errors occurred!

whereby the path mgl2/config.h was not found. MathGL was installed in /usr/local/lib and include. I put a symlink to /usr/include - lib, which was not working.

MathGL can be found here: http://mathgl.sourceforge.net/doc_en/...

thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-04-24 21:27:11 -0500

MartinHummel gravatar image

updated 2014-04-24 21:31:34 -0500

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 )
  • 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 ...
(more)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-04-14 22:31:37 -0500

Seen: 864 times

Last updated: Apr 24 '14