Page 1 of 1

Proper usage of B0 remote APIs simxCreatePublisher() and simxCreateSubscriber()

Posted: 07 Jun 2019, 11:48
by marcofe
Hi,

I have a Simulink model that needs to exchange data with V-REP. Specifically, I want to command the pose of a vision sensor object (i.e., using simxSetObjectPosition/simxSetObjectOrientation or, equivalently, simxSetObjectPose), while reading, in the subsequent iteration, the resulting camera velocity, its pose wrt to a given reference frame and the current image (i.e., using, respectively, simxGetObjectVelocity, simxGetObjectPose and simxGetVisionSensorImage).

I need a synchronous communication, so I set simxSynchronous on true and trigger manually V-REP through simxSynchronousTrigger. Every mentioned command is used by employing the default publisher/subsriber through simxDefaultPublisher and simxDefaultSubscriber calls.

With this setup, I'm experiencing several issues in the performances of the simulation. In particular, two main problems arise:

1. The commanded pose of the camera results from a one-step integration of a commanded velocity signal. Therefore, I can compare such commanded velocity with the measured velocity obtained from simxGetObjectVelocity. What I see is that the measured data have a delay of 3 simulation steps. For instance, for a simulation time step of 50ms, a command sent at 1s is read at 1,150s.

2. Apparently randomly, the image acquired through simxGetVisionSensorImage does not seem to be consistent with the camera motion, as several "peaks" appear in the evolution of the corresponding measured image moments.

In order to solve the two issues above, I tried to go deeper in the understanding of the B0 remote APIs. In particular, I wonder if using a custom Publisher/Subscriber for each command could solve something and how they should be used.
From the documentation, it is not clear to me how they should be used: do I need to define them only once, at the beginning of the program? Or are they supposed to replace the simxDefaultPublisher/Subscriber calls in the last input argument of the APIs?
When I try this last option, I receive the following error in Simulink:
Parameter must be a handle
.

Therefore, what should be the correct usage of custom publishers and subscribers? Despite the description of the issues is not exhaustive and could be due to other aspects of the complex Simulink model, would you have any hint about the reasons for such behaviours?

Thank you in advance

Re: Proper usage of B0 remote APIs simxCreatePublisher() and simxCreateSubscriber()

Posted: 14 Jun 2019, 12:40
by coppelia
Hello,

I am not sure I understood everything correctly. Sometimes is is easier to break down a question into smaller pieces at a time.
Can you post a minimalistic scene that illustrates the delay you are talking about? (best by simply modifying the existing simpleTest example programs for the B0-based remote API) Is the delay linked to the velocity value, or does the delay also happen with the position of an object for instance?
Does the simpleTest example program run fine, or do you notice any similar behaviour?

If you use a specific publisher or subscriber, then you should only create it once for a given message, e.g. at the beginning of your program. It allows you to have a separate communication line, with different properties (e.g. publishInterval).

Cheers