VREP and Arduino interface through VREP Remote APIs

Requests or suggestions for new features
Post Reply
AmmarAkhlaq
Posts: 2
Joined: 27 Jul 2015, 12:11

VREP and Arduino interface through VREP Remote APIs

Post by AmmarAkhlaq »

Hello,
I am Ammar Akhlaq and i am working on VREP from healthy period of time now.

Now what I wana to interface Arduino and VREP With Remote APIs which is quit possible i think. I already went through all the post regarding it but found nothing which can clear my confusion

I have few question that needs clarification. I have already used the remote APIs for quit few of my project.For all what i did ,is I created client sever in Visual Studio and executed the exe file for client from server side Which VREP. All work fine but now i wana control simulation using external hardware let say arduino in first phase: and my questions for that:

1: I want to use Arduino IDE not Visual studio So how to defined NON_MATLAB_PARSING and MAX_EXT_API_CONNECTIONS=255 as a preprocessor definition. as no option is available in Arduino IDE as we have in visual Studio .

2: Previously I was copy my client application exe file in to folder where i have VRep exe file. then i use Lua commad simLaunchExecutable to execute it now my client will be running in Arduino with remote APIs and I think VREP will not execute it automatically so what is the replacement method to do this step and execute the code in Arduino ?

3:How VREP will know that Now it has to read data from arduino which is connect to one of the computer port? I do not wana do serial data communication and then run Lua commands in VREP as did you mention in this post (Hardware-in-the-loop remote API plugin).Want to Run actual remote APi as i did in my previous client projects but replacing PC with external hardware Arduino.
I understand that serial communication will be some how involve.

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

Re: VREP and Arduino interface through VREP Remote APIs

Post by coppelia »

Hello,

about your questions:

1. if your IDE does not allow you to specify preprocessor commands, you could directly define them in your code (but make sure that those definitions are defined for each file being compiled):

Code: Select all

#define NON_MATLAB_PARSING
#define MAX_EXT_API_CONNECTIONS=255
2. You won't be able to start the remote API client execution if it is located on some different hardware. But you can do the other way round: start the simulation from the remote API client with simxStartSimulation. This will however only work with continuous remote API cserver services.

3. I don't understand your question there. If the remote API client is running on the Arduino, then you would read either the V-REP sensors (via the remote API), or the real sensor. In a similar way, you would send the desired joint positions to V-REP via the remote API, or to the real motors.

Cheers

AmmarAkhlaq
Posts: 2
Joined: 27 Jul 2015, 12:11

Re: VREP and Arduino interface through VREP Remote APIs

Post by AmmarAkhlaq »

about 3rd question:
yes,I wanna do exactly as you said.My question there was.
How VREP will differentiate (recognize) that it is being controlling by External Hardware.

and moreover

Can I tell VREP to Communicate with the hardware connected to specific port of computer. Like connect and read from computer port 3 where arduino is connected.
Thanks a lot for reply.

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

Re: VREP and Arduino interface through VREP Remote APIs

Post by coppelia »

When you control V-EP from an external application/hardware, it doesn't directly notice the difference. For example:

From a remote API client, you set a joint target speed:

Code: Select all

simxSetJointTargetVelocity(clientID,jointHandle,targetVelocity,simx_opmode_oneshot);
What will happen is the remote API client will send the command to a V-REP plugin (v_repExtRemoteApi), which will decode the command and execute simSetJointTargetVelocity.

If you do this from a child script for instance, you simply call:

Code: Select all

simSetJointTargetVelocity(jointHandle,targetVelocity)
You basically execute the same function as the remote API plugin does.

From V-REP, you can also directly communicate with some external hardware, e.g. from a plugin, or, from a child script. In the latter case, you can open a serial port and communicate over it (e.g. simSerialOpen), or you can open a tcp connection and communicate over it (check the demo scene socketAndTubeCommunicationExample.ttt).

Cheers

Post Reply