Hello Mworks developers,
I’m considering Mworks to run an experiment that would use a haptic robot. For now I use my own program, but a lot of MWorks niceties would be nice to have ! In such a scenario, the robot handle position would control a cursor on the screen, and forces would be rendered by the robot.
Typically, the robot is controlled by a library with two simple commands, one to get the position of the robot handle, and one to tell the robot to apply a given force. In my current implementation, these are called in a busy loop that runs on a separate thread, and the update rate is 4KHz (which is the optimal and maximal refresh rate). The function which sets the force appears to be waiting which explains the fixed rate (if the time is missed, it will wait 250us more).
The forces are most of the time computed as a function of the position/speed of the robot handle. For example if you want to simulate a spring, you set the force vector to k.(p_handle-p_origin), or if you want to simulate viscosity, the force is -k.velocity. Currently I use a set of force “objects” (which state changes during a trial). You can imagine them as the equivalent of visual objects of a visual scene, but those are rendered haptically: the force to output is just the sum of the force vectors generated by each object.
Would the architecture of Mworks be suited for such an application ?
By discussing with mworks user in my lab, there were suggestions of writing plugins for the robot, for the force objects, and I guess also for a renderer. In that scenario, we would have:
-
Robot plugin gathers the position
-
Cursor (visual object) position is set from the robot position
-
Force objects are informed of the robot position/speed
-
Forces of the force objects are retrieved, summed
-
The obtained force is send to the robot by the robot plugin.
-
and 5) must be separated by less than 250us. It’s of course desirable that the force obtained is computed from the last position read, not the previous one or a mix of the two. Would such an update rate be possible ? How difficult would that be ?
Thanks for your input,
Pierre