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