help request to add a new grabber

Hi,
I have created a new grabber for a stereo camera which is dependent of a non GPL library, so I can't include sources of this library in MRPT.
I have modified the CameraSensor class for include this grabber.
I have modified the file CMakeList in the top-level folder of mrpt :

SET( MRPT_HAS_SVS OFF CACHE BOOL "Add support for STOC Stereo Camera?")
IF(MRPT_HAS_SVS)
SET( SVS_ROOT_DIR "" CACHE PATH "Path to SVS library root directory")

IF(WIN32)
MESSAGE("Sorry! STOC camera is supported only for LINUX yet. Set MRPT_HAS_SVS to OFF")
SET(CMAKE_MRPT_HAS_SVS 0)
ELSE(WIN32)
# Set to 1, next check for missing things and set to 0 on any error & report message:
SET(CMAKE_MRPT_HAS_SVS 1)

IF(NOT EXISTS S{SVS_ROOT_DIR})
SET(CMAKE_MRPT_HAS_SVS 0)
MESSAGE("The directory 'SVS_ROOT_DIR' does not exists. Turn off SVS support or provide the correct path.")
ENDIF(NOT EXISTS S{SVS_ROOT_DIR})

IF(NOT EXISTS S{SVS_ROOT_DIR}/srcECA_MODIFIED/svsclass.h)
SET(CMAKE_MRPT_HAS_SVS 0)
MESSAGE("The directory 'SVS_ROOT_DIR' does not contain srcECA_MODIFIED/svsclass.h. Turn off SVS support or provide the correct path.")
ENDIF(NOT EXISTS S{SVS_ROOT_DIR}/srcECA_MODIFIED/svsclass.h)

IF(NOT EXISTS S{SVS_ROOT_DIR}/srcECA_MODIFIED/dcs.h)
SET(CMAKE_MRPT_HAS_SVS 0)
MESSAGE("The directory 'SVS_ROOT_DIR' does not contain srcECA_MODIFIED/dcs.h. Turn off SVS support or provide the correct path.")
ENDIF(NOT EXISTS S{SVS_ROOT_DIR}/srcECA_MODIFIED/dcs.h)

ENDIF(WIN32)

ENDIF(MRPT_HAS_SVS)

CREATE_CMAKE_MRPT_DEFINE(MRPT_HAS_SVS)

IF(CMAKE_MRPT_HAS_SVS)
INCLUDE_DIRECTORIES("S{SVS_ROOT_DIR}/srcECA_MODIFIED")

LINK_DIRECTORIES("S{SVS_ROOT_DIR}/bin")
ENDIF(CMAKE_MRPT_HAS_SVS)

SHOW_CONFIG_LINE("Has videre stereo camera " CMAKE_MRPT_HAS_SVS)

and config.h.in :

#define MRPT_HAS_SVS S{CMAKE_MRPT_HAS_SVS}

My mrpt version compil correctely with and without my grabber.
The Application rawlog-grabber and rawlogviewer run correctly with my grabber.
But if I link on hwdrivers with a others program the compilator didn't find the headers than my grabber use.
I didn't know how to create the link between hwdrivers and the headers of the non-opensource library.

Could you please tell me how to enable cmake to add automaticaly the header folder of the non-opensource library when I use FIND_PACKAGE(MRPT REQUIRED hwdrivers).

Best regards,
Cyril Gerber.

jlblanco's picture

Hi Cyril, First, would be

Hi Cyril,

First, would be willing to contribute your implementation to the main MRPT sources when you cosider it's more or less stable? (I've sent you an email with more details on this).

Second, on the question itself:
If you mean that you do have includes of a third-party library in your new mrpt-hwdriver class, that's a though problem without a very easy and clean solution.
One solution is to propagate all the include dirs ("-I" flags) to MRPTConfig.cmake, pkg-config files, etc... but I don't think it's a scalable solution since:
1) the end-user will end-up with tons of -I flags
2) thinking of Linux (eg Ubuntu) -dev packages, it would add an additional dependency (in this case I think it's not the case if the SVS lib is not in Ubuntu repositories, right?)

All in all, I always prefer to solve this in this way: opaque pointers. You can see examples of this, for example, in mrpt::utils::CImage with the internal "IplImage*" (stored as a "void*"), and in many other places (a good example for your case is CImageGrabber_dc1394 and m_dc1394_lib_context, etc...).

I hope you like this approach... it's ugly for the programmer, but IMHO makes things easier for the final user of the library.

JL

Cyril_Gerber's picture

Hi, Thank you for your reply

Hi,

Thank you for your reply and have introduced me the way of opaque pointer.
I have used them for solve my problem.
I will work with my grabber during few weeks before commit my code, if it is stable.

Regards and congratulation for the world cup.

Cyril

Syndicate content

The Mobile Robot Programming Toolkit (MRPT) initiative (C) 2012