Mind controlled Robot

Typically: "How do I... ", "How can I... " questions
Post Reply
antoo
Posts: 2
Joined: 08 Jan 2015, 13:31

Mind controlled Robot

Post by antoo » 09 Jan 2015, 15:45

Hi,

I have an important project to finish soon, I am supposed to control a manipulator DoF 7 with open vibe, an other software able to process EEG ( electrical signals from the brain). I am supposed to write a client in C++ on Vrep in order to retreive data sent by open vibe. How should I do that ? Using a plug in seems to be the best way but does some other easier option exist ? Should I just use the skeleton available on the install folder and write my code in it ?

Eric
Posts: 186
Joined: 11 Feb 2013, 16:39

Re: Mind controlled Robot

Post by Eric » 10 Jan 2015, 00:05

Hi

Can you detail a little bit more on the architecture? How do you do to retrieve data sent by openVIBE?
How are you using openVIBE? as an application or as a library? If it is as an application, you can either use an ad-hock socket communication with V-REP or a remoteAPI. If it is as a library, then a plugin is recommended.

Cheers

Eric

antoo
Posts: 2
Joined: 08 Jan 2015, 13:31

Re: Mind controlled Robot

Post by antoo » 10 Jan 2015, 00:36

Thank you very much for helping me I am kind of lost as I am not use to program that much !

Code: Select all

#include <iostream>
 
#include <vrpn_Button.h>
#include <vrpn_Analog.h>
 
void VRPN_CALLBACK vrpn_button_callback(void* user_data, vrpn_BUTTONCB button)
{
    std::cout << "Button ID : " << button.button << " / Button State : " << button.state << std::endl;
 
    if (button.button == 1)
    {
        *(bool*)user_data = false;
    }
}
 
int main(int argc, char** argv)
{
    /* flag used to stop the program execution */
    bool running = true;
 
    /* VRPN Button object */
    vrpn_Button_Remote* VRPNButton;
 
    /* Binding of the VRPN Button to a callback */
    VRPNButton = new vrpn_Button_Remote( "openvibe_vrpn_button@localhost" );
    VRPNButton->register_change_handler( &running, vrpn_button_callback );
 
  
 
    /* The main loop of the program, each VRPN object must be called in order to process data */
    while (running)
    {
        VRPNButton->mainloop();
    }
 
    return 0;
}
The code above is the client i am supposed to write on VREP
With open vibe, i created a server box which send a "a button" with states and id I need to retreive this id and button on VREP, so i think i am using open vibe as an application. It is a brain computer interface that must send button to vrep. But i am not sure, how could i know for sure if i am using it as library or not ?

coppelia
Site Admin
Posts: 7267
Joined: 14 Dec 2012, 00:25

Re: Mind controlled Robot

Post by coppelia » 11 Jan 2015, 13:30

Hello,

not sure how open VIBE is being used. But you probably have several possibilities:
  • write a V-REP plugin that will link to the open VIBE library. That way, your plugin could register new script functions that allow you to interact with the library. This is actually the more difficult (but most flexible approach). For that, have a look at the various plugin examples located in the programming folder (plugin projects all start with v_repExt...)
  • include a few source code files into your open VIBE application. Those few files will allow you to communicate with V-REP. This is the remote API approach. This is easier than the above described approach, but will introduce some communication delays (a few ms) and is not as flexible
  • you can directly establish a socket communication from within a child script, and interact with open VIBE that way (if open VIBE allows for that)
Cheers

Post Reply