Building my own driver

Making & changing hardware drivers in Acquisition Server
Post Reply
Lucie
Posts: 6
Joined: Thu Feb 04, 2010 11:02 am

Building my own driver

Post by Lucie »

Hello,

I would like to create a new driver.

The documentation is clear, except for one thing : how can I use the driver I write ?
To be more precise, I don't know how to compile the c++ code and make the Acquisition server recognise it.

Could you please either explain it to me or point me to the part of the documentation I may have missed ?

Best regards.
Lucie

nbaron
Posts: 23
Joined: Mon Jan 18, 2010 4:54 am

Re: Building my own driver

Post by nbaron »

Hi,

In 5 steps :
1) Download SVN source (or latest stable source)
2) Build the source (with the script in the folder */scripts/) to obtain an IDE project (I use VS2008).
There is a doc for that on the website and some tutos on the forum.
3) In the project "OpenVibe-acquisition-server-dynamic" you can add the source of your driver class.
3 bis) I prefer to manually add the source in a folder like :
*/openvibe-applications/acquisition-server/tags/X.X.X/src/{myDriverName}/
And include the .cpp and .h manually in the project.
4) Add this line after line 300 :

Code: Select all

m_vDriver.push_back(new CDriver{myDriverName}(*m_pDriverContext));
5) Build ALL the solution.

This is just the way I think you can add a driver. But did'nt try it yet and I did not find a doc or a more simple way.

{myDriverName} : name of your driver. e.g. GenericOscillator

Lucie
Posts: 6
Joined: Thu Feb 04, 2010 11:02 am

Re: Building my own driver

Post by Lucie »

Thanks !

I am on Linux, I will try to adapt this solution and post an update soon.

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Building my own driver

Post by yrenard »

Dear Lucie,

welcome on this board and thank you for your interest in OpenViBE.

Indeed, Laurent who developed his first driver in september / october just in the same room as me already told me exactly what you are just saying... I just didn't update the documentation, sorry...

So if you want to test / use your driver, just put it in the openvibe-applications/acquisition-server/trunc/src/your-driver-name.

Then edit the openvibe-applications/acquisition-server/trunc/src/ovasCAcquisitionServer.cpp and see what is done for the other drivers. It is as easy as that.

Hope to receive a patch for your contribution soon ;) What acquisition device are you using ?

Best regards,
Yann

PS: hey nbaron, you are faster than me - I'll be able to leave on holidays soon, thanks ;)

Lucie
Posts: 6
Joined: Thu Feb 04, 2010 11:02 am

Re: Building my own driver

Post by Lucie »

Thank you, it works !

I just compiled a dummy driver which is the Generic oscillator with another name. I can see it in the pop up list when I use the acquisition server.

I just have to write the actual code :wink:
I am trying to write a driver for a gTec product : the gMOBIlab+.

Is there a way to run Cmake only in the src directory where the code of my driver lies ? I currently run linux-build, which takes some time verifying everything is already built.
Even if running Cmake only in this directory is not enough to get OpenVibe to recognize the driver, I would like to do it in order to check for syntax errors before launching linux-build which, as I said, takes some time to run.

Best Regards

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Building my own driver

Post by yrenard »

Dear Lucie,

see this FAQ entry. It works on Windows but also works on Linux :p

Best regards,
Yann

Lucie
Posts: 6
Joined: Thu Feb 04, 2010 11:02 am

Re: Building my own driver

Post by Lucie »

Good morning,

It looks like the documentation disagrees with the code of the other drivers.
I assume that the code of the other drivers is correct. Indeed, doing as in the documentation leads to a failure when compiling and a grep on all the source files for OpenViBEAcquisitionServer::boolean returns nothing.

The differences are :
  • Classes for drivers are put in the namespace OpenViBEAcquisitionServer (I don't know why exactly, but this is not mentioned in the doc)
  • OpenViBEAcquisitionServer::boolean and OpenViBEAcquisitionServer::uint32 do not exist, everybody use OpenViBE::boolean and OpenViBE::uint32 instead.
This is not a big deal, but you may want to update the documentation.

Best regards,
Lucie

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Building my own driver

Post by yrenard »

Dear Lucie,

I updated the documentation page with your remarks from today and yesterday. I also put the IDriverContext object in the sample code as it did not exist when the doc was first written.

See the updated page.

Thank you,
Yann

Lucie
Posts: 6
Joined: Thu Feb 04, 2010 11:02 am

Re: Building my own driver

Post by Lucie »

Hello,

I have a problem during the link edition : I have to use an external library which is located in /usr/lib/gMOBIlabplus.so and I don't know how to make the linker find it. I suppose that I have to modify the Cmake file but I don't know how.

Thanks for your help,
Lucie

Lucie
Posts: 6
Joined: Thu Feb 04, 2010 11:02 am

Re: Building my own driver

Post by Lucie »

Hello,

Sorry for that, I finally found what to do to add a new library !
Here is my code :

Code: Select all

[size=85]IF(UNIX)
	FIND_LIBRARY(gMOBIlabplus_LIBRARY NAMES gMOBIlabplus PATH /usr/lib /usr/local/lib) 
	IF (gMOBIlabplus_LIBRARY)
   	  SET(gMOBIlabplus_FOUND TRUE)
	ELSE(gMOBIlabplus_LIBRARY)
   	  MESSAGE(STATUS "    [FAILED] lib gMobiLabPlus")
	ENDIF (gMOBIlabplus_LIBRARY)

	IF (gMOBIlabplus_FOUND)
   	  IF (NOT gMOBIlabplus_FIND_QUIETLY)
	    MESSAGE(STATUS "    [  OK  ] Third party lib ${gMOBIlabplus_LIBRARY}")
	    TARGET_LINK_LIBRARIES(${PROJECT_NAME}-dynamic ${gMOBIlabplus_LIBRARY} )
   	ENDIF (NOT gMOBIlabplus_FIND_QUIETLY)
	ELSE (gMOBIlabplus_FOUND)
   	  IF (gMOBIlabplus_FIND_REQUIRED)
      	  MESSAGE(FATAL_ERROR "Could not find gMobiLab+")
   	ENDIF (gMOBIlabplus_FIND_REQUIRED)
	ENDIF (gMOBIlabplus_FOUND)
ENDIF(UNIX)[/size]
Best regards,
Lucie

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: Building my own driver

Post by yrenard »

Dear Lucie,

what's up with the g.Mobilab driver ?

Yann

lfsuarez
Posts: 4
Joined: Mon Feb 27, 2012 6:55 pm

Re: Building my own driver

Post by lfsuarez »

Hi everybody

In this moment i am working with research in the
area of BCI, for this reason iḿ trying to use gMOBIlab with OpenVIBE,
but actually i have i problem and I did not obtained that the
Acquisition server recognize me the gMOBIlab.

I actually think that the problem it has to do with Cmake file that seeking for the libraries of
gMOBIlab. When I make the construction of openvibe, i saw that
couldn't find the libraries, even though I did the installation of
gMOBIlab software in version 1.11.00, which I think is the last. I
think that maybe there is an incompatibility issue with the latest
version of the software .... I wonder if you have any idea that could
do.

Thanks,

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Building my own driver

Post by lbonnet »

Hi lfsuarez,

Which OS are you working on ?
For the record, the gMobilabPlus driver is only compatible with Linux (a contribution from Lucie, as you can see in this topic)

If at compilation time the build process failed to find the gMobilabPlus API, take a look at the file
cmake-modules/FindThirdPartyGMobiLabPlusAPI.cmake
Maybe you will find some incoherence with your installation.

Please provide build log, OS, openvibe version etc. the more we have details, the more we can help !

Laurent
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

lfsuarez
Posts: 4
Joined: Mon Feb 27, 2012 6:55 pm

Re: Building my own driver

Post by lfsuarez »

Hi laurent ... thanks for your help

The OS on which i'm working on it's ubuntu 11.10, the version of openvibe 0.13.1 and I have also installed the libraries of g.MOBIlabPlus for linux ..the version 1.11.00. I have done my own tests, with the demo that the gMOBIlab brings and the connection has performed without problems.

Laurent i was already reviewing the cmake file you specified, and what I found there was a difference in the library file name that is looking at findlibrary function. I found in the /usr/lib a library with the name libgmobilabplusapi.so.1.11 libgmobilabplusapiso.so.1.11.00. This is the content of the cmake file currently

#
# The gMobilab driver was contributed
# by Lucie Daubigney from Supelec Metz
#

# ---------------------------------
# Finds GTecMobiLabPlus+
# Adds library to target
# Adds include path
# ---------------------------------

IF(UNIX)
FIND_LIBRARY(gMOBIlabplus_LIBRARY NAMES gMOBIlabplus PATHS /usr/lib /usr/local/lib)
IF(gMOBIlabplus_LIBRARY)
MESSAGE(STATUS " Found GMobiLabPlusAPI...")
MESSAGE(STATUS " [ OK ] lib ${gMOBIlabplus_LIBRARY}")
ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyGMobiLabPlusAPI)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}-dynamic ${gMOBIlabplus_LIBRARY} )
ELSE(gMOBIlabplus_LIBRARY)
MESSAGE(STATUS " FAILED to find : GMobiLabPlusAPI...")
ENDIF(gMOBIlabplus_LIBRARY)
ENDIF(UNIX)



Actually I'm not sure how I could modify the cmake, but i made some test changed the name of the library who is looking for ... and practically did the installation again, without getting new results i still receiving this message: FAILED to find : GMobiLabPlusAPI...
also he didn't find BLiFF++,

I really dont know what else I can do ...

Post Reply