Thanks Jerome, I understand that calling the VirtuoseAPI functions are thread-safe from either the application code or inside the periodic function. My question is about querying variables that are not owned and protected by the haptic service. Let me give an example: Let's say we have two objects in a scene, one is the master attached to the device end-effector, and the other one is a slave that is connected with some user-defined coupling mechanism to the master. The dynamic simulation callback will then look something like this:
void PeriodicCB(VirtContext VC, void* pUserData)
{
float MasterPos[7], SlavePos[7], MutualForce[6];
virtGetPosition(VC, MasterPos);
//Perform dynamic simulation between master & slave:
MyDynamicsFunc(MasterPos, SlavePos, MutualForce);
virtSetForce(VC, MutualForce);
}
The function MyDynamicsFunc() takes the master position as input, and computes and returns the slave position and mutual force as output. Now after calling virtSetPeriodicFunction(VC, PeriodicCB, 0.001f, NULL) and virtStartLoop(), the master position and mutual force can be queried outside the periodic function (e.g., inside the graphics rendering loop) using VirtuoseAPI functions, but how would you query the most recent slave position?
Thanks,
Morad